[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bug#3688: Also need (auto-fill-mode nil) to trigger this bug

From: Stefan Monnier
Subject: Re: bug#3688: Also need (auto-fill-mode nil) to trigger this bug
Date: Mon, 29 Jun 2009 14:14:01 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.94 (gnu/linux)

>> All minor modes are turned on with a positive arg and turned off with
>> a negative arg.  A nil argument may toggle it, but that might change in
>> the future.  A `toggle' argument toggles most (but not all) minor modes.

> OK. I didn't know that (and I'm using emacs for almost two decades now).

The use of positive/negative to turn the mode on/off is described in the
docstring as:

  With ARG, turn Auto Fill mode on if and only if arg is positive.

> Still I want to express my dislike about the way a "nil" arg is handled.

I agree.  I'd like to change it to behave like a positive arg, but the
way it works is just a result of the fact that when used interactively
you want the command to toggle when it is not given any prefix argument
and the easiest way to do that is to consider nil as "toggle".

All minor modes defined using `define-minor-mode' now accept (and use,
when called interactively) the value `toggle' to indicate that we want
to toggle.  They also still accept nil to mean "toggle" but this is the
part that I intend to change at some point.

> First, is 0 a positive arg?

If you don't know, don't use it.  There are plenty of obviously-positive
arguments to choose from.

>    (auto-fill-mode -1)      ;;; turn off
>    (auto-fill-mode 1)       ;;; turn on

These are the two canonical ways to turn the mode ON/OFF.

>    (auto-fill-mode)         ;;; toggles
>    (auto-fill-mode nil)     ;;; toggles

auto-fill-mode cannot distinguish between these two cases, so obviously
if one toggles, the other will too.
[ Well, yes, if it used &rest, it could actually distinguish, but since
it doesn't, it can't. ]

>    (auto-fill-mode 0)       ;;; turn off
>    (auto-fill-mode t)       ;;; turn on

These two have been used fairly often, but I strongly discourage
their use.  I think they make about as much sense as

    (auto-fill-mode "Hi John!")
    (auto-fill-mode (make-overlay))

> Toggling for a "nil" argument does not make sense to me.

I actually agree.  For various reasons (mostly, for use of the function
on mode hooks), nil should turn the mode ON unconditionally; but history
decided otherwise.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]