From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Bill Wohler Newsgroups: gmane.emacs.devel Subject: Re: add-hook versus custom-set-variables Date: Thu, 29 Dec 2005 02:05:35 -0800 Organization: Newt Software Message-ID: <21285.1135850735@olgas.newt.com> References: <24044.1135811115@olgas.newt.com> <87irt87fkp.fsf-monnier+emacs@gnu.org> <871wzwcppm.fsf@olgas.newt.com> <87k6dn6fz6.fsf-monnier+emacs@gnu.org> NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1135879563 15231 80.91.229.2 (29 Dec 2005 18:06:03 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 29 Dec 2005 18:06:03 +0000 (UTC) Cc: "Davide G. M. Salvetti" , Romain Francoise , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Dec 29 19:05:59 2005 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Es29y-0007M2-W0 for ged-emacs-devel@m.gmane.org; Thu, 29 Dec 2005 19:05:55 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Es2BL-0006r1-C1 for ged-emacs-devel@m.gmane.org; Thu, 29 Dec 2005 13:07:19 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Es2BA-0006qt-9o for emacs-devel@gnu.org; Thu, 29 Dec 2005 13:07:08 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Es2B9-0006qg-OU for emacs-devel@gnu.org; Thu, 29 Dec 2005 13:07:08 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Es2B9-0006qd-KK for emacs-devel@gnu.org; Thu, 29 Dec 2005 13:07:07 -0500 Original-Received: from [69.93.192.76] (helo=tassie.newt.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Es2BX-0001P7-AI for emacs-devel@gnu.org; Thu, 29 Dec 2005 13:07:31 -0500 Original-Received: from olgas.newt.com (m190e36d0.tmodns.net [208.54.14.25]) by tassie.newt.com (Postfix) with ESMTP id 31A882D4013; Thu, 29 Dec 2005 10:05:39 -0800 (PST) Original-Received: by olgas.newt.com (Postfix, from userid 1000) id 072C816FD9; Thu, 29 Dec 2005 02:05:36 -0800 (PST) Original-Received: from olgas.newt.com (localhost [127.0.0.1]) by olgas.newt.com (Postfix) with ESMTP id 03ABA16FAC; Thu, 29 Dec 2005 02:05:36 -0800 (PST) Original-To: Stefan Monnier In-Reply-To: Stefan Monnier's message of Thu, 29 Dec 2005 11:14:49 EST. <87k6dn6fz6.fsf-monnier+emacs@gnu.org> X-Mailer: MH-E 7.85+cvs; nmh 1.1; GNU Emacs 22.0.50.13 X-Image-URL: http://www.newt.com/wohler/images/bill-diving.png Mail-Followup-To: emacs-devel@gnu.org, "Davide G. M. Salvetti" , Romain Francoise X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:48500 Archived-At: Stefan Monnier 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 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.