I'm using the ryo-modal package that enables you to define your own keys in modal editing. I'm trying to makemf move the cursor to the end of the word, insert a whitespace and then exit the modal mode. This works fine without the :then '(insert " ") part. However, I would really like to see my original idea working. Thanks in advance.

(ryo-modal-key "f" 'forward-word :then '(insert " ") :exit t)

1 Answer 1


Try this:

(ryo-modal-key "f" 'forward-word :then (list (lambda () (interactive) (insert " "))) :exit t)

  • @stefan Actually you don't need to make it interactive, and having a quoted list works as well. That being said, your edited answer works too (but isn't as compact). I'm the author of ryo-modal and the non-interactive lambda feature was added because I thought the code looked cluttered when writing interactive everywhere :) Commented Sep 27, 2018 at 6:26
  • Then I suggest you change ryo-modal-key's docstring because it says "list of additional commands" and a non-interactive function is not a command (whereas a string is a command, as is a vector of commands). By the way I salso see you have (if (commandp f) (call-interactively f) ...) which should likely be replaced with (if (commandp f) (command-execute f) ...) since call-interactively doesn't know how to execute commands that are strings or vectors.
    – Stefan
    Commented Sep 27, 2018 at 12:39
  • Thanks for the suggestions @stefan. I'll look into command-execute (and how it is different to call-interactively) and I agree that the docstring should change. I actually didn't realize that (commandp "a") would be t, even though I knew strings could be used as commands. Commented Sep 27, 2018 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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