I am trying to bind keys to a lambda function using bind-key.el. I have the following factor macro
;; taken from Emacs Doom (defmacro cmd! (&rest body) (declare (doc-string 1) (pure t) (side-effect-free t)) `(lambda (&rest _) (interactive) ,@body)) which creates a lambda interactive function. So at first, I tried using that to bind-keys with no success.
(use-package org :bind (:map org-mode-map ("C-c C-f" . (cmd! (message "Test"))))) But then I get the error. use-package: org-super-agenda wants arguments acceptable to the 'bind-keys' macro.... I also tried
(bind-keys :map org-mode-map ("C-c C-f" . (cmd! (message "Test")))) but then I get the error command-execute: Wrong type argument: commandp, (cmd! (message "Test")) when I press C-c C-f.
I then tried replacing (cmd! ... with (lambda () (interactive) ...)
(bind-keys :map org-mode-map ("C-c C-f" . (lambda () (interactive) (message "Test")))) but then I get stuck in an infinite loop when executing the previous statement. When stopping with C-g, I find that I am stuck in a function called prin1-to-string with a seemingly infinite
(closure ((binding closure ((binding closure ((binding closure ... nil ... ...) as an argument. I think the reason is that in my particular file with lexical binding, closing the lambda expression is expensive.
How am I supposed to do this efficiently?