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: Mon, 10 Jun 2019 15:35:12 +0200

On Mon, Jun 10, 2019 at 12:21 PM Basil L. Contovounesios
<address@hidden> wrote:

> FWIW, I find this useful.

Thanks.

> My only questions are a) whether we'd want to
> introduce optional docstring filling more systematically, e.g. during
> *Help* buffer generation,

I don't think so. Usually, docstrings are hand-crafted to be readable,
and random-filling them isn't going to be an improvement per se. In
this specific case, the docstring is mostly auto-generated, with
variable substitution, so filling *is* an improvement. But not
generally.

> and b) whether the fill-column can be
> controlled by emacs-lisp-docstring-fill-column or some new user option
> along the same lines.

IMO, a new option would be unnecessary clutter, but using
emacs-lisp-docstring-fill-column is a good idea. Thanks.


diff --git i/lisp/emacs-lisp/easy-mmode.el w/lisp/emacs-lisp/easy-mmode.el
index be531aab84..2cfbe726e5 100644
--- i/lisp/emacs-lisp/easy-mmode.el
+++ w/lisp/emacs-lisp/easy-mmode.el
@@ -96,9 +96,16 @@ easy-mmode--mode-docstring
     (if (string-match-p "\\bARG\\b" doc)
         doc
-      (let ((argdoc (format easy-mmode--arg-docstring
+      (let ((fill-prefix nil)
+            (fill-column (if (integerp emacs-lisp-docstring-fill-column)
+                             emacs-lisp-docstring-fill-column
+                           65)) ; default value of e-l-d-f-c
+            (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]