unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Luc Teirlinck <teirllm@dms.auburn.edu>
Cc: monnier@iro.umontreal.ca, mituharu@math.s.chiba-u.ac.jp, rms@gnu.org
Subject: Re: obsolete comment in tool-bar.el
Date: Mon, 18 Jul 2005 21:59:48 -0500 (CDT)	[thread overview]
Message-ID: <200507190259.j6J2xmf16875@raven.dms.auburn.edu> (raw)
In-Reply-To: <200507160204.j6G24XE13583@raven.dms.auburn.edu> (message from Luc Teirlinck on Fri, 15 Jul 2005 21:04:33 -0500 (CDT))

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))))))))
  \f
  ;;;
  ;;; make global minor mode
--- 267,273 ----
         (add-minor-mode ',mode ',lighter
  		       ,(if keymap keymap-sym
  			  `(if (boundp ',keymap-sym)
! 			       (symbol-value ',keymap-sym)))))))
  \f
  ;;;
  ;;; make global minor mode
============================================================

  reply	other threads:[~2005-07-19  2:59 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-07 12:40 obsolete comment in tool-bar.el Mathias Dahl
2005-07-07 19:15 ` Luc Teirlinck
2005-07-08  6:40   ` Mathias Dahl
2005-07-08 15:29     ` Luc Teirlinck
2005-07-08 17:40   ` Richard M. Stallman
2005-07-08 18:53     ` Drew Adams
2005-07-09  1:53       ` Luc Teirlinck
2005-07-09  4:20       ` Richard M. Stallman
2005-07-09  2:35     ` Luc Teirlinck
2005-07-10  5:19       ` Richard M. Stallman
2005-07-11  3:21         ` Luc Teirlinck
2005-07-11 16:53           ` Richard M. Stallman
2005-07-11 17:56             ` David Kastrup
2005-07-11 20:28               ` Luc Teirlinck
2005-07-12  3:20               ` Richard M. Stallman
2005-07-13  3:02                 ` Luc Teirlinck
2005-07-13 16:52                   ` Richard M. Stallman
2005-07-14  2:08                     ` Luc Teirlinck
2005-07-14  8:14                       ` YAMAMOTO Mitsuharu
2005-07-14 16:50                         ` Luc Teirlinck
2005-07-14 18:30                         ` Luc Teirlinck
2005-07-15  4:35                           ` Stefan Monnier
2005-07-15 13:53                             ` Luc Teirlinck
2005-07-15 20:44                               ` Stefan Monnier
2005-07-15 22:05                                 ` Luc Teirlinck
2005-07-15 22:46                                 ` Luc Teirlinck
2005-07-16  1:47                                 ` Luc Teirlinck
2005-07-16  2:04                                 ` Luc Teirlinck
2005-07-19  2:59                                   ` Luc Teirlinck [this message]
2005-07-19 14:41                                     ` Stefan Monnier
2005-07-20  4:05                                       ` Luc Teirlinck
2005-07-21  5:40                                         ` Stefan Monnier
2005-07-20  8:34                                     ` Richard M. Stallman
     [not found]                       ` <E1Dt8bd-0001fH-Eu@fencepost.gnu.org>
2005-07-14 22:05                         ` Luc Teirlinck
2005-07-15  3:24                           ` Luc Teirlinck
2005-07-15 18:10                             ` Richard M. Stallman
2005-07-16  2:32                               ` Luc Teirlinck
2005-07-13  3:20                 ` Luc Teirlinck
2005-07-09  3:57     ` Luc Teirlinck
2005-07-09  7:55       ` Eli Zaretskii
2005-07-09 13:57         ` Luc Teirlinck
2005-07-12  4:13           ` YAMAMOTO Mitsuharu
2005-07-12 12:20             ` YAMAMOTO Mitsuharu
2005-07-12 18:25               ` Luc Teirlinck
2005-07-12 23:58                 ` Luc Teirlinck
2005-07-13 16:52                   ` Richard M. Stallman
2005-07-12 20:19               ` Luc Teirlinck
2005-07-13  1:53               ` Luc Teirlinck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200507190259.j6J2xmf16875@raven.dms.auburn.edu \
    --to=teirllm@dms.auburn.edu \
    --cc=mituharu@math.s.chiba-u.ac.jp \
    --cc=monnier@iro.umontreal.ca \
    --cc=rms@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).