开发者

How to change the meta key in Emacs?

I've just started to put in the time to get to learn 开发者_StackOverflow中文版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?


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.


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.


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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜