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: Mon, 18 Jul 2005 21:59:48 -0500 (CDT) Message-ID: <200507190259.j6J2xmf16875@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> NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1121742882 1676 80.91.229.2 (19 Jul 2005 03:14:42 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 19 Jul 2005 03:14:42 +0000 (UTC) Cc: monnier@iro.umontreal.ca, mituharu@math.s.chiba-u.ac.jp, rms@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jul 19 05:14:38 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DuiYk-0000BQ-Tw for ged-emacs-devel@m.gmane.org; Tue, 19 Jul 2005 05:14:19 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Duiai-0000Ct-Of for ged-emacs-devel@m.gmane.org; Mon, 18 Jul 2005 23:16:20 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DuiXs-0007nv-18 for emacs-devel@gnu.org; Mon, 18 Jul 2005 23:13:24 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DuiXg-0007lc-4J for emacs-devel@gnu.org; Mon, 18 Jul 2005 23:13:15 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DuiXd-0007eb-M8 for emacs-devel@gnu.org; Mon, 18 Jul 2005 23:13:09 -0400 Original-Received: from [131.204.53.104] (helo=manatee.dms.auburn.edu) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DuiUD-0001Gd-MO; Mon, 18 Jul 2005 23:09: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 j6J307CK018830; Mon, 18 Jul 2005 22:00:07 -0500 (CDT) Original-Received: (from teirllm@localhost) by raven.dms.auburn.edu (8.11.7p1+Sun/8.11.7) id j6J2xmf16875; Mon, 18 Jul 2005 21:59:48 -0500 (CDT) X-Authentication-Warning: raven.dms.auburn.edu: teirllm set sender to teirllm@dms.auburn.edu using -f Original-To: emacs-devel@gnu.org In-reply-to: <200507160204.j6G24XE13583@raven.dms.auburn.edu> (message from Luc Teirlinck on Fri, 15 Jul 2005 21:04:33 -0500 (CDT)) 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:41060 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:41060 Since the current version of `define-minor-mode', is incompatible with the new :initialize function customize-initialize-safe-default, _something_ needs to be done. (It currently breaks the building of Emacs on certain operating systems and additional uses of customize-initialize-safe-default could, with the current define-minor-mode, easily break it on all operating systems.) So either we apply the patch below, or we have to introduce a condition-case form in the code removed by that patch. I propose to apply the patch below. It removes completely useless code at the end of define-minor-mode. I explained in the message I am replying to and in my message before that one, why that code is not only useless, but causes several very annoying misfeatures. Here is a summary of these misfeatures: 1) The code uses eval-after-load, which, according to `(elisp)Hooks for Loading', well-designed Lisp programs should not use. For good reason: it destroys the interactive nature of Elisp. Any code that directly or indirectly uses define-minor-mode can not be reliably tested interactively, say in the *scratch* buffer or ielm. It can only be tested reliably by loading files, as I found out. My patch would remove this misfeature. 2) Just loading the file may result in the minor mode function being called. It is true that there is precedent for this: the default :set function `custom-initialize-reset' has the same problem. But reportedly, define-minor-mode uses custom-initialize-default, exactly to avoid that problem. In vain, unless we apply the patch below. 3) The unnatural code I propose to erase makes `define-minor-mode' prone to errors if anything else in Emacs changes. We are currently struggling with an example of that. 4) It disguises potential bugs in Elisp code where somebody sets the minor mode variable instead of calling the minor mode function, by more or less randomly "correcting" the bug for the current session only. This makes debugging Emacs more difficult. 5) By more or less at random correcting _user_ bugs of the type discussed in (4), namely setting the minor mode variable with setq outside Custom, it confuses the user, because setting the variable sometimes appears to work and sometimes not. If it never worked, it would be much easier for the user to realize that it was not the correct way to customize the minor mode. Note that a user using setq instead of Custom is probably trying to learn and define-minor-mode should not interfere with his learning process. The code I propose to remove does not take care of a problem which the original code it replaced did address and which the current comment still falsely claims it addresses: loading the file does currently _not_ enable the minor mode if the standard value is non-nil and the minor mode variable is unbound when the defcustom is evaluated. _Maybe_ that problem should be taken care of, although that would inevitably also reintroduce misfeature (2) above, but not in a very bad way. As I explained earlier, I believe that the best way to do that would be to make define-minor-mode use a new :initialize function. The patch below does _not_ do that. ===File ~/easy-mmode-diff=================================== *** easy-mmode.el 15 Jul 2005 19:36:26 -0500 1.69 --- easy-mmode.el 18 Jul 2005 19:03:51 -0500 *************** *** 267,278 **** (add-minor-mode ',mode ',lighter ,(if keymap keymap-sym `(if (boundp ',keymap-sym) ! (symbol-value ',keymap-sym)))) ! ! ;; If the mode is global, call the function according to the default. ! ,(if globalp ! `(if (and load-file-name (not (equal ,init-value ,mode))) ! (eval-after-load load-file-name '(,mode (if ,mode 1 -1)))))))) ;;; ;;; make global minor mode --- 267,273 ---- (add-minor-mode ',mode ',lighter ,(if keymap keymap-sym `(if (boundp ',keymap-sym) ! (symbol-value ',keymap-sym))))))) ;;; ;;; make global minor mode ============================================================