* Can you create interactive funtions in a a macro
@ 2009-03-18 22:35 Kelly
2009-03-19 1:18 ` Katsumi Yamaoka
0 siblings, 1 reply; 3+ messages in thread
From: Kelly @ 2009-03-18 22:35 UTC (permalink / raw)
To: help-gnu-emacs
Hi, I am missing something here.
I am trying to write a macro to create interactive functions to
automate some stuff.
What I present below is a simlified case:
(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" "We are the knights who say NI!")
the code is supposed to create two interactive functions (text-
swallow) and (text-ni)
that insert the string.
If I macroexpand the forms above and evaluate that, I get what I was
after.
Is there something I'm missing, or can you just not do this.
(it's fine to tell me that I would be better served doing it some
other way, but I'm just trying to understand why this doesn't work)
TIA,
Kelly
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Can you create interactive funtions in a a macro
2009-03-18 22:35 Can you create interactive funtions in a a macro Kelly
@ 2009-03-19 1:18 ` Katsumi Yamaoka
2009-03-19 20:18 ` Kelly
0 siblings, 1 reply; 3+ messages in thread
From: Katsumi Yamaoka @ 2009-03-19 1:18 UTC (permalink / raw)
To: help-gnu-emacs
>>>>> Kelly wrote:
> Hi, I am missing something here.
> I am trying to write a macro to create interactive functions to
> automate some stuff.
> What I present below is a simlified case:
> (defmacro deftext (functionname texttoinsert)
> `(defun ,(make-symbol (concatenate 'string "text-" functionname)) ()
> (interactive)
> (insert-string ,texttoinsert)))
A function symbol has to be interned in `obarray'. You seem to
have meant the Emacs Lisp function `concat' with `concatenate'.
`insert-string' is obsolete since Emacs 22.1. This will work:
(defmacro deftext (functionname texttoinsert)
`(defun ,(intern (concat "text-" functionname)) ()
(interactive)
(insert ,texttoinsert)))
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Can you create interactive funtions in a a macro
2009-03-19 1:18 ` Katsumi Yamaoka
@ 2009-03-19 20:18 ` Kelly
0 siblings, 0 replies; 3+ messages in thread
From: Kelly @ 2009-03-19 20:18 UTC (permalink / raw)
To: help-gnu-emacs
On Mar 18, 9:18 pm, Katsumi Yamaoka <yama...@jpl.org> wrote:
> >>>>> Kelly wrote:
> > Hi, I am missing something here.
> > I am trying to write a macro to create interactive functions to
> > automate some stuff.
> > What I present below is a simlified case:
> > (defmacro deftext (functionname texttoinsert)
> > `(defun ,(make-symbol (concatenate 'string "text-" functionname)) ()
> > (interactive)
> > (insert-string ,texttoinsert)))
>
> A function symbol has to be interned in `obarray'. You seem to
> have meant the Emacs Lisp function `concat' with `concatenate'.
> `insert-string' is obsolete since Emacs 22.1. This will work:
>
> (defmacro deftext (functionname texttoinsert)
> `(defun ,(intern (concat "text-" functionname)) ()
> (interactive)
> (insert ,texttoinsert)))
Yes, it was the intern that I was lacking.
conatenate is actually included with cl-extra, so it was working, I
have done more CL than emacs lisp.
Wasn't aware that insert-string was obsolete (it still worked) -
Thanks for the reply, I've got what I wanted working!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-03-19 20:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-18 22:35 Can you create interactive funtions in a a macro Kelly
2009-03-19 1:18 ` Katsumi Yamaoka
2009-03-19 20:18 ` Kelly
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.