emacs-devel
[Top][All Lists]
Advanced

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

Re: add-hook versus custom-set-variables


From: Stefan Monnier
Subject: Re: add-hook versus custom-set-variables
Date: Thu, 29 Dec 2005 11:14:49 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

>>> Two workarounds which aren't pretty are to insist that the user add a
>>> defvar in .emacs for any hook he customizes
>> 
>> I don't understand what you're suggesting here.
>> How could a defvar in .emacs help?

> Please read Luc's article where he describes the technique and why.

>   http://article.gmane.org/gmane.emacs.pretest.bugs/9993

Oh, I see.  It's not specific to defvar: setq works just as well.

>>> ;; MH-E hooks
>>> (eval-after-load 'mh-customize
>>> (progn
>>> (message "Adding mailcrypt hooks to MH-E...")
>>> (add-hook 'mh-folder-mode-hook 'mc-install-read-mode)
>>> (add-hook 'mh-letter-mode-hook 'mc-install-write-mode)))
>> 
>> eval-after-load is a function, not a macro.  I know it's counter
>> intuitive.

> I don't know enough about the internals to know why this would be
> counter-intuitive. I read your answer as: macros do what you expect,
> functions don't. Please elaborate if this is not what you mean. Why
> doesn't eval-after-load do what I expect?

The evaluation of a form (A B C) can follow the following two paths:

- if it's a macro:

   (eval (macrocall A B C))

- if it's a function

   (funcall A (eval B) (eval C))

Note how a function cannot delay the evaluation of its arguments.


        Stefan




reply via email to

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