Kungsgeten/ryo-modal

Binding functions with arguments

Closed this issue · 2 comments

One more thing cropped up when I was moving my modalka config: I'd like to have SPC quit ryo-mode and insert a space. I've tried these 2 options; neither works:

("SPC" ryo-modal-mode :then '(insert " "))
("SPC" '(insert " ") :exit t))

It seems more generally that I can't pass a function with argument correctly - most likely because I don't understand enough elisp...
Do you know how to achieve this?

Thank you!

Hi! Its true that you can not pass functions with arguments, they need to be commands (functions which you could normally run with M-x). You'll normally have to write your own function in order to do what you want. Like this:

(defun insert-space ()
  (interactive)
  (insert " "))
(ryo-modal-key "SPC" 'insert-space :exit t)

In this case, however, you could use the fact that targets in ryo can be a key: that keypress will be simulated when using the ryo command. You could therefore do this (in most modes, depends on what space normally do): (ryo-modal-key "SPC" "SPC" :exit t)

Great! This works great, thank you!