[Top][All Lists]

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

Re: elisp macros problem

From: Lowell Kirsh
Subject: Re: elisp macros problem
Date: Mon, 26 Jul 2004 23:54:41 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.1) Gecko/20040707

This still doesn't seem to work. With the following defun and call:

(defmacro my-add-hooks (hooks &rest body)
  `(dolist (hook ',hooks)
     (my-add-hook hook ,@body)))

(my-add-hooks (inferior-lisp lisp emacs-lisp lisp-interaction)
              (imenu-add-to-menubar "Symbols"))

I get the following macroexpansion, which looks correct to me, but doesn't actually do anything:

 (catch (quote --cl-block-nil--)
(let ((--dolist-temp--20870 (quote (inferior-lisp lisp emacs-lisp lisp-interaction)))
     (while --dolist-temp--20870
       (setq hook (car --dolist-temp--20870))
       (my-add-hook hook
                    (imenu-add-to-menubar "Symbols"))
       (setq --dolist-temp--20870 (cdr --dolist-temp--20870)))


David Kastrup wrote:

Lowell Kirsh <address@hidden> writes:

Why does this not work:

(defmacro my-add-hooks (hooks &rest body)
  `(dolist (hook ,hooks)
      (my-add-hook hook ,@body)))


Because you need to write
`(dolist (hook ',hooks)

and then call this with an _unquoted_ list, like
(my-add-hooks (lisp emacs-lisp)

Apart from that, I consider this sort of thing a crock.  What are you
hoping to achieve that you would not be better off doing by a proper
function instead of a macro?

reply via email to

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