all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Noam Postavsky <npostavs@users.sourceforge.net>
Cc: 24706@debbugs.gnu.org, Philipp Stephani <p.stephani2@gmail.com>
Subject: bug#24706: 26.0.50; Minor mode functions should do strict argument type checking
Date: Sun, 16 Oct 2016 09:49:32 -0700 (PDT)	[thread overview]
Message-ID: <75ec3189-08f4-455f-bfa6-f21e1d0454d6@default> (raw)
In-Reply-To: <CAM-tV-_FnCVWPMypH7sjRvubPz7X31jiCDXtiQAWEZJGg6yfow@mail.gmail.com>

> >> (define-minor-mode foo-mode nil)
> >> its docstring will be
> >>
> >> "Toggle Foo mode on or off.
> >> With a prefix argument ARG, enable Foo mode if ARG is
> >> positive, and disable it otherwise.  If called from Lisp, enable
> >> the mode if ARG is omitted or nil, and toggle it if ARG is ‘toggle’."
> >>
> >> This appears to indicate that (foo-mode 'banana)
> >> should disable foo-mode, but it enables it.
> >
> > No, it does not suggest that.  But to be clearer, it should
> > probably explicitly address the non-nil and non-`toggle' case,
> > like so:
> >
> >   If called from Lisp, enable the mode if ARG is omitted or
> >   nil, toggle it if ARG is ‘toggle’, and disable it if ARG is
> >   any other non-nil value.
> 
> If the Lisp description is meant to be exhaustive by itself, we should
> cover the numeric case too:
> 
>    If called from Lisp, enable the mode if ARG is omitted, nil, or a
>    positive number; toggle it if ARG is `toggle'; and disable it
>    otherwise.

Yes, and anyway what I wrote was wrong.

The doc string of `define-minor-mode' has it right, as does your
suggestion:

  When called from Lisp, the mode command toggles the mode if the
  argument is `toggle', disables the mode if the argument is a
  non-positive integer, and enables the mode otherwise (including
  if the argument is omitted or nil or a positive integer).

I'd suggest the same order as in the `define-minor-mode' doc:

  When called from Lisp:
  * Toggle the mode if ARG is `toggle'.
  * Disable it if ARG is a non-positive integer.
  * Enable it if ARG is anything else.
  





  reply	other threads:[~2016-10-16 16:49 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-16 15:45 bug#24706: 26.0.50; Minor mode functions should do strict argument type checking Philipp Stephani
2016-10-16 16:12 ` Drew Adams
2016-10-16 16:31   ` Noam Postavsky
2016-10-16 16:49     ` Drew Adams [this message]
2016-10-16 18:01     ` Eli Zaretskii
2016-10-16 18:13   ` Philipp Stephani
2016-10-16 18:25     ` Philipp Stephani
2016-10-16 18:51       ` Eli Zaretskii
2017-04-23 17:51         ` Philipp Stephani
2017-04-26 11:26           ` Eli Zaretskii
2020-08-01 20:47             ` Philipp Stephani
2020-08-02 16:13               ` Eli Zaretskii
2020-10-01 12:12                 ` Stefan Kangas
2016-10-16 18:53     ` Eli Zaretskii
2016-10-16 19:50     ` Drew Adams

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=75ec3189-08f4-455f-bfa6-f21e1d0454d6@default \
    --to=drew.adams@oracle.com \
    --cc=24706@debbugs.gnu.org \
    --cc=npostavs@users.sourceforge.net \
    --cc=p.stephani2@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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.