Can you create interactive functions in an Emacs Lisp macro?
elisp, macros
Solution
This does what you want:
(defmacro deftext (functionname texttoinsert)
(let ((funsymbol (intern (concat "text-" functionname))))
`(defun ,funsymbol () (interactive) (insert-string ,texttoinsert))))
Problem
I'm trying to write a macro in emacs lisp to create some ‘helper functions.’ Ultimately, my helper functions will be more useful than what I have here. I realize that there may be better/more intuitive ways to accomplish the same thing (please post) but my basic question is why won't this work/what am I doing wrong: ``` (defmacro deftext (functionname texttoinsert) `(defun ,(make-symbol (concatenate 'string "text-" functionname)) () (interactive) (insert-string ,texttoinsert))) (deftext "swallow" "What is the flight speed velocity of a laden swallow?") (deftext "ni" "What is the flight speed velocity of a laden swallow?") ``` If I take the output of the macroexpand and evaluate that, I get the interactive functions I was intending to get with the macro, but even though the macro runs and appears to evaluate, I can't call `M-x text-ni` or `text-swallow`.