From unknown Sat Aug 16 18:09:55 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#24706 <24706@debbugs.gnu.org> To: bug#24706 <24706@debbugs.gnu.org> Subject: Status: 26.0.50; Minor mode functions should do strict argument type checking Reply-To: bug#24706 <24706@debbugs.gnu.org> Date: Sun, 17 Aug 2025 01:09:55 +0000 retitle 24706 26.0.50; Minor mode functions should do strict argument type = checking reassign 24706 emacs submitter 24706 Philipp Stephani
> (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.=C2=A0 If called from Lisp, enable<= br class=3D"gmail_msg"> > the mode if ARG is omitted or nil, and toggle it if ARG is =E2=80=98to= ggle=E2=80=99."
>
> This appears to indicate that (foo-mode 'banana)
> should disable foo-mode, but it enables it.
No, it does not suggest that.=C2=A0 But to be clearer, it should
probably explicitly address the non-nil and non-`toggle' case,
like so:
=C2=A0 If called from Lisp, enable the mode if ARG is omitted or
=C2=A0 nil, toggle it if ARG is =E2=80=98toggle=E2=80=99, and disable it if= ARG is
=C2=A0 any other non-nil value.
(And place the Lisp description in a separate paragraph
from the interactive description.)
> I think minor modes should simply not allow anything but
> integers and 'toggle for ARG, avoiding this confusion.
Why?=C2=A0 There is no confusion possible, once the doc string
explicitly speaks about all possible argument values.
Why would you change the behavior, instead of just clarifying
the doc?
> (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.=C2=A0 If called from Lisp, enable<= br class=3D"gmail_msg"> > the mode if ARG is omitted or nil, and toggle it if ARG is =E2=80=98to= ggle=E2=80=99."
>
> This appears to indicate that (foo-mode 'banana)
> should disable foo-mode, but it enables it.
No, it does not suggest that.=C2=A0 But to be clearer, it should
probably explicitly address the non-nil and non-`toggle' case,
like so:
=C2=A0 If called from Lisp, enable the mode if ARG is omitted or
=C2=A0 nil, toggle it if ARG is =E2=80=98toggle=E2=80=99, and disable it if= ARG is
=C2=A0 any other non-nil value.
(And place the Lisp description in a separate paragraph
from the interactive description.)
> I think minor modes should simply not allow anything but
> integers and 'toggle for ARG, avoiding this confusion.
Why?=C2=A0 There is no confusion possible, once the doc string
explicitly speaks about all possible argument values.
Why would you change the behavior, instead of just clarifying
the doc?
> From: Philipp Stephani <p.stephani2@gmail.com>
> Date: Sun, 16 Oct 2016 18:25:08 +0000
>
> Attached a patch that uses the wording from `define-minor-mode'.
The patch for the ELisp manual simply rearranges the same words, so
it's not clear to me why we would prefer it to what's already there= .
As for the doc string, please avoid repetition, it's confusing.=C2=A0 I=
suggested to describe the additional features when the mode is called
from Lisp by using the word "also".