diff options
author | Juanma Barranquero <lekktu@gmail.com> | 2019-10-05 00:31:17 +0200 |
---|---|---|
committer | Juanma Barranquero <lekktu@gmail.com> | 2019-10-05 00:31:17 +0200 |
commit | bbfa9995ff3bdb8a00fe3082bc3249cc1e68e1ab (patch) | |
tree | 06b5c96b1e81f1272108cffd7f7606e0180fa693 /lisp/emacs-lisp/easy-mmode.el | |
parent | 2ff16a483702ef064babf0823b20b2138fc1571a (diff) | |
download | emacs-bbfa9995ff3bdb8a00fe3082bc3249cc1e68e1ab.tar.gz |
Improve docstrings auto-generated by `define-minor-mode'
* lisp/emacs-lisp/easy-mmode.el (easy-mmode--mode-docstring):
When using `easy-mmode--arg-docstring' to auto-generate a
docstring, refill it up to `emacs-lisp-docstring-fill-column'.
Diffstat (limited to 'lisp/emacs-lisp/easy-mmode.el')
-rw-r--r-- | lisp/emacs-lisp/easy-mmode.el | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el index 5e7b29eddf8..ccdb25ef60e 100644 --- a/lisp/emacs-lisp/easy-mmode.el +++ b/lisp/emacs-lisp/easy-mmode.el @@ -95,10 +95,18 @@ if ARG is `toggle'; disable the mode otherwise.") \\{%s}" mode-pretty-name keymap-sym)))) (if (string-match-p "\\bARG\\b" doc) doc - (let ((argdoc (format easy-mmode--arg-docstring - mode-pretty-name))) + (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)) + (filled (if (fboundp 'fill-region) + (with-temp-buffer + (insert argdoc) + (fill-region (point-min) (point-max) 'left t) + (buffer-string)) + argdoc))) (replace-regexp-in-string "\\(\n\n\\|\\'\\)\\(.\\|\n\\)*\\'" - (concat argdoc "\\1") + (concat filled "\\1") doc nil nil 1))))) ;;;###autoload |