unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Filling the docstring generated by define-minor-mode
@ 2019-06-10  4:55 Juanma Barranquero
  2019-06-10 10:21 ` Basil L. Contovounesios
  2019-06-10 17:37 ` Stefan Monnier
  0 siblings, 2 replies; 18+ messages in thread
From: Juanma Barranquero @ 2019-06-10  4:55 UTC (permalink / raw)
  To: Emacs developers

[-- Attachment #1: Type: text/plain, Size: 2000 bytes --]

Currently, in some cases, define-minor-mode generates parts of a minor
mode's doctring, by using easy-mmode--arg-docstring:

  (defconst easy-mmode--arg-docstring
    "

  If called interactively, enable %s if ARG is positive, and
  disable it if ARG is zero or negative.  If called from Lisp,
  also enable the mode if ARG is omitted or nil, and toggle it
  if ARG is `toggle'; disable the mode otherwise.")

and then adding other references to the minor mode's function or variable.

Minor mode's names are often long and the result is quite ugly. An
easy fix is simply filling the docstring afterwards:

diff --git i/lisp/emacs-lisp/easy-mmode.el w/lisp/emacs-lisp/easy-mmode.el
index be531aab84..23f85a3f4f 100644
--- i/lisp/emacs-lisp/easy-mmode.el
+++ w/lisp/emacs-lisp/easy-mmode.el
@@ -96,9 +96,13 @@ 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 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


In the patch above I've used 65 as fill-column because I think it
gives better results for most minor mode's names than the suggested
60. Other values are of course posible, and can be discussed later if
this is deemed useful.

The following images show the docstring for
`display-fill-column-indicator-mode', as it is right now, and after
auto-filling it to 65 columns.

WDYT?

[-- Attachment #2: before.png --]
[-- Type: image/png, Size: 28777 bytes --]

[-- Attachment #3: after.png --]
[-- Type: image/png, Size: 27491 bytes --]

^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2019-10-03 23:30 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-10  4:55 Filling the docstring generated by define-minor-mode Juanma Barranquero
2019-06-10 10:21 ` Basil L. Contovounesios
2019-06-10 13:35   ` Juanma Barranquero
2019-06-10 17:37 ` Stefan Monnier
2019-06-10 18:08   ` Juanma Barranquero
2019-06-10 18:24     ` Drew Adams
2019-06-10 19:26       ` Juanma Barranquero
2019-06-10 20:15         ` Drew Adams
2019-06-10 20:25           ` Juanma Barranquero
2019-06-10 18:33     ` Stefan Monnier
2019-06-10 19:15       ` Juanma Barranquero
2019-06-11  7:14         ` Stefan Monnier
2019-06-11 10:37           ` Juanma Barranquero
2019-06-11 18:19             ` Stefan Monnier
2019-10-01 20:23               ` Juanma Barranquero
2019-10-01 21:04                 ` Lars Ingebrigtsen
2019-10-01 21:51                 ` Stefan Monnier
2019-10-03 23:30                   ` Juanma Barranquero

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).