Is there a way to map the tab key to meta in emacs?
-
14-04-2021 - |
题
I'm looking to rebind Meta
to the tab key in my emacs environment. I've looked around but been unable to find anything other than binding it to command
or option
, which are slightly better but still not ideal.
解决方案
You cannot do this in Emacs alone, you need to modify the keymap in your window system (*nux, Mac, MS Windows).
See the similar questions for the reasoning: Mapping Caps Lock to Control from within Emacs on Windows, elisp how to check if Shift key is pressed, and Can I send a keypress to Windows from Emacs?.
You can make the change in your window system - but it'd be helpful to know what that is...
其他提示
If you use OS X, you can install KeyRemap4MacBook and use a private.xml like this:
<?xml version="1.0"?>
<root>
<appdef>
<appname>EMACS</appname>
<equal>org.gnu.Emacs</equal>
</appdef>
<item>
<name>tabtometa</name>
<identifier>tabtometa</identifier>
<only>EMACS</only>
<autogen>__KeyOverlaidModifier__ KeyCode::TAB, KeyCode::OPTION_L, KeyCode::TAB</autogen>
</item>
</root>
It changes tab to option when held but keeps it as tab when pressed.
If you want to use option to insert non-ASCII characters, change OPTION_L
to CONTROL_R
and use:
(setq ns-option-modifier 'nil)
(setq ns-right-control-modifier 'meta)