From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Per Abrahamsen Newsgroups: gmane.emacs.help Subject: Re: defcustom: changing from defvar - order of execution Date: Tue, 10 May 2005 18:14:59 +0200 Organization: The Church of Emacs Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1115741508 19556 80.91.229.2 (10 May 2005 16:11:48 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 10 May 2005 16:11:48 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue May 10 18:11:44 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DVXKV-0007UU-4r for geh-help-gnu-emacs@m.gmane.org; Tue, 10 May 2005 18:11:31 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DVXT3-0006i7-H6 for geh-help-gnu-emacs@m.gmane.org; Tue, 10 May 2005 12:20:21 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!logbridge.uoregon.edu!news-FFM2.ecrc.net!news.net.uni-c.dk!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 70 Original-NNTP-Posting-Host: sheridan.dina.kvl.dk Original-X-Trace: news.net.uni-c.dk 1115741593 7164 130.225.40.227 (10 May 2005 16:13:13 GMT) Original-X-Complaints-To: usenet@news.net.uni-c.dk Original-NNTP-Posting-Date: Tue, 10 May 2005 16:13:13 +0000 (UTC) X-Face: +kRV2]2q}lixHkE{U)mY#+6]{AH=yN~S9@IFiOa@X6?GM|8MBp/ Mail-Copies-To: nobody User-Agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:Sc5HgWyhQdH4ophcHxbvFdZ5Xc8= Original-Xref: shelby.stanford.edu gnu.emacs.help:130827 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:26484 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:26484 "Drew Adams" writes: > (defcustom align-load-hook nil > "*Hook that gets run after the aligner has been loaded." > :type 'hook > :group 'align) > > (run-hooks 'align-load-hook) Load hooks are rather special, and shouldn't be declared with defcustom. Anyone using a load hook should be comfortable with Emacs Lisp. > Here's another example: > > (defcustom apropos-symbol-face 'bold > "*Face for symbol name in Apropos output, or nil for none." > :group 'apropos > :type 'face) > > (define-button-type 'apropos-symbol > 'face apropos-symbol-face > 'help-echo "mouse-2, RET: Display more help on this symbol" > 'follow-link t > 'action #'apropos-symbol-button-display-help > 'skip t) Problematic in any case, since changing apropos-symbol-face from customize will have no immidiate effect. It would be better to have apropos-symbol-face being an actual face, inheriting from bold. But because face inheritance wasn't in Emacs 19.0, Emacs is very incosistent about when to use faces, and when to use variables containing faces. Also in new code, since bad habbits don't die easily. > (defcustom mouse-avoidance-mode nil...) > (if mouse-avoidance-mode > (mouse-avoidance-mode mouse-avoidance-mode)) Is there a :set in the defcustom? Global minor mode variables should have one, so changing the variable from customize will turn the minor mode on or off. This will also solve the initialization order problem (with the risk of doing some unnecessary work). > Here's another example: > > (defcustom calculator-use-menu t ...) > (or calculator-mode-map > ... > (if (and calculator-use-menu ... calculator-use-menu should be a global minor mode, see above. > These examples are taken from just the first few standard Elisp libraries, > sorted alphabetically. I could go on, but you get the idea. As you see, the answer depends on the example. But a common answer is that if you need to depend on a user variable in the initialization, the user variable should have a :set that undo the effect if the user change it. > How is the user's customization (via Customize) taken into account in such > cases, if the custom-set-variables form is inserted at the _end_ of his > .emacs or custom-file? It looks to me like the _library_ (default) values of > such variables, not the user's customized values, will be used in the > library. The location in the .emacs file is just exposing the problem to more, in all cases the problem would show up if the library was loaded from the site initialization file, or even dumped with Emacs.