15

I've just started to put in the time to get to learn emacs. By default my meta key is bound to Esc, and I'm finding that really inconvenient. I read somewhere however that it's not a good idea to change the binding to Alt. Is that true? If not, how could I go about doing that?

0

5 Answers 5

8

It's bound to Alt by default for me, and I have no problems with that. Are you on a Mac perhaps? There it is bound to one of the other keys like option.

If you are on a mac, the way to change the key will probably vary based on which version of Emacs you're using--e.g., I think changing it in the terminal would be different than changing it on one of the windowed varieties.

Another thing to try: http://www.jwz.org/xkeycaps/ Look through the keyboard layout with this and see if any key is assigned to Meta. If not, try assigning it; otherwise try changing it. I haven't actually tried this, but it looks promising.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your reply :) I'm actually using red hat.
Well, I've never used red hat, but I do know that on Solaris it maps to a key different from alt, which in this case has a diamond on it (weird Sun keyboards). Maybe try either the windows key or whatever you have in place of it works?
5

If you are using a Mac, you can follow the directions from here:

"If you do not want to use the Esc key, you can specify a key to use as Meta. To specify a Meta key, select the Emulation tab of the Editor Preferences dialog."

You can then select to use Alt or Command as your Meta key.

2 Comments

Thanks for your reply :) I'm actually using red hat.
I think it will actually be the same settings. Worth trying at least.
3

For me, on my mac, it was bound to Alt by default, but I found it anoying because Alt is used for some special characters on Mac. I added these lines on my .emacs

(setq mac-function-modifier 'meta)
(setq mac-option-modifier nil)

Thus in your case, you would have to add this in your .emacs (I tried this solution, and it worked for me)

(setq mac-option-modifier 'meta) ; set alt-key to meta
(setq mac-escape-modifier nil) ; set esc-key to nil

1 Comment

I don't know why they downvoted you, your answer worked perfectly for me on my mac.
3

I'm guessing that you're on Mac, because I had the same problem. This is how I fixed it:

  1. Open Terminal
  2. Open up the preferences
  3. Open up the "Profiles" tab and choose the "Keyboard" tab with your current profile selected
  4. Below the long scroll box are a couple check boxes. Check "Use Option as Meta key."

I'm using OS X 10.11.5, so I don't know about older versions of Terminal. I imagine that it would be similar.

2 Comments

This is by far the easiest solution I've come across for Macs. Thank you
That is still true. However, in that case you cannot use option on your Mac to modify in Emacs, e.g. Alt-3 will not produce a #. See: stackoverflow.com/questions/45697790/…
1

I had to do this for emacs while remotely connected to my raspberry pi.

  1. Go to terminal.

  2. type:

    xmodmap -e "keysym Alt_L = Meta_L Alt_L"
    

This was suggested in xmodmap's manual

man xmodmap

Hope that helps :) I'm pretty new to this though so someone else may want to comment.

1 Comment

The OP asked for it to be done in Emacs. Using xmodmap would cause everything in that shell to be changed, not necessarily the desired outcome.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.