I want to send keybindings to meow-leader-define-key
but it only takes them in dotted pair notation, which is a string followed by a function, but I can't figure out how to convert a string and a function into dotted pair notation in the function.
I would like something like this:
(cons "hi" (lambda ()
(message "ok..." )))
To result in this:
("hi" . (lambda ()
(message "ok..." )))
I would like to return the code below like this with a dot:
'("z z" .
(lambda nil
(interactive)
(message "zz")))
Here is the full code, the problem I am trying to solve is in pop newlist
.
(setq my/modal 'meow)
(defmacro my/def-key (state map &rest rest)
(let* ((newlist
(pcase my/modal
('evil rest)
('meow (mapcar (lambda (x)
(let ((KBD (car (cdr x))))
(if (and (stringp KBD)
(string-match-p "^<leader" KBD))
(setcar (cdr x)
(replace-regexp-in-string "<leader>" "" KBD))
x))) rest))))
(mlist (remq nil
(mapcar (lambda
(x) (when (and (cdr newlist)
(car newlist))
`'(,(pop newlist)
,(pop newlist)))) newlist)))
;; works
;;`(,@(cons 1 2 )) )) newlist)))
)
(pcase my/modal
('evil
`(evil-define-key ,state ,map ,@newlist ))
('meow
`(meow-leader-define-key ,@mlist ))
(_
(display-warning :wrong-variable
"Wrong variable set for my/modal")))))
(macroexpand-1 '(my/def-key 'normal global-map
(kbd "<leader>z z")
(lambda ()
(interactive)
(message "zz"))
(kbd "<leader>z f")
(lambda ()
(interactive)
(message "zf"))))
dolist
might work better. However, I'm still puzzled as to how to do that. Thanks.(foo . (bar))
and(foo bar)
? If not... what is the actual problem?