[Top][All Lists]

[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 <address@hidden> 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

reply via email to

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