1

In Emacs evil-mode, I'm trying to bind the string "ei" to an ex command that opens up my init file. This is what I came up with:

(defun edit-init () (find-file "~/.emacs"))
(evil-ex-define-cmd "ei" 'edit-init)

When I try to run the ex command (using ":ei"), Emacs tells me "Unknown command "ei").

I checked the evil-ex-commands variable and the new command is correctly being stored in the list. It looks like this:

("ei" . edit-init)

My first thought was that the default ex command of "e" for edit was interfering with the command somehow, however I tried binding "ew" to other-window and it worked fine.

Am I missing something about how evil-ex commands are created? Is there a limitation on what characters can be used?

Thanks

Drew
  • 29,895
  • 7
  • 74
  • 104
nslamberth
  • 1,147
  • 8
  • 10

1 Answers1

1

You need to define a command, not just a function. In other words, your command is missing an (interactive) clause:

(defun edit-init ()
  (interactive)
  (find-file "~/.emacs"))
fifr
  • 138
  • 5