在Mac上使用XQuartz打开远程服务器上安装的emacs时,将Meta更改为选项键

Neg*_*lis 9 linux x11 macos emacs

我的问题是这样的:首先,我使用Mac上的Terminal.app通过ssh -Y登录远程服务器.然后键入以打开该远程服务器上安装的emacs

emacs
Run Code Online (Sandbox Code Playgroud)

因为我在使用ssh时添加选项-Y,所以emacs在Mac上安装的XQuartz中打开.

此时,问题出现了:选项键不被视为Meta,只有ESC键被视为Meta.但我想使用选项键作为Meta.

我该如何解决?

Doo*_*oon 7

请查看http://www.emacswiki.org/emacs/MetaKeyProblems

特别是这一部分.

然后,您可以使用选项/ alt键作为元键从X11窗口(Applications/Utilities/X11.app)运行emacs.此外,您可以使用xmodmap命令将命令键重新映射到仅在X11下的Control.这样做的好处是允许命令键与其他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
Run Code Online (Sandbox Code Playgroud)

将以上文件与命令一起使用

xmodmap ~/.xmodmap
Run Code Online (Sandbox Code Playgroud)

在启动emacs之前(例如,如果您使用xterm的登录shell选项,则来自/ etc/bashrc,即X11中的xterm -ls /终端的Application/Customize).

  • 非常感谢!我就像你回答的那样做了,它确实有效!但是当我运行xmodmap~/.xmodmap时,它会输出以下错误:X请求失败错误:BadValue(操作范围超出整数参数)失败请求的主要操作码:118(X_SetModifierMapping)失败请求中的值:0x17序列号请求失败:16输出流中的当前序列号:16无论如何,它确实有效.非常感谢,Doon! (2认同)