OSX Emacs: unbind just the right alt?

2019-02-04 14:13发布

问题:

I'm using emacsformacosx.com and would like to stop the Meta_R (right meta, or right option key) on my Apple keyboard from being an Emacs meta key.

The reason is that I want to be able to continue using the right option key as a character modifier so that I can enter UTF-8 chars when writing in emacs. I know I can do a C-x 8 RET and type em dash, for example, but that's a lot more work than Alt_R -!

Is there some way of passing the keycode to global-unset-key? Or something else I'm overlooking?

I should be clear that I still want to be able to use the Meta_L binding :)

回答1:

Aquamacs has a variable called ns-right-alternate-modifier. If I am reading the documentation correctly, this should do what you want:

(setq ns-right-alternate-modifier nil)

I am unsure whether this is supported on stock GNU Emacs.



回答2:

To map the the left alt key with META and the right alt key with ALT, on the Mac OS X version of GNU Emacs, I use:

(setq mac-option-key-is-meta t)
(setq mac-right-option-modifier nil)

It should do the job for the behaviour you expect.



回答3:

I found a solution for my macbook pro with french keyboard.

Considering that I hardly ever use the Fn key here what i did:

; ALT is considered as ALT and not interpreted as META
(setq-default mac-option-modifier nil)

; Fn is considered as META and not interpreted as Fn
(setq-default mac-function-modifier 'meta)

So I can fool around with as many backslash as I want in emacs!

\\[GREAT!!!]\\



回答4:

This is not exactly what you want, but this is what I do and may help someone (for instance on the Macbook keyboard which has only one option key): You could bind just the keys you want:

(global-set-key "\M-_" (lambda () (interactive) (ucs-insert "2014")))

for em dash, etc. Just bind whatever you use commonly. In the rare case you want to type something you haven't bound, you can (in Aquamacs, and it should be possible in other Emacsen as well) hit C-; which is bound to toggle-mac-option-modifier, so that Option key is no longer Meta, type the character, and hit C-; again.