From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Luc Teirlinck Newsgroups: gmane.emacs.devel Subject: Re: [drew.adams@oracle.com: Info on define-minor-mode - :init-value or :initial-value?] Date: Thu, 28 Jul 2005 20:48:09 -0500 (CDT) Message-ID: <200507290148.j6T1m9j18171@raven.dms.auburn.edu> References: <200507271604.j6RG4Pf04580@raven.dms.auburn.edu> NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1122602823 20746 80.91.229.2 (29 Jul 2005 02:07:03 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 29 Jul 2005 02:07:03 +0000 (UTC) Cc: rms@gnu.org, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jul 29 04:06:55 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DyKGy-00070z-R1 for ged-emacs-devel@m.gmane.org; Fri, 29 Jul 2005 04:06:53 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DyKJR-0001lL-Lz for ged-emacs-devel@m.gmane.org; Thu, 28 Jul 2005 22:09:25 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DyKGi-0000gi-HN for emacs-devel@gnu.org; Thu, 28 Jul 2005 22:06:37 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DyKGT-0000Zl-6p for emacs-devel@gnu.org; Thu, 28 Jul 2005 22:06:22 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DyKGT-0000Um-3f for emacs-devel@gnu.org; Thu, 28 Jul 2005 22:06:21 -0400 Original-Received: from [131.204.53.104] (helo=manatee.dms.auburn.edu) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DyKAu-0000pN-3t; Thu, 28 Jul 2005 22:00:36 -0400 Original-Received: from raven.dms.auburn.edu (raven.dms.auburn.edu [131.204.53.29]) by manatee.dms.auburn.edu (8.12.10/8.12.10) with ESMTP id j6T1mqCK024088; Thu, 28 Jul 2005 20:48:52 -0500 (CDT) Original-Received: (from teirllm@localhost) by raven.dms.auburn.edu (8.11.7p1+Sun/8.11.7) id j6T1m9j18171; Thu, 28 Jul 2005 20:48:09 -0500 (CDT) X-Authentication-Warning: raven.dms.auburn.edu: teirllm set sender to teirllm@dms.auburn.edu using -f Original-To: monnier@iro.umontreal.ca In-reply-to: (message from Stefan Monnier on Thu, 28 Jul 2005 12:58:30 -0400) 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:41292 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:41292 Stefan Monnier wrote: > There is more. You can not specify a non-nil :init-value, unless > either the minor mode is enabled by just setting the variable or > unless you do something extra. In what way is this a limitation? I.e. if you don't use define-minor-mode, how would you do it differently? [ I don't mean to say that "manual" code can't do it differently, but that if it does it differently, it'll most likely break the convention that just loading a file shouldn't make any visible changes. ] Suppose that you have a minor mode that only makes a difference when you are using the speedbar. (I just take this as an example; any option that is itself not enabled by default will do.) The minor mode would be part of the intended default behavior of speedbar, but not everybody might like it, hence the need for a defcustom with default t. You use `custom-initialize-set' as the :initialize function. You put the minor mode code in speedbar.el. Now loading speedbar.el will enable the minor mode, unless the user overwrote that by setting the minor mode variable to nil. However, this will not change the behavior of Emacs in any way that is unrelated to the speedbar. With the current define-minor-mode code, you can _try_ to set the :initialize keyword to `custom-initialize-set', but it will not work, because define-minor-mode writes the defcustom before the minor mode function, hence executing the defcustom will yield an error. It is possible to change the define-minor-mode code to get around that, but I guess that it would require define-minor-mode to first write a compiler defvar, then the mode function, and then the defcustom. Also, all functions used by the minor mode function would have to be defined before the define-minor-mode (if the minor mode is enabled by default). Sincerely, Luc.