emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Filling the docstring generated by define-minor-mode


From: Juanma Barranquero
Subject: Re: Filling the docstring generated by define-minor-mode
Date: Tue, 1 Oct 2019 22:23:52 +0200

Revisiting this issue...

I proposed to automatically refill the docstrings that are auto-generated by define-minor-mode. Hand-crafted docstrings, or other doc strings outside define-minor-mode's ones are not affected.

Obviously, as the one who proposed it, I think this is a good change for that particular problem (and that particular problem *only*), regardless of whether we will want to add more formatting or refilling capabilities for docstrings in the future. 

So I'd like to get a definite "ok" or "not ok" to close this issue.


diff --git i/lisp/emacs-lisp/easy-mmode.el w/lisp/emacs-lisp/easy-mmode.el
index be531aab84..fe89ed1754 100644
--- i/lisp/emacs-lisp/easy-mmode.el
+++ w/lisp/emacs-lisp/easy-mmode.el
@@ -96,9 +96,15 @@ easy-mmode--mode-docstring
     (if (string-match-p "\\bARG\\b" doc)
         doc
-      (let ((argdoc (format easy-mmode--arg-docstring
+      (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)))
-        (replace-regexp-in-string "\\(\n\n\\|\\'\\)\\(.\\|\n\\)*\\'"
-                                  (concat argdoc "\\1")
-                                  doc nil nil 1)))))
+        (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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]