GNU bug report logs - #4102
23.1.50; recentf-mode nil but toggles

Previous Next

Package: emacs;

Reported by: "Xah Lee" <xah <at> xahlee.org>

Date: Mon, 10 Aug 2009 08:15:05 UTC

Severity: normal

Done: Chong Yidong <cyd <at> stupidchicken.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 4102 in the body.
You can then email your comments to 4102 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4102; Package emacs. (Mon, 10 Aug 2009 08:15:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Xah Lee" <xah <at> xahlee.org>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Mon, 10 Aug 2009 08:15:05 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: "Xah Lee" <xah <at> xahlee.org>
To: <bug-gnu-emacs <at> gnu.org>
Subject: 23.1.50; recentf-mode nil but toggles
Date: Mon, 10 Aug 2009 01:06:19 -0700
gosh, stung by this bug.

in my elisp code, i have:

(recentf-mode nil)

this should turn it off, but actually it toggles.

here's a quote of its inline doc:
«
(recentf-mode &optional arg)

Toggle recentf mode.
With prefix argument arg, turn on if positive, otherwise off.
»

this is reproduciable in the following:

GNU Emacs 23.1.1 (i386-mingw-nt6.0.6002) of 2009-07-29 on SOFT-MJASON

GNU Emacs 23.1.50.1 (i386-mingw-nt6.0.6002) of 2009-06-30 on LENNART-69DE564 
(patched)

 Xah
∑ http://xahlee.org/

Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4102; Package emacs. (Mon, 10 Aug 2009 16:50:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Mon, 10 Aug 2009 16:50:03 GMT) Full text and rfc822 format available.

Message #10 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Xah Lee <xah <at> xahlee.org>
Cc: 4102 <at> debbugs.gnu.org, <bug-gnu-emacs <at> gnu.org>
Subject: Re: bug#4102: 23.1.50; recentf-mode nil but toggles
Date: Mon, 10 Aug 2009 12:40:34 -0400
> in my elisp code, i have:
> (recentf-mode nil)
> this should turn it off, but actually it toggles.

That's indeed the standard behavior for all minor modes.  Use integers
to avoid such surprises.

> With prefix argument arg, turn on if positive, otherwise off.

It's not clear whether nil is positive or negative.


        Stefan




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4102; Package emacs. (Mon, 10 Aug 2009 16:50:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Mon, 10 Aug 2009 16:50:05 GMT) Full text and rfc822 format available.

Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4102; Package emacs. (Tue, 11 Aug 2009 02:10:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Xah Lee" <xah <at> xahlee.org>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Tue, 11 Aug 2009 02:10:05 GMT) Full text and rfc822 format available.

Message #20 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: "Xah Lee" <xah <at> xahlee.org>
To: "Stefan Monnier" <monnier <at> iro.umontreal.ca>
Cc: <4102 <at> debbugs.gnu.org>, <bug-gnu-emacs <at> gnu.org>
Subject: Re: bug#4102: 23.1.50; recentf-mode nil but toggles
Date: Mon, 10 Aug 2009 19:01:37 -0700
>> With prefix argument arg, turn on if positive, otherwise off.
>
> It's not clear whether nil is positive or negative.

Thanks. That's interesting.

Can the doc adds a warning like:

The argument should be a integer. Do not use t or nil.

?

 Xah
∑ http://xahlee.org/

☄

----- Original Message ----- 
From: "Stefan Monnier" <monnier <at> iro.umontreal.ca>
To: "Xah Lee" <xah <at> xahlee.org>
Cc: <4102 <at> debbugs.gnu.org>; <bug-gnu-emacs <at> gnu.org>
Sent: Monday, August 10, 2009 9:40 AM
Subject: Re: bug#4102: 23.1.50; recentf-mode nil but toggles


>> in my elisp code, i have:
>> (recentf-mode nil)
>> this should turn it off, but actually it toggles.
>
> That's indeed the standard behavior for all minor modes.  Use integers
> to avoid such surprises.
>
>> With prefix argument arg, turn on if positive, otherwise off.
>
> It's not clear whether nil is positive or negative.






Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4102; Package emacs. (Tue, 11 Aug 2009 02:10:07 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Xah Lee" <xah <at> xahlee.org>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Tue, 11 Aug 2009 02:10:07 GMT) Full text and rfc822 format available.

Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4102; Package emacs. (Wed, 12 Aug 2009 04:15:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Kevin Rodgers <kevin.d.rodgers <at> gmail.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Wed, 12 Aug 2009 04:15:04 GMT) Full text and rfc822 format available.

Message #30 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Kevin Rodgers <kevin.d.rodgers <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#4102: 23.1.50; recentf-mode nil but toggles
Date: Tue, 11 Aug 2009 22:05:52 -0600
Xah Lee wrote:
>>> With prefix argument arg, turn on if positive, otherwise off.
>>
>> It's not clear whether nil is positive or negative.

It seems clear to me that nil is not positive, so the "otherwise"
condition holds.

> Thanks. That's interesting.
> 
> Can the doc adds a warning like:
> 
> The argument should be a integer. Do not use t or nil.

Do not use `supercalifragilisticexpialidocious' either.

How about: Use nil to toggle the mode on or off.

-- 
Kevin Rodgers
Denver, Colorado, USA





Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4102; Package emacs. (Thu, 13 Aug 2009 04:25:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Drew Adams" <drew.adams <at> oracle.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Thu, 13 Aug 2009 04:25:05 GMT) Full text and rfc822 format available.

Message #35 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: "Drew Adams" <drew.adams <at> oracle.com>
To: "'Xah Lee'" <xahlee <at> gmail.com>, <bug-gnu-emacs <at> gnu.org>
Subject: RE: bug#4102: 23.1.50; recentf-mode nil but toggles
Date: Wed, 12 Aug 2009 21:15:41 -0700
> Is there somewhere in elisp manual that
> explicitly explains/warns that commands that turn minor mode on/off
> stick to 1 and 0 and consider t and nil not acceptable argument?

(elisp) Minor Mode Conventions:

   * Define a command whose name is the same as the mode variable.  Its
     job is to enable and disable the mode by setting the variable.

     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.

     Here is an example taken from the definition of
     `transient-mark-mode'.  It shows the use of `transient-mark-mode'
     as a variable that enables or disables the mode's behavior, and
     also shows the proper way to toggle, enable or disable the minor
     mode based on the raw prefix argument value.

          (setq transient-mark-mode
                (if (null arg) (not transient-mark-mode)
                  (> (prefix-numeric-value arg) 0)))

Any positive integer is the same as 1.
Any negative integer is the same as 0.

 t  is the same as 1.
`-' is the same as 0.

 (4) is the same as 1.
(-4) is the same as 0.
 (0) is the same as 0.

(t) is the same as 1.

(nil) and (-): behavior not conventionally defined

nil always toggles. It lets you do just `M-x foo' to toggle (the most common
change).

You can do `C-u M-x foo' or `C-9 M-x foo' to turn it on and `C-- M-x foo' to
turn it off.

etc.





Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4102; Package emacs. (Thu, 13 Aug 2009 05:00:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to xahlee <at> gmail.com:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Thu, 13 Aug 2009 05:00:03 GMT) Full text and rfc822 format available.

Message #40 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Xah Lee <xahlee <at> gmail.com>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#4102: 23.1.50; recentf-mode nil but toggles
Date: Wed, 12 Aug 2009 21:53:13 -0700
[Message part 1 (text/plain, inline)]
Thanks Drew and all in this thread for the info.
 Xah

On Wed, Aug 12, 2009 at 9:15 PM, Drew Adams <drew.adams <at> oracle.com> wrote:

> > Is there somewhere in elisp manual that
> > explicitly explains/warns that commands that turn minor mode on/off
> > stick to 1 and 0 and consider t and nil not acceptable argument?
>
> (elisp) Minor Mode Conventions:
>
>   * Define a command whose name is the same as the mode variable.  Its
>     job is to enable and disable the mode by setting the variable.
>
>     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.
>
>     Here is an example taken from the definition of
>     `transient-mark-mode'.  It shows the use of `transient-mark-mode'
>     as a variable that enables or disables the mode's behavior, and
>     also shows the proper way to toggle, enable or disable the minor
>     mode based on the raw prefix argument value.
>
>          (setq transient-mark-mode
>                (if (null arg) (not transient-mark-mode)
>                  (> (prefix-numeric-value arg) 0)))
>
> Any positive integer is the same as 1.
> Any negative integer is the same as 0.
>
>  t  is the same as 1.
> `-' is the same as 0.
>
>  (4) is the same as 1.
> (-4) is the same as 0.
>  (0) is the same as 0.
>
> (t) is the same as 1.
>
> (nil) and (-): behavior not conventionally defined
>
> nil always toggles. It lets you do just `M-x foo' to toggle (the most
> common
> change).
>
> You can do `C-u M-x foo' or `C-9 M-x foo' to turn it on and `C-- M-x foo'
> to
> turn it off.
>
> etc.
>
>


-- 
 Xah
∑ http://xahlee.org/
[Message part 2 (text/html, inline)]

Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4102; Package emacs. (Thu, 13 Aug 2009 17:45:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> IRO.UMontreal.CA>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Thu, 13 Aug 2009 17:45:04 GMT) Full text and rfc822 format available.

Message #45 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Kevin Rodgers <kevin.d.rodgers <at> gmail.com>
Cc: 4102 <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
Subject: Re: bug#4102: 23.1.50; recentf-mode nil but toggles
Date: Thu, 13 Aug 2009 13:36:32 -0400
> Do not use `supercalifragilisticexpialidocious' either.
> How about: Use nil to toggle the mode on or off.

Actually, the docstring already says that nil toggles.  If you remember
that the docstring is written here to describe the command rather than
the function, then you'll immediately conclude that

  With prefix argument arg, turn on if positive, otherwise off.

only applies when there's a prefix argument, so when there isn't, arg is
necessarily nil and the normal behavior (described on the previous line:

   Toggle recentf mode.

) applies.


        Stefan




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4102; Package emacs. (Thu, 13 Aug 2009 17:45:06 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> IRO.UMontreal.CA>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Thu, 13 Aug 2009 17:45:06 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to "Xah Lee" <xah <at> xahlee.org> Request was from Chong Yidong <cyd <at> stupidchicken.com> to control <at> emacsbugs.donarmstrong.com. (Sat, 15 Aug 2009 23:20:08 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> emacsbugs.donarmstrong.com. (Sun, 13 Sep 2009 14:24:11 GMT) Full text and rfc822 format available.

This bug report was last modified 15 years and 340 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.