Subject: Re: bug#24622: 26.0.50; lisp-fill-paragraph broken

From: Alex <[email-masked]>
Date: Thu, 12 Oct 2017 20:23:01 -0600

martin rudalics <[email-masked]> writes:

> This commit
>
> commit 866e3c050fe64fee81f29a335a50a11b2562422e
> Author: Lars Ingebrigtsen <[email-masked]>
> Date:   Thu Apr 28 12:05:15 2016 +0200
>
>     Don't consider colons to be paragraphs starting chars in strings
>
>     * lisp/emacs-lisp/lisp-mode.el (lisp-fill-paragraph): Don't
>     consider colons to start paragraphs in (doc) strings
>     (bug#7751).
>
> breaks filling doc-strings of defcustoms.  As an example consider the
> defcustom of ‘window-min-height’ in window.el:

I've included a diff below that appears to solve both bug#7751 and this
one, though I can't guarantee that it doesn't blow something else up.
Does anyone have any complaints?

In any case, I think this bug should be solved before 26.1 is released.

diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index fd12635d85..93435e1b4b 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -1267,7 +1267,8 @@ lisp-fill-paragraph
       ;; case).  The `;' and `:' stop the paragraph being filled at following
       ;; comment lines and at keywords (e.g., in `defcustom').  Left parens are
       ;; escaped to keep font-locking, filling, & paren matching in the source
-      ;; file happy.
+      ;; file happy.  The `:' must be preceded by whitespace so that keywords
+      ;; inside of the docstring don't start new paragraphs (Bug#7751).
       ;;
       ;; `paragraph-separate': A clever regexp distinguishes the first line of
       ;; a docstring and identifies it as a paragraph separator, so that it
@@ -1280,13 +1281,7 @@ lisp-fill-paragraph
       ;; `emacs-lisp-docstring-fill-column' if that value is an integer.
       (let ((paragraph-start
              (concat paragraph-start
-                     (format "\\|\\s-*\\([(;%s\"]\\|`(\\|#'(\\)"
-                             ;; If we're inside a string (like the doc
-                             ;; string), don't consider a colon to be
-                             ;; a paragraph-start character.
-                             (if (nth 3 (syntax-ppss))
-                                 ""
-                               ":"))))
+                     "\\|\\s-*\\([(;\"]\\|\\s-:\\|`(\\|#'(\\)"))
 	    (paragraph-separate
 	     (concat paragraph-separate "\\|\\s-*\".*[,\\.]$"))
             (fill-column (if (and (integerp emacs-lisp-docstring-fill-column)