3

I just started experimenting with emacs. And as a Vim user I did not want to bother use it without installing evil-mode first.

However, evil-mode seems to break the emacs keybinding for 'execute-extended-command' (M-x).

I really don't care about this keybinding, and I noticed that I can call for example 'list-packages' from the evil command-mode and it works just fine. Only thing I am missing now, is the TAB auto completion in command mode, like typing 'list-' TAB and then it will show or iterate available commands. Is this possible with evil-mode?

or is there eventually an easy way to fix this keybinding?

I am using:

  • debian jessie
  • GNU Emacs 24.4.1

EDIT:

My .emacs file:

(require 'package)
(push '("marmalade" . "http://marmalade-repo.org/packages/")
    package-archives )
(push '("melpa" . "http://melpa.milkbox.net/packages/")
    package-archives)

(add-to-list 'load-path "~/.emacs.d/evil")
(require 'evil)
(evil-mode 1)

(define-key evil-normal-state-map [escape] 'keyboard-quit)
(define-key evil-visual-state-map [escape] 'keyboard-quit)
(define-key minibuffer-local-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-ns-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-completion-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-must-match-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-isearch-map [escape] 'minibuffer-keyboard-quit)

I attempted to add Modifier-x

(global-set-key (kbd "C-x") 'execute-extended-command)

and Alt-x

(global-set-key (kbd "A-x") 'execute-extended-command)

but these attempts didn't fix the keybinding, so I've decided to roll with super key

(global-set-key (kbd "s-x") 'execute-extended-command)
Michelrandahl
  • 3,365
  • 2
  • 26
  • 41

1 Answers1

1

Fixing keyboard bindings is quite easy - just add this line to your .emacs file (or evaluate it in the scratch buffer):

(global-set-key (kbd "< put your key combination here >") 'execute-extended-command)

You can use reference from ErgoEmacs to understand how to provide key combinations for kbd function.

And IMO it's better to use standard Emacs means to run commands - use your evil-mode command mode for evil-related things, and use M-x/execute-extended-command to work with Emacs.

NikitaBaksalyar
  • 2,414
  • 1
  • 24
  • 27
  • Thank you very much. I think your point about using standard Emacs bindings is relevant... However, there must be a bug in evil-mode because your suggestion only worked for super-x, (global-set-key (kbd "s-x") 'execute-extended-command) – Michelrandahl Feb 24 '15 at 19:25
  • @Mitzh, you can check what command is bound to `M-x` by pressing `C-h k M-x` (i.e. Ctrl+H, then `k`, then Alt+X) - perhaps, it's interfering with evil or other plugins you might have installed. – NikitaBaksalyar Feb 24 '15 at 19:30
  • Thanks again. Now I definitely believe that evil-mode is causing the key-binding to be bugged... Because it happily reports that "M-x runs the command execute-extended-command..". And that it is bound to "s-x, , , M-x" – Michelrandahl Feb 24 '15 at 19:39
  • 2
    still says M-x is undefined for me – Jeff Linahan Sep 01 '15 at 12:35