[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#24706: 26.0.50; Minor mode functions should do strict argument type
From: |
Drew Adams |
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) |
> >> (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.