Usage with (cdr (assoc "wq" evil-ex-commands))
shadowrylander opened this issue · 14 comments
Hello!
I would like some help in configuring your package, via use-package
, to run a command from the evil-ex-commands
alist, using ("ll" (cdr (assoc "wq" evil-ex-commands)))
; however, I'm getting the Error (use-package): ryo-modal/:config: Wrong type argument: listp, cdr
error. Here is the whole ryo-modal + use-package
code I'm using:
(use-package ryo-modal
:demand t
:general
(:keymaps 'override
(general-chord "kk") 'start-ryo)
:config
(ryo-modal-keys
;; First argument to ryo-modal-keys may be a list of keywords.
;; These keywords will be applied to all keybindings.
(:norepeat t)
;; Adapted From The Comments:
;; Answer: https://emacs.stackexchange.com/a/21364
;; User: https://emacs.stackexchange.com/users/8578/pyrocrasty
;; ("pp" save-buffers-kill-emacs)
;; ("pp" (cdr (assoc "q" evil-ex-commands)))
;; ("oo" save-buffer)
;; ("oo" (cdr (assoc "w" evil-ex-commands)))
("ll" (cdr (assoc "wq" evil-ex-commands)))
;; ("qq" kill-emacs)
;; ("qq" (cdr (assoc "q!" evil-ex-commands)))
("kk" start-ryo)
)
:straight
(:host github :repo "kungsgeten/ryo-modal" :branch "master"))
Any help would be greatly appreciated!
I think the cdr
part might be quoted inside the macro, and therefore is evaluated as a list instead of the result of the function call. Try using ryo-modal-key
instead and see if that works.
I attempted the following, but it gave me the same error:
(ryo-modal-key "ll" '(cdr (assoc "wq" evil-ex-commands)))
I also tried an interactive lambda, but that gave me the same error with lambda
instead of cdr
.
Should I perhaps put them in a let statement and then assign them to the keys?
Fascinating; so it worked after I did the following:
- Wrap
ryo-modal-key[s]
in a let statement, and moving thecdr
statement to a let variable, then - Move it to the config section of
evil-mode
I think this should allow me to use ryo-modal's use-package
keyword, correct?
I'm not sure, I haven't used the use-package
keyword myself. However I think that you shouldn't quote the cdr
statement, since I guess you're trying to get an element from the evil-ex-commands
alist. Does the following work?
(ryo-modal-key "ll" (cdr (assoc "wq" evil-ex-commands)))
Ah; yes, yes it does. However, I'm still getting a Error (use-package): ryo-modal/:config: Symbol’s value as variable is void: evil-ex-commands
error when putting it in the ryo-modal
config section; putting it in the evil-mode
section works. I do want to implement it using the :ryo
keyword, though, and none of the following work; the first gives no error, but just flat out doesn't work, while the latter two are giving me the same errors as before:
:ryo
(let ((wq (cdr (assoc "wq" evil-ex-commands))))
("ll" wq))
:ryo ("ll" (cdr (assoc "wq" evil-ex-commands)))
:ryo ("ll" '(cdr (assoc "wq" evil-ex-commands)))
Oh, and neither does this work; same effect as the first example in the previous message:
:ryo
(let ((wq (cdr (assoc "wq" evil-ex-commands))))
("ll" 'wq))
The reason for the Error (use-package): ryo-modal/:config: Symbol’s value as variable is void: evil-ex-commands
is probably that ryo-modal
is loaded before evil-ex-commands
is known.
I surmised as much; however, I still cannot use your use-package
keyword.
This user on reddit mentions using the eval
method from your prefix keys section; could you possibly explain that to me? I don't quite understand it.
The aforementioned reddit user gave me this snippet that works:
(eval
`(ryo-modal-keys
("l l" ,(general-simulate-key ":wq <RET>") :first '(evil-normal-state) :name "wq")
("l p" ,(general-simulate-key ":q <RET>") :first '(evil-normal-state) :name "q")
("l o" ,(general-simulate-key ":w <RET>") :first '(evil-normal-state) :name "w")
("l q" ,(general-simulate-key ":q! <RET>") :first '(evil-normal-state) :name "q!"))
Could you show me how to convert this to a use-package
keyword format, i.e. using :ryo
?
I don't use the :ryo
keyword in use-package
myself, and if I remember correctly it was submitted as a pull request by another user. So I'm sorry, I can not.
Ah; that is understandable. I may have a solution for the keyword on hand, so I'll post that here in a little bit if it works!
Unfortunately, the keyword solution didn't work. But thank you kindly for all the help! I'll go ahead and close this, then!