質問

I am trying to bind execute-extended-command to M-x in evil normal mode. I currently have

;; evil mode
(require 'evil)
(evil-mode 1)

(define-key evil-normal-state-map "M-x" 'execute-extended-command)

in my .emacs file but the keybinding doesn't work. I tried replacing

"M-x"

with

"\M-x"

and

(kbd "M-x")

but neither works. I also tried adding it to evil.el and evil-maps.el.

役に立ちましたか?

解決 2

After long research and with help from #emacs and #evil-mode channels on irc, it turned out that my emacs was broken. It was a snapshot from http://emacs.naquadah.org/ I tried all this on another emacs version (from debian jessies repos) and it worked ok.

他のヒント

I don't know what's wrong with your binding. You could use Emacs' own global-set-key for global stuff and if you plan something special for say, insert mode, you could override that later on, like this:

 ;; this works, just tested. My evil is 1.0-dev from github.
 (global-set-key (kbd "M-x") 'smex)
 (define-key evil-insert-state-map (kbd "M-x") 'execute-extended-command)

Use (kdb "") macro when you have modifier keys in your binding. But you can use the macro always, regardless of the content. These are for example usage. When in doubt, wrap the key in (kdb ).

 (global-set-key (kbd "M-x") 'smex)
 (global-set-key (kbd "M-X") 'smex-major-mode-commands)
 ;;(global-set-key (kbd "M-x") 'execute-extended-command)

 (define-key evil-normal-state-map ",d" 'volatile-kill-buffer)
 (define-key evil-normal-state-map ",b" 'ido-switch-buffer)
 (define-key evil-normal-state-map ",s" 'ispell-word)

 (define-key evil-normal-state-map (kbd "C-x g") 'magit-status)
 (define-key evil-insert-state-map (kbd "C-f") 'my-expand-file-name-at-point)
 (define-key evil-insert-state-map (kbd "C-x C-l") 'my-expand-lines)

 (define-key minibuffer-local-map (kbd "C-w") 'backward-kill-word)
 (define-key evil-normal-state-map (kbd ",ff") 'ido-find-file)
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top