help-gnu-emacs
[Top][All Lists]
Advanced

[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:38:31 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.1) Gecko/20040707

A crock? Now that I've got that macrology out of the way, does not

(my-add-hooks (emacs-lisp lisp lisp-interaction)
  (fun foo))

look better than

(add-hook 'emacs-lisp-mode-hook
   (lambda () (fun foo)))

(add-hook 'lisp-mode-hook
   (lambda () (fun foo)))

(add-hook ....


I think it does :)

Lowell

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)
  body)

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]