Kungsgeten / ryo-modal

Roll your own modal mode

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[bug] :hydra keyword not working for ryo-modal-keys

moesasji opened this issue · comments

According to the readme it should be possible to use the :hydra keyword in both ryo-modal-key as well as in ryo-modal-keys. However :hydra only works as expected for me when using it in ryo-modal-key, but not for ryo-modal-keys

Stripped down testcase that shows the problem on my system

 (use-package ryo-modal
  :ensure t
  :bind* ("<escape>" . my/enable-ryo-modal-mode)
  :config
  ;; hydra binding working
  (ryo-modal-key
   "SPC h" :hydra
   '(hydra-help ()
                "Testing"
                ("h" magit-status "magit" :color blue)))
 
;; hydra binding NOT working
 (ryo-modal-keys
   ("SPC"
     (("SPC" counsel-M-x)
     ("b" :hydra
     '(hydra-buffer (:color blue)
                    "Buffers"
                    ("n" next-buffer "next" :color red)
                    ("p" previous-buffer "prev" :color red)
                    ("s" save-buffer "save" :color red)))
    ("f" counsel-find-file "file"))))

For me the SPC h works, but SPC b triggers the message SPC b is undefined which looks like a bug to me. The SPC SPC and SPC f both work, so it appears restricted to the hydra binding.

btw) In case it matters: this is on Emacs version 25.2.1

Hi! It's a bit confusing, but when using ryo-modal-keys the second argument shouldn't be quoted. I remember having trouble with this myself (when to use quoted or not) and it is probably because of something in the ryo-modal-keys macro (which was the first elisp macro I ever wrote).

Anyway, I think it should work if you do it like this:

(ryo-modal-keys
 ("SPC"
  (("SPC" counsel-M-x)
   ("b" :hydra
    (hydra-buffer (:color blue)
                  "Buffers"
                  ("n" next-buffer "next" :color red)
                  ("p" previous-buffer "prev" :color red)
                  ("s" save-buffer "save" :color red)))
   ("f" counsel-find-file "file"))))

As you can see, the only difference is that the hydra-buffer list isn't quoted anymore.

Yes indeed....removing the quote indeed makes the hydra work for ryo-modal-keys as well. Sorry for the noise!

btw) One reason I didn't spot it as the quote was present in your config posted some time ago (https://gist.github.com/Kungsgeten/9be1b6e16475a2e0adf33ea6b229b15b). Which is why I wrongly assumed it should be there.

Perhaps there has been a change since I posted that, or perhaps I posted a defunct config by mistake :) Glad to hear it is working for you now.