在mac上使用XQuartz打开远程服务器上安装的emacs时,将Meta更改为option key



我的问题是这样的:首先,我使用终端通过ssh -Y登录到远程服务器。然后通过输入

打开安装在远程服务器上的emacs。
emacs

由于我在使用ssh时添加了-Y选项,所以在Mac上安装的XQuartz中打开了emacs。

在这个时候,问题来了:选项键不被视为Meta,只有ESC键被视为Meta。但是我想使用选项键作为Meta.

我怎么解决它?

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

特别是这部分

你可以在X11窗口(Applications/Utilities/X11.app)中使用option/alt键作为元键来运行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

用命令

使用上面的文件
xmodmap ~/.xmodmap

在启动emacs之前(例如,如果你使用登录shell选项到xterm,从/etc/bashrc,即xterm -ls在X11/Application/Customize for terminal)

最新更新