unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Docstrings of minor modes are unclear
@ 2012-10-12  8:45 Tassilo Horn
  2012-10-12 14:30 ` Stefan Monnier
  0 siblings, 1 reply; 2+ messages in thread
From: Tassilo Horn @ 2012-10-12  8:45 UTC (permalink / raw)
  To: emacs-devel

Hi all,

the docstrings of (global) minor modes defined with `define-minor-mode'
and `define-globalized-minor-mode' are a bit unclear.  Both say:

  If called from Lisp, enable the mode if ARG is omitted or nil.

This is only halfway true.  The minor more will be activated if ARG is
omitted or if ARG is not a negative integer or zero.

I've now seen that in the meantime the docstring generated by
`define-minor-mode' has been made a bit accurate in terms of mentioning
'toggle, but it's still not clear.

Any objections to the following patch?


--8<---------------cut here---------------start------------->8---
=== modified file 'lisp/emacs-lisp/easy-mmode.el'
--- lisp/emacs-lisp/easy-mmode.el	2012-09-22 15:24:26 +0000
+++ lisp/emacs-lisp/easy-mmode.el	2012-10-12 08:42:31 +0000
@@ -259,8 +259,11 @@
 	 ,(or doc
 	      (format (concat "Toggle %s on or off.
 With a prefix argument ARG, enable %s 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'.
+positive, and disable it otherwise.  When called from Lisp,
+toggle the mode if the argument is `toggle', disable the mode if
+the argument is a non-positive integer, and enable the mode
+otherwise including if the argument is omitted or nil or a
+positive integer.
 \\{%s}") pretty-name pretty-name keymap-sym))
 	 ;; Use `toggle' rather than (if ,mode 0 1) so that using
 	 ;; repeat-command still does the toggling correctly.
@@ -381,8 +384,10 @@
 	 ;; doc string.
 	 ,(format "Toggle %s in all buffers.
 With prefix ARG, enable %s if ARG is positive;
-otherwise, disable it.  If called from Lisp, enable the mode if
-ARG is omitted or nil.
+otherwise, disable it.  If called from Lisp, toggle the mode if
+the argument is `toggle', disable the mode if the argument is a
+non-positive integer, and enable the mode otherwise including if
+the argument is omitted or nil or a positive integer.
 
 %s is enabled in all buffers where
 \`%s' would do it.
--8<---------------cut here---------------end--------------->8---

Bye,
Tassilo



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Docstrings of minor modes are unclear
  2012-10-12  8:45 Docstrings of minor modes are unclear Tassilo Horn
@ 2012-10-12 14:30 ` Stefan Monnier
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2012-10-12 14:30 UTC (permalink / raw)
  To: emacs-devel

> the docstrings of (global) minor modes defined with `define-minor-mode'
> and `define-globalized-minor-mode' are a bit unclear.  Both say:

>   If called from Lisp, enable the mode if ARG is omitted or nil.

> This is only halfway true.

> I've now seen that in the meantime the docstring generated by
> `define-minor-mode' has been made a bit accurate in terms of mentioning
> 'toggle, but it's still not clear.

> Any objections to the following patch?

This ends up duplicating the description (once for the interactive case
and once for the Lisp call case).  I'd rather keep something short, like
we have.
We just need to reword it a bit so as to make it clear that when we say
"If called from Lisp," it doesn't mean that what was said before doesn't
apply, but that *in addition* to what was said before "enable the mode
if ARG is omitted or nil, and toggle it if ARG is `toggle'".

I don't have a good suggestion for how to do that, tho.


        Stefan



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-10-12 14:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-12  8:45 Docstrings of minor modes are unclear Tassilo Horn
2012-10-12 14:30 ` Stefan Monnier

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).