GNU bug report logs -
#44341
27.1; define-minor-mode generates inaccurate docstring
Previous Next
Reported by: Thibault Polge <thibault <at> thb.lt>
Date: Sat, 31 Oct 2020 11:01:02 UTC
Severity: normal
Tags: fixed
Found in version 27.1
Fixed in version 28.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
In my Emacs 27.1, the following line:
(define-minor-mode test-mode "A test.")
generates a function test-mode whose docstring ends as follows:
> If called from Lisp, also enable the mode if ARG is omitted or nil,
> and toggle it if ARG is ‘toggle’; disable the mode otherwise.
This case (non-interactively, enable the mode if ARG is non-nil, unless
it's toggle) doesn't seem to have been implemented. Here's a test that
demonstrates that:
(mapcar
(lambda (x) (test-mode x) (cons x test-mode))
'(t ; Should disable.
nil ; Should disable
-33 ; Should NOT disable (but will)
33 ; Should enable
0 ; Should disable
toggle ; Should toggle, and will.
toggle ; Repeated for confirmation
disable ; Should disable (as a random symbol)
disable ; Again
"What?" ; Same.
))
The generated function reads as follows, and indeed implements none of
the conditions the docstring describes. The relevant par is in the
first half, before (run-hooks)
(defun test-mode
(&optional arg)
"A test.\n\nIf called interactively, enable Test mode if ARG is positive, and\ndisable it if ARG is zero or negative. If called from Lisp, also\nenable the mode if ARG is omitted or nil, and toggle it if ARG is\n`toggle'; disable the mode otherwise."
(interactive
(list
(or current-prefix-arg 'toggle)))
(let
((last-message
(current-message)))
(setq test-mode
(if
(eq arg 'toggle)
(not test-mode)
(>
(prefix-numeric-value arg)
0)))
(run-hooks 'test-mode-hook
(if test-mode 'test-mode-on-hook 'test-mode-off-hook))
(if
(called-interactively-p 'any)
(progn nil
(unless
(and
(current-message)
(not
(equal last-message
(current-message))))
(let
((local " in current buffer"))
(message "Test mode %sabled%s"
(if test-mode "en" "dis")
local))))))
(force-mode-line-update)
test-mode)
Best regards,
Thibault
[signature.asc (application/pgp-signature, inline)]
This bug report was last modified 4 years and 293 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.