Ubuntu – How to make xterm to send the Alt key to emacs as Meta

emacsxterm

I see that this question has been asked multiple times. The solutions given there in does not seem to apply to my setup. Here is my story:

I use ubuntu 12.0.04 LTS, with xmonad (not over gnome), and use xterm for my work. I would prefer to use xterm rather than a different terminal or emacs own window. When using emacs -nw, I see that Alt is not recognized. I verified using xev that Alt is indeed getting generated. Further, if I am using rxvt, I see that Alt is getting recognized by emacs -nw. I am using evil mode (as a long time vim user, and an emacs newbee), and I would really prefer not having my escape key rebound as alt (which was the solution given in another thread). What should I do? (If it helps, Alt-x on the xterm window without emacs running generates "ΓΈ" or if I run emacs -nw -Q).

Best Answer

As seen in the Arch Wiki, you need to make Xterm to send the correct escaped key to the program:

If you use the Alt key for keyboard shortcuts, you will need this in your resource file:

XTerm*metaSendsEscape: true

So, just do:

echo 'XTerm*metaSendsEscape: true' >> ~/.Xresources

And restart your Xterm session.

Related Question