ido-mode binding masked by global-set-key

帅比萌擦擦* 提交于 2019-12-10 15:07:02

问题


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.

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-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)

And it works fine until I place the following line in my .emacs file:

(global-set-key (kbd "M-<return>") 'insert-newline-and-indent)

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.


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.

I solved the problem by moving the global-set-key call above the ergoemacs initialization. Not the best solution, but a simple one.


回答1:


The problem was caused by ergoemacs-keybindings package, or, to be more specific, by ergoemacs-mode.el

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.

I see three solutions to that problem:

  1. Comment-out advice in ergoemacs-mode.el.
  2. Use global-set-key BEFORE you turn on ergoemacs-mode.
  3. Wait for the ergoemacs author to fix the bug ;)


来源:https://stackoverflow.com/questions/9877557/ido-mode-binding-masked-by-global-set-key

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!