Is prepending "ryo:" to name needed?
Closed this issue · 3 comments
I've been messing around with the ryo-emacs config from sriramkswamy (https://github.com/sriramkswamy/ryo-emacs) which is already a very nice demonstration what can be achieved using ryo-modal.
The thing that is very noticeable in his config is that he refers to every single keybindings twice, which is hard to keep in sync so a likely source of trouble. Moreover it leads to an unnecessarily long config file with a lot of duplication (in his config that is work in progress the files for keybindings and specifying the names for which-key are each ~2000 lines)
In my opinion it would be much cleaner to have all the info at the same place as can be done using the :name functionality that is already present in ryo-modal by defining the keybindings using something along the lines of:
(ryo-modal-keys
("c"
(("a w" sk/mark-around-word :then (kill-region) :exit t
:name "Mark around word"))))
This works as expected, but when doing this it appears as ryo:mark around word in the which-key popup, which looks bad but also makes it harder to process the info that is being displayed and might explain why he took that approach.
Is the pre-pending "ryo:" to the name that you do really needed? If not, could that prefix get removed or else be made optional to make these keybindings easier to manage?
btw) setting the string that is now "ryo:" to a blank seems to work fine for me.
Hi!
I didn't think it would work to include whitespace in the :name
section, but it does? The reason for the ryo:
prefix is to avoid namespace clashes with other commands. I'm using which-key
too, and I've added this line to my init: (push '((nil . "ryo:") . (nil . "")) which-key-replacement-alist)
, and that removes all ryo:
prefixes. I should probably add that to the README file, since which-key
is a popular package!
If the code line above doesn't work it may be because you need to update which-key
(they changed it quite recently), or I may have written it wrong. I actually use it like this in my config:
(mapc
(lambda (x)
(push `((nil . ,(car x)) . (nil . ,(cdr x))) which-key-replacement-alist))
'(("kill" . "☠")
("projectile" . "✎")
("helm" . "⎈")
("other-window" . "↗▯")
("ryo:" . "")
("other-frame" . "↗⌧")))
- Thanks for that response as that is a trick I wouldn't have figured out, i.e. adding
(push '((nil . "ryo:") . (nil . "")) which-key-replacement-alist)
to my config indeed makes strings in which-key appear as intended without the need for the duplication. Definitely worth adding something like this to the readme as that isn't that obvious.
- Adding whitespaces in the string behind name works fine as long as the string is enclosed in quotes as I did in the code in the start post. The only downside appears to be that it looks a bit weird when looking up help for a key as it looks like this:
(ryo:Mark\ around\ word BEG END &optional REGION)
but that is just a cosmetic issue. Nothing more.
I've added the which-key
info to the README. I'm closing this issue, since I do not think its wise to remove the ryo:
prefix. I hope that is okay :)