unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
To: "'Xah Lee'" <xahlee@gmail.com>, <bug-gnu-emacs@gnu.org>
Subject: bug#4102: 23.1.50; recentf-mode nil but toggles
Date: Wed, 12 Aug 2009 21:15:41 -0700	[thread overview]
Message-ID: <F383C07A3CCF4CD6A513E6C1E77C1FF9@us.oracle.com> (raw)
In-Reply-To: <26d7a64b-c393-42b9-bacf-8a9e6c62eadd@f20g2000prn.googlegroups.com>

> 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	other threads:[~2009-08-13  4:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-10  8:06 bug#4102: 23.1.50; recentf-mode nil but toggles Xah Lee
2009-08-10 16:40 ` Stefan Monnier
2009-08-11  2:01   ` Xah Lee
2009-08-12  4:05     ` Kevin Rodgers
2009-08-13 17:36       ` Stefan Monnier
     [not found]     ` <mailman.4441.1250051225.2239.bug-gnu-emacs@gnu.org>
2009-08-12 19:33       ` Xah Lee
2009-08-13  4:15         ` Drew Adams [this message]
2009-08-13  4:53           ` Xah Lee

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=F383C07A3CCF4CD6A513E6C1E77C1FF9@us.oracle.com \
    --to=drew.adams@oracle.com \
    --cc=4102@emacsbugs.donarmstrong.com \
    --cc=bug-gnu-emacs@gnu.org \
    --cc=xahlee@gmail.com \
    /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).