我的问题是这样的:首先,我通过Mac上的Terminal.app使用ssh -Y登录远程服务器。然后通过输入命令打开安装在该远程服务器上的emacs。
emacs
因为我在使用ssh时加入了-Y选项,所以emacs打开在安装在Mac上的XQuartz中。此时遇到了问题:选项键没有被视为Meta键,只有ESC键被视为Meta键。但是我想使用选项键作为Meta键。
如何解决这个问题?
请看http://www.emacswiki.org/emacs/MetaKeyProblems中的这部分内容。
你可以使用选项/alt键作为meta键来从X11窗口(Applications/Utilities/X11.app)运行emacs。此外,您可以使用xmodmap命令在X11下将command键重新映射为仅控制键。这样做的优点是允许command键在其他Mac应用程序中表现出所期望的行为。xmodmap还可以确保Alt/Option键在emacs中设置为Meta键。您可以通过以下~/.xmodmap文件实现这一点(以感叹号开头的行是注释,可以省略):
! undo any meta keys already set
clear Mod1
! keycodes 63 and 71 are the left and right COMMAND buttons adjacent to the spacebar; set them to be control keys
keycode 63=Control_L
keycode 71=Control_R
! keycodes 66 and 69 are the option/alt keys; assign them as Meta keys
keycode 66=Meta_L
keycode 69=Meta_R
! now tell X11 that the Meta keys act as the Mod1 (meta) modier key; that is, when they are pressed with KEY, it is the same as hitting M-KEY
add Mod1 = Meta_L Meta_R
! tell X11 that the Control keys are Control modifiers, so when pressed with u (for example) it is the same as hitting C-u
add Control = Control_L Control_R
使用上述文件,使用以下命令:
xmodmap ~/.xmodmap
如果您使用登录 shell 选项在 X11/Application/Customize 终端中,例如从 /etc/bashrc 中启动 emacs(例如 xterm -ls),请注意这一点。
xmodmap ~/.xmodmap
时,它会打印以下错误:X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 118 (X_SetModifierMapping) Value in failed request: 0x17 Serial number of failed request: 16 Current serial number in output stream: 16
无论如何,它确实有效。非常感谢,Doon! - Negelis