Subject: bug#6335: closed (Re: bug#6335: 24.0.50; doc for define-minor-mode: specify ARG)

From: [email-masked] (GNU bug Tracking System)
Date: Thu, 03 Jun 2010 05:14:02 +0000

Your bug report

#6335: 24.0.50; doc for define-minor-mode: specify ARG

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
6335: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6335
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#6335: 24.0.50; doc for define-minor-mode: specify ARG
From: Stefan Monnier <[email-masked]>
To: "Drew Adams" <[email-masked]>
Date: Wed, 02 Jun 2010 21:54:43 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

> (cond ((integer arg) (if (> arg 0) do-foo do-fa))
>       ((consp arg) ...)
>       (arg ...)
>       (t ...))

I do not want to support this.
 
> The doc should also state clearly that the _raw prefix argument_ is used
> as ARG interactively.

It's not the case.

> Programmers can then take advantage of that fact also.  Knowing this,
> they can easily define a minor-mode command that lets users pass
> a significant value via a prefix arg.
 
And I don't want to support this either.

If people want to write functions that behave somewhat like minor modes
but with slightly different calling conventions, they can do that just
fine with `defun'.

        Stefan

Subject: 24.0.50; doc for define-minor-mode: specify ARG
From: "Drew Adams" <[email-masked]>
To: <[email-masked]>
Date: Wed, 2 Jun 2010 15:07:28 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

(elisp) Minor Mode Conventions says this about a minor-mode command:
 
 The command should accept one optional argument.  If the argument
 is `nil', it should toggle the mode (turn it on if it is off, and
 off if it is on).  It should turn the mode on if the argument is a
 positive integer, the symbol `t', or a list whose CAR is one of
 those.  It should turn the mode off if the argument is a negative
 integer or zero, the symbol `-', or a list whose CAR is a negative
 integer or zero.  The meaning of other arguments is not specified.
 
`define-minor-mode' defines such a command.  But the doc for
`define-minor-mode' does not let you know the identity of the parameter
(which is ARG) or anything about where its value comes from
interactively.  It should, for at least these reasons:
 
1. A programmer can use the value.  It is one thing to know that a
positive arg turns the mode on.  It is another thing to know what the
arg name is, so that the command body can recuperate that value and use
it.  For example, the body of the command could do something different,
depending on the value:
 
(cond ((integer arg) (if (> arg 0) do-foo do-fa))
      ((consp arg) ...)
      (arg ...)
      (t ...))
 
2. This would require Emacs developers to maintain `define-minor-mode'
so that the name ARG is respected.  Yes, that's a good thing, not a bad
thing.  The argument should explicitly be part of the spec defining
`define-minor-mode'.  Programmers will anyway use `symbol-function' to
find out what the parameter is, and it is better that Emacs Dev
recognize this, respect the parameter name, and document it.
 
The doc should also state clearly that the _raw prefix argument_ is used
as ARG interactively.  Programmers can then take advantage of that fact
also.  Knowing this, they can easily define a minor-mode command that
lets users pass a significant value via a prefix arg.
 
All of this is important, missing info for programmers.

In GNU Emacs 24.0.50.1 (i386-mingw-nt5.1.2600)
 of 2010-05-23 on G41R2F1
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (3.4) --no-opt --cflags -Ic:/xpm/include'