emacs-diffs
[Top][All Lists]
Advanced

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

master 9bf367e: Improve filling of Emacs Lisp doc strings


From: Lars Ingebrigtsen
Subject: master 9bf367e: Improve filling of Emacs Lisp doc strings
Date: Thu, 4 Feb 2021 10:14:50 -0500 (EST)

branch: master
commit 9bf367e18486b8f89ff1e0a4c4f4b5b4da4d9a75
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Improve filling of Emacs Lisp doc strings
    
    * lisp/emacs-lisp/lisp-mode.el (lisp-fill-paragraph): When filling
    a Lisp string, try to avoid filling bits that follow it
    (bug#28937).
---
 lisp/emacs-lisp/lisp-mode.el | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index 5dda3a8..f5ce107 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -1373,7 +1373,24 @@ and initial semicolons."
                                   (derived-mode-p 'emacs-lisp-mode))
                              emacs-lisp-docstring-fill-column
                            fill-column)))
-       (fill-paragraph justify))
+        (save-restriction
+          (save-excursion
+          (let ((ppss (syntax-ppss)))
+            ;; If we're in a string, then narrow (roughly) to that
+            ;; string before filling.  This avoids filling Lisp
+            ;; statements that follow the string.
+            (when (ppss-string-terminator ppss)
+              (goto-char (ppss-comment-or-string-start ppss))
+              (beginning-of-line)
+              ;; The string may be unterminated -- in that case, don't
+              ;; narrow.
+              (when (ignore-errors
+                      (progn
+                        (forward-sexp 1)
+                        t))
+                (narrow-to-region (ppss-comment-or-string-start ppss)
+                                  (point))))
+           (fill-paragraph justify)))))
       ;; Never return nil.
       t))
 



reply via email to

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