重新定义 Emacs 中的主要模式前缀键
我一直在尝试自学 emacs,因为我使用的是 dvorak,所以我愚蠢地将 Cc
反弹到移动键并习惯了它。现在我实际上开始用它进行一些编程,我加载了一个 python 文件并注意到 Cc
是 python-mode
中所有特殊命令的前缀。
我可以重新绑定前缀键并一次性更改 init.el
文件中的所有 python 命令吗?如果没有,我应该单独重新绑定所有 python 命令吗?
I've been trying teach myself emacs, and because I am using dvorak, I foolishly rebound C-c
to a movement key and got used to it. Now i'm actually starting to do some programming with it, and I loaded up a python file and noticed that C-c
is the prefix to all the special commands in python-mode
.
Can I rebind the prefix key and change all python commands in one swoop in my init.el
file? If not, should I rebind all the python commands individually?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您希望 Ctrl+C 充当
left
并 F12 充当Cc
:请注意,这也会影响多键绑定,例如您现在需要输入 Ctrl+X F12 退出 Emacs。硬币的另一面是
Cc Cc
被键入为 F12 F12。If you want Ctrl+C to act as
left
and F12 to act asC-c
:Note that this will also influence multi-key bindings, e.g. you now need to type Ctrl+X F12 to exit Emacs. The flip side of this coin is that
C-c C-c
is typed as F12 F12.如果您查看 python.el 的源代码,您会发现这些命令是使用完整规范单独添加的,例如
(define-key map "\Cc\Cr" 'python-send-region)< /代码>。
所以,你必须自己重做所有这些。这就是说它非常简单。根据您的评论,您希望将前缀键更改为 C-',而正确转义的技巧是根本不使用转义,而是使用宏
kbd< /code> (文档链接)。
这样,您可以将模式映射定义更新为:
If you look at the source code for python.el, you'll see that the commands were added individually using the full specification, e.g.
(define-key map "\C-c\C-r" 'python-send-region)
.So, you're going to have to redo them all yourself. That said it is pretty straight-forward. From your comment, you want to change the prefix key to be C-', and the trick to getting escaping right is to not use escapes at all, but instead to use the macro
kbd
(documentation link).With that, you can update the mode-map definition to be: