]> git.eshelyaron.com Git - emacs.git/commitdiff
Improve docstrings auto-generated by `define-minor-mode'
authorJuanma Barranquero <lekktu@gmail.com>
Fri, 4 Oct 2019 22:31:17 +0000 (00:31 +0200)
committerJuanma Barranquero <lekktu@gmail.com>
Fri, 4 Oct 2019 22:31:17 +0000 (00:31 +0200)
* 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'.

lisp/emacs-lisp/easy-mmode.el

index 5e7b29eddf8b2cec9396fc6af055afb031758046..ccdb25ef60e59c1b4dae7d270347658c4b460680 100644 (file)
@@ -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