Reputation: 1217
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
Upvotes: 2
Views: 341
Reputation: 148
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"))
Upvotes: 2