unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* add-hook versus custom-set-variables
@ 2005-12-28 23:05 Bill Wohler
  2005-12-29  3:24 ` Stefan Monnier
  0 siblings, 1 reply; 13+ messages in thread
From: Bill Wohler @ 2005-12-28 23:05 UTC (permalink / raw)


I set mh-folder-mode-hook to bw-mh-folder-mode-hook in my
custom-set-variables stanza.

When I start Emacs, I see that mh-folder-mode-hook is set to
mc-install-read-mode instead. I'd expect to see both
mc-install-read-mode and bw-mh-folder-mode-hook. This reminded me a lot
of the problems we had with the defvar of the hook in
define-derived-mode.

It appears that an add-hook call during the mailcrypt initialization is
binding mh-folder-mode-hook so that the custom-set-variables is losing.
I think Luc's explanation in
http://article.gmane.org/gmane.emacs.pretest.bugs/9993 is germane.

Since users will use the Customization interface to set hooks (at least
166 of them in my instance), I think it is important to figure out a
general resolution to this problem.

Two workarounds which aren't pretty are to insist that the user add a
defvar in .emacs for any hook he customizes or for system libraries to
delay the evaluation of add-hook until after the related
custom-set-variables and defcustom have been evaluated.

When I modified mailcrypt-init.el as follows:

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

I found that the eval-after-load form was evaluated during
initialization rather than after I loaded MH-E. From *Messages*:

    Loading 50mailcrypt (source)...
    Adding mailcrypt hooks to MH-E...

Any thoughts as to why this happened? No, mh-customize had not been
loaded yet.

For the Debian folks, I have the following code in my .emacs so that I
can use Debian Emacs Lisp packages while running CVS Emacs:

    (when (eq emacs-major-version 22)
      (add-to-list 'load-path "/usr/share/emacs/site-lisp")
      (load-library "debian-startup")
      (setq debian-emacs-flavor 'emacs-snapshot)
      (debian-startup 'emacs-snapshot))

-- 
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.

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2005-12-31 21:26 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).