[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[h-e-w] Re: (interactive) in a macro

From: Hannu Koivisto
Subject: [h-e-w] Re: (interactive) in a macro
Date: Fri, 20 Mar 2009 17:19:44 +0200
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/22.2 (gnu/linux)

Kelly McDonald <address@hidden> writes:

> (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?")
> if I macroexpand the macro, paste the results and evaluate that in the
> buffer, I get exactly the function I want (for my contrived example),
> but if I just evaluate the macro above, the function doesn't appear to
> be interactive.

You say that as if the function is available but not interactive,
but that is not the case.  If you had tried to say C-h f
text-swallow RET, you would have noticed that not only is there no
interactive text-swallow function, there is no kind of text-swallow
function.  And that is because you used make-symbol instead of
intern.  You might want to read the "8.3 Creating and Interning
Symbols" section in the Emacs Lisp reference manual for further

Also, insert-string is obsolete since 22.1.  Personally, I'd also
consider passing the entire function name as a symbol instead of
(over?)optimizing the interface that way, at least if the intention
is that you call those functions directly by their name (instead of
some other mechanism where you only need that "swallow" part, in
which case your approach would be better.)  And I'd use hyphens in
variable names.  And I would have posted this in a non-Windows
specific group/list :)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]