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
?
My elisp is a bit rusty, but until someone comes up with the actual explanation: I could get your examples to work a bit more as expected my replacing cmd
with (eval cmd)
(possibly same with name
) in the macro definition body.
Hope this helps.