summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2022-04-03 14:07:55 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2022-04-03 14:08:04 +0200
commit5e429e21d9ae7e217c4c2b5b6d78f932c8f6ae39 (patch)
tree462ab8ef3e3574cf3103724df8341b7ddc477112 /lisp/emacs-lisp
parent1fb20a4dde8c63a1aae570b59bb4bbb02673bec9 (diff)
downloademacs-5e429e21d9ae7e217c4c2b5b6d78f932c8f6ae39.tar.gz
emacs-5e429e21d9ae7e217c4c2b5b6d78f932c8f6ae39.tar.bz2
emacs-5e429e21d9ae7e217c4c2b5b6d78f932c8f6ae39.zip
Have global minor modes say so in the doc string
* lisp/emacs-lisp/easy-mmode.el (easy-mmode--arg-docstring): Allow saying whether it's a global minor mode or not. (easy-mmode--mode-docstring): Use it. (define-minor-mode): Pass in the data.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/easy-mmode.el20
1 files changed, 11 insertions, 9 deletions
diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el
index 21a29a722c3..b2302624b1a 100644
--- a/lisp/emacs-lisp/easy-mmode.el
+++ b/lisp/emacs-lisp/easy-mmode.el
@@ -82,9 +82,9 @@ replacing its case-insensitive matches with the literal string in LIGHTER."
(replace-regexp-in-string (regexp-quote lighter) lighter name t t))))
(defconst easy-mmode--arg-docstring
- "This is a minor mode. If called interactively, toggle the `%s'
-mode. If the prefix argument is positive, enable the mode, and
-if it is zero or negative, disable the mode.
+ "This is a %sminor mode. If called interactively, toggle the
+`%s' mode. If the prefix argument is positive, enable the mode,
+and if it is zero or negative, disable the mode.
If called from Lisp, toggle the mode if ARG is `toggle'.
Enable the mode if ARG is nil, omitted, or is a positive number.
@@ -97,7 +97,7 @@ The mode's hook is called both when the mode is enabled and when
it is disabled.")
(defun easy-mmode--mode-docstring (doc mode-pretty-name keymap-sym
- getter)
+ getter global)
;; If we have a doc string, and it's already complete (which we
;; guess at with the simple heuristic below), then just return that
;; as is.
@@ -124,10 +124,12 @@ it is disabled.")
(let* ((fill-prefix nil)
(docs-fc (bound-and-true-p emacs-lisp-docstring-fill-column))
(fill-column (if (integerp docs-fc) docs-fc 65))
- (argdoc (format easy-mmode--arg-docstring mode-pretty-name
- ;; Avoid having quotes turn into pretty quotes.
- (string-replace "'" "\\\\='"
- (format "%S" getter)))))
+ (argdoc (format
+ easy-mmode--arg-docstring
+ (if global "global " "")
+ mode-pretty-name
+ ;; Avoid having quotes turn into pretty quotes.
+ (string-replace "'" "\\\\='" (format "%S" getter)))))
(let ((start (point)))
(insert argdoc)
(when (fboundp 'fill-region)
@@ -335,7 +337,7 @@ or call the function `%s'."))))
warnwrap
`(defun ,modefun (&optional arg ,@extra-args)
,(easy-mmode--mode-docstring doc pretty-name keymap-sym
- getter)
+ getter globalp)
,(when interactive
;; Use `toggle' rather than (if ,mode 0 1) so that using
;; repeat-command still does the toggling correctly.