bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#4102: 23.1.50; recentf-mode nil but toggles


From: Drew Adams
Subject: 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.







reply via email to

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