From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.devel Subject: RE: [drew.adams@oracle.com: Info on define-minor-mode - :init-valueor :initial-value?] Date: Thu, 28 Jul 2005 10:43:17 -0700 Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1122573360 16135 80.91.229.2 (28 Jul 2005 17:56:00 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 28 Jul 2005 17:56:00 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jul 28 19:55:51 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DyCbF-0007Q2-30 for ged-emacs-devel@m.gmane.org; Thu, 28 Jul 2005 19:55:17 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DyCdh-00065y-CP for ged-emacs-devel@m.gmane.org; Thu, 28 Jul 2005 13:57:49 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DyCal-00037T-Np for emacs-devel@gnu.org; Thu, 28 Jul 2005 13:54:48 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DyCae-00033a-7V for emacs-devel@gnu.org; Thu, 28 Jul 2005 13:54:40 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DyCad-0002xA-J0 for emacs-devel@gnu.org; Thu, 28 Jul 2005 13:54:39 -0400 Original-Received: from [148.87.122.30] (helo=rgminet01.oracle.com) by monty-python.gnu.org with esmtp (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.34) id 1DyCbG-00067Z-5b for emacs-devel@gnu.org; Thu, 28 Jul 2005 13:55:19 -0400 Original-Received: from rgminet01.oracle.com (localhost [127.0.0.1]) by rgminet01.oracle.com (Switch-3.1.6/Switch-3.1.6) with ESMTP id j6SHhJ09018001 for ; Thu, 28 Jul 2005 11:43:19 -0600 Original-Received: from rgmsgw301.us.oracle.com (rgmsgw301.us.oracle.com [138.1.186.50]) by rgminet01.oracle.com (Switch-3.1.6/Switch-3.1.6) with ESMTP id j6SHhIeN017988 for ; Thu, 28 Jul 2005 11:43:18 -0600 Original-Received: from rgmsgw301.us.oracle.com (localhost [127.0.0.1]) by rgmsgw301.us.oracle.com (Switch-3.1.4/Switch-3.1.0) with ESMTP id j6SHhH4b030843 for ; Thu, 28 Jul 2005 11:43:18 -0600 Original-Received: from dradamslap (dradams-lap.us.oracle.com [130.35.177.126]) by rgmsgw301.us.oracle.com (Switch-3.1.4/Switch-3.1.0) with SMTP id j6SHhHmY030838 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) for ; Thu, 28 Jul 2005 11:43:17 -0600 Original-To: X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 In-Reply-To: Importance: Normal X-Brightmail-Tracker: AAAAAQAAAAI= X-Whitelist: TRUE 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:41274 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:41274 For the moment, I just replaced the incorrect keyword :initial-value in the example with :init-value. Thanks. > 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. ] I don't know how you'll decide to handle this, but I agree with Luc that it is confusing to set the :init-value to, say, `t' and then not see that initial value be effective. I did this recently, in fact. I saw the mode name appear in the mode-line after loading the file, saw that the mode variable was indeed `t', and was confused that the mode was not actually turned on, in spite of the mode-line indication and the variable value. Not good, in terms of user interface. This is not very clear to me, I admit, so ignore my comments if they are off-base. IIUC, users creating a library with a define-minor-mode that has a non-nil :init-value will need to do something like the following at the end of the library (otherwise, the lighter and mode variable will indicate that the mode is on after loading, but it is not really on): (if foo-mode (foo-mode 1)) If this is correct, couldn't this be made part of the define-minor-mode macro - say, to execute this code automatically after loading the library? If my understanding is correct, but such automatic treatment is not a good idea, shouldn't this `(if foo-mode (foo-mode 1))' cliche be documented as a guideline? I found it after 1) reading Luc's email and 2) grepping the Lisp directory to see how other libraries dealt with this issue. At the least, if nothing special is done to treat non-nil :init-value, and users need to do something additional themselves, then shouldn't the Info doc show an example with non-nil :init-value, instead of the current example using nil? WRT the guideline of "loading must not change anything" - I agree, but I think that turning on a minor mode is usually relatively benign, because it can be turned off easily. Users loading a library that defines a minor mode will not be shocked if the mode is turned on by default, if the logical initial value to use is something other than nil. Otherwise, if we're going to be rigid about this guideline (perhaps there are good reasons to do that, even in this case), then maybe we should just get rid of :init-value and have the initial value always be nil - that is, make users of a library turn on the minor mode explicitly. That would not be my preference, but it would at least avoid confusion.