]> git.eshelyaron.com Git - emacs.git/commitdiff
Improve docstrings auto-generated by `define-minor-mode'
authorJuanma Barranquero <lekktu@gmail.com>
Thu, 3 Oct 2019 23:26:07 +0000 (01:26 +0200)
committerJuanma Barranquero <lekktu@gmail.com>
Thu, 3 Oct 2019 23:26:56 +0000 (01:26 +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..6d5b5141aaf161b3310213eb54475bb3e645b50f 100644 (file)
@@ -95,11 +95,17 @@ 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)))
-        (replace-regexp-in-string "\\(\n\n\\|\\'\\)\\(.\\|\n\\)*\\'"
-                                  (concat argdoc "\\1")
-                                  doc nil nil 1)))))
+      (let* ((fill-prefix nil)
+             (docstring-fc (bound-and-true-p emacs-lisp-docstring-fill-column))
+             (fill-column (if (integerp docstring-fc) docstring-fc 65))
+             (argdoc (format easy-mmode--arg-docstring
+                             mode-pretty-name)))
+        (with-temp-buffer
+          (insert (replace-regexp-in-string "\\(\n\n\\|\\'\\)\\(.\\|\n\\)*\\'"
+                                            (concat argdoc "\\1")
+                                            doc nil nil 1))
+          (fill-region (point-min) (point-max) 'left t)
+          (buffer-string))))))
 
 ;;;###autoload
 (defalias 'easy-mmode-define-minor-mode 'define-minor-mode)