I am trying to generate functions using a macro:
(defmacro make-my-emacs-command-region (cmd name)
(list 'defun (intern (format "my-emacs-command-%s-%s" cmd name))
'(&optional arg)
(list 'interactive "p")
(list (intern (format "mark-%s" name)) 'arg)
(list (intern (format "my-emacs-command-%s-region" cmd))
'(region-beginning) '(region-end))))
generator:
(mapcar (lambda (a) (make-my-emacs-command-region a buffer))
'(foo bar))
But I get:
my-emacs-command-a-buffer
What am I doing wrong? How can I force to pass value of a
?
A major point of lisp macros is that the arguments are not evaluated. Read up on the macro pages in the manual, specifically the expansion of macros. The macroexpand
function would be of use in debugging the problem. Also, backquote might help you write the body of the macro a little more succinctly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With