[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: elisp macros problem
From: |
David Kastrup |
Subject: |
Re: elisp macros problem |
Date: |
24 Jul 2004 21:00:01 +0200 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 |
Lowell Kirsh <lkirsh@cs.ubc.ca> writes:
> I am defining an emacs lisp macro to do:
>
> (my-add-hook 'lisp
> ...)
>
> which should give:
>
> (add-hook 'lisp-mode-hook
> (lambda () ...))
>
> I have:
>
> (defmacro my-add-hook (hook &rest body)
> (let ((tempvar (make-symbol "cat")))
> `(flet ((,tempvar (sym str)
> (make-symbol (concat (symbol-name sym) str))))
> (add-hook (cat ,hook "-mode-hook") (lambda () ,@body)))))
>
> Does anyone know what's wrong with this and why it doesn't work?
I don't know where to start...
First of all, your use of flet is complete nonsense. You flet an
uninterned symbol with the name "cat" to some function. However, you
never use that function. Instead you are trying to call the interned
symbol "cat" (which is probably undefined). Even if one fixed that,
it is completely unnecessary. Just do
(defmacro my-add-hook (hook &rest body)
`(add-hook ',(intern (concat (symbol-name hook) "-mode-hook"))
(lambda () ,@body)))
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
Re: elisp macros problem, Barry Margolin, 2004/07/24
Re: elisp macros problem, Lowell Kirsh, 2004/07/25