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: obsolete comment in tool-bar.el Date: Tue, 19 Jul 2005 23:05:28 -0500 (CDT) Message-ID: <200507200405.j6K45SZ18998@raven.dms.auburn.edu> References: <200507071915.j67JFZT29961@raven.dms.auburn.edu> <200507090235.j692ZER04883@raven.dms.auburn.edu> <200507110321.j6B3LgG09526@raven.dms.auburn.edu> <85y88dfcqw.fsf@lola.goethe.zz> <200507130302.j6D32qE05640@raven.dms.auburn.edu> <200507140208.j6E28tr08794@raven.dms.auburn.edu> <200507141830.j6EIU5r11167@raven.dms.auburn.edu> <878y08k857.fsf-monnier+emacs@gnu.org> <200507151353.j6FDrMf12755@raven.dms.auburn.edu> <200507160204.j6G24XE13583@raven.dms.auburn.edu> <200507190259.j6J2xmf16875@raven.dms.auburn.edu> <874qaqg8w0.fsf-monnier+emacs@gnu.org> NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1121833702 14590 80.91.229.2 (20 Jul 2005 04:28:22 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 20 Jul 2005 04:28:22 +0000 (UTC) Cc: rms@gnu.org, mituharu@math.s.chiba-u.ac.jp, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jul 20 06:28:10 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Dv6BY-0001Ea-4w for ged-emacs-devel@m.gmane.org; Wed, 20 Jul 2005 06:27:56 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Dv6DX-0002sH-Qw for ged-emacs-devel@m.gmane.org; Wed, 20 Jul 2005 00:29:59 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Dv69s-0002PC-EW for emacs-devel@gnu.org; Wed, 20 Jul 2005 00:26:12 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Dv69i-0002Kc-Hh for emacs-devel@gnu.org; Wed, 20 Jul 2005 00:26:07 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Dv69h-0002EC-DD for emacs-devel@gnu.org; Wed, 20 Jul 2005 00:26:01 -0400 Original-Received: from [131.204.53.104] (helo=manatee.dms.auburn.edu) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Dv5zc-0002Dd-Q6; Wed, 20 Jul 2005 00:15:37 -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 j6K45mCK022498; Tue, 19 Jul 2005 23:05:48 -0500 (CDT) Original-Received: (from teirllm@localhost) by raven.dms.auburn.edu (8.11.7p1+Sun/8.11.7) id j6K45SZ18998; Tue, 19 Jul 2005 23:05:28 -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: <874qaqg8w0.fsf-monnier+emacs@gnu.org> (message from Stefan Monnier on Tue, 19 Jul 2005 10:41:42 -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:41085 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:41085 Stefan Monnier wrote: Please check the commit-history of this piece of code (e.g. with vc-annotate) to see that it used to do what you say it "should" do (i.e. also call the minor-mode function if the init-value is non-nil). First of all, I assume the lack of reaction to my patch means that you no longer object to it. I will wait another day or so to make sure that this is indeed the case. I will have to do something reasonably soon, since without that patch (or proper alternative) Emacs fails to build on certain operating systems. To answer the above quote, the define-minor-mode code used to contain: ;; If the mode is global, call the function according to the default. ,(if globalp `(if ,mode (,mode 1)))))) until you started making various changes to this section of define-minor-mode. The original code I quoted above had the shortcoming of performing part of the initialization outside of the defcustom, which can be confusing. But it _did_ enable the mode if the defcustom sat the variable to t and that was the intended purpose of the code, as the comment makes clear. The current code follows the following idea: Loading a file should change Emacs's state as little as possible, so the init-value of a minor mode should *describe* (not determine) the default state of the minor-mode (in the case where the minor-mode function is not executed). I understood that. However setting the mode variable to t without enabling the mode has some very bad consequences, to the point that I believe it could be considered an outright bug. If the mode has a lighter, the mode line claims that the mode is enabled, whereas it is not, confusing the user. Even though the mode variable is non-nil, the mode is disabled, so `M-x foo-mode' should enable it. Instead, `M-x foo-mode' is actually a no-op in this situation, which is also very confusing to the user. With the current code (with or without the code I propose to delete), if you want to enable a global minor mode by default, you have to preload the library that defines the minor mode before startup.el is loaded and then enable the mode by calling the minor mode function in startup.el. (Calling it in startup.el instead of in the file defining the minor mode prevents calling it again if for some reason the file gets reloaded.) This way you avoid the bugs described above. Of course, the author of a package not included with Emacs can not preload his file. So the author of such a file should put `(if foo-mode (foo-mode 1))' in his file, at a place late enough that calling foo-mode does not produce any errors. One solution is to just document the above. (Many people do not know it.) This would have the advantage that, even after the code I propose to remove is removed, define-minor-mode does not need to be called near the end of the file, because it would never call the minor mode function. Another solution is to change the :initialize function. There are some reasons why this would appear to be cleaner. However, it would require changing the order in which define-minor-mode does things and, _if_ a global minor mode is enabled by default, then define-minor-mode would have to be called at a place in the file where calling the minor mode function will not lead to an error. Sincerely, Luc.