问题描述
计算器!在过去的几天里,我正在尝试自定义我的emacs一点点,我面临的问题,我不知道如何处理。
stackoverflow! In the past few days I was trying to customize my emacs a little bit and I faced the problem that I don't know how to approach.
我正在尝试要做的是定义一个全局键盘绑定和一个ido模式键盘绑定,将使用相同的键来执行不同的操作。
What I'm trying to do is to define a global keybinding and an ido-mode keybinding that would use the same keys to do different things.
Ido模式键盘绑定是这样定义的: / p>
Ido-mode keybinding is defined this way:
(defun ido-my-keys ()
"Add my keybindings for ido."
(define-key ido-completion-map (kbd "M-<return>")
'ido-invoke-in-vertical-split)
)
(add-hook 'ido-setup-hook 'ido-my-keys)
它工作正常,直到我放置我的.emacs文件中的以下行:
And it works fine until I place the following line in my .emacs file:
(global-set-key (kbd "M-<return>") 'insert-newline-and-indent)
使用此行显示M-return调用insert-newline-和 - 甚至从ido-switch-buffer。有趣的是,当我以交互方式使用全局设置键(即不是从init-file而是从M-x调用)时,一切都按预期运行。
With this line present M-return invokes insert-newline-and-indent even from ido-switch-buffer. Interestingly, when I use global-set-key interactively (i.e. not from init-file but from M-x invocation), everything works as expected.
感谢您的帮助。对不起我的英语。
Thanks for your help. Sorry for my english.
问题原来是在我已经打开的ergoemacs模式。这个模式定义了一个导致这个效果的全局设置键的建议。
The problem turned out to be in ergoemacs-mode that I had turned on. This mode defines an advice for global-set-key that causes this effect.
我通过在全局设置键调用上面的ergoemacs初始化来移动,解决了这个问题。
I solved the problem by moving the global-set-key call above the ergoemacs initialization. Not the best solution, but a simple one.
推荐答案
问题是由ergoemacs-keybindings包引起的,或者是更多具体由ergoemacs-mode.el
The problem was caused by ergoemacs-keybindings package, or, to be more specific, by ergoemacs-mode.el
这个包定义了一个全局设置密钥的建议,事实上,它用自己的ergoemacs-global-set-键。但是由于ergoemacs是一种次要模式,它的键盘映射比全局映射具有更高的优先级,因此覆盖了ido小模式的绑定。
This package defines an advice for global-set-key that, in fact, replaces it with its own ergoemacs-global-set-key. But since ergoemacs is a minor mode, its keymap has higher precedence than the global map, thus overriding keybinding of ido minor mode.
我看到三个解决方案: / p>
I see three solutions to that problem:
- ergoemacs-mode.el中的注释建议。
- 使用全局设置键您打开ergoemacs模式。
- 等待ergoemacs作者修复错误;)
这篇关于ido-mode绑定被全局设置密钥掩码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!