all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Bill Wohler <wohler@newt.com>
Cc: "Davide G. M. Salvetti" <salve@debian.org>,
	Romain Francoise <rfrancoise@debian.org>,
	emacs-devel@gnu.org
Subject: Re: add-hook versus custom-set-variables
Date: Thu, 29 Dec 2005 02:05:35 -0800	[thread overview]
Message-ID: <21285.1135850735@olgas.newt.com> (raw)
In-Reply-To: Stefan Monnier's message of Thu, 29 Dec 2005 11:14:49 EST. <87k6dn6fz6.fsf-monnier+emacs@gnu.org>

Stefan Monnier <monnier@iro.umontreal.ca> wrote:

> >>> 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 the function cannot delay the evaluation of its arguments.

Thanks for the explanation. There's a lot of strange things in
elisp--mostly around compilation and evaluation--that I don't understand
and every little bit helps. Maybe another reading of these sections in
the elisp manual will make more sense now.

In any event, I think I get it now. To keep eval-after-load from being
completely useless, the idiom is to quote the form. Right?

This works:

 (eval-after-load "mh-e"
   '(progn
     (add-hook 'mh-folder-mode-hook 'mc-install-read-mode)
     (add-hook 'mh-letter-mode-hook 'mc-install-write-mode)))

BUT!

While coming up with a recipe to prove that the semantics had changed
between Emacs 21 and 22, I discovered I was inadvertently performing my
"site-init" *after* I ran custom-set-variables. (Recall that I'm
simulating the Debian site-init from my .emacs while using CVS Emacs.)
Normally, site-init is performed *before* one's .emacs is loaded. After
moving the site-init to the top of my .emacs file, I regained Emacs 21
semantics and all is well.

Sorry about the false alarm; at least I learned a few things.

-- 
Bill Wohler <wohler@newt.com>  http://www.newt.com/wohler/  GnuPG ID:610BD9AD
Maintainer of comp.mail.mh FAQ and MH-E. Vote Libertarian!
If you're passed on the right, you're in the wrong lane.

  reply	other threads:[~2005-12-29 10:05 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-28 23:05 add-hook versus custom-set-variables Bill Wohler
2005-12-29  3:24 ` Stefan Monnier
2005-12-29  7:44   ` Bill Wohler
2005-12-29 16:14     ` Stefan Monnier
2005-12-29 10:05       ` Bill Wohler [this message]
2005-12-29 19:12         ` Stefan Monnier
2005-12-30  5:37           ` Tomas Zerolo
2005-12-30 20:52   ` Bill Wohler
2005-12-30 22:25     ` Stefan Monnier
2005-12-31 19:36       ` Richard M. Stallman
2005-12-31 19:47         ` David Kastrup
2005-12-31 21:00           ` Chong Yidong
2005-12-31 21:26             ` David Kastrup

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=21285.1135850735@olgas.newt.com \
    --to=wohler@newt.com \
    --cc=emacs-devel@gnu.org \
    --cc=rfrancoise@debian.org \
    --cc=salve@debian.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.