I use evil and I want to execute a function by using Emacs macro system.

Let's say I have the following macro.

(evil-set-register ?f [?i ?f ?o ?o ?b ?a ?r escape])

I can run the macro by using @f. But this system is not easy to read and maintain.


How to execute an interactive function by using @f shortcut?


Here's function insert-foobar which inserts string foobar:

(defun insert-foobar nil
  "Insert foobar."
  (call-interactively 'evil-append)
  (insert "foobar")
(evil-set-register ?f (call-interactively 'insert-foobar)) ;; This does not work
(evil-set-register ?f (insert-foobar)) ;; This does not work too
(evil-set-register ?f (lambda nil "documentation"
                        (call-interactively 'insert-foobar)))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.