emacs-diffs
[Top][All Lists]
Advanced

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

master 7f11dea: Fix filling of overlong first lines in Python doc string


From: Lars Ingebrigtsen
Subject: master 7f11dea: Fix filling of overlong first lines in Python doc strings
Date: Wed, 26 May 2021 19:23:01 -0400 (EDT)

branch: master
commit 7f11dea66298c2c9aeccab2b542ee8e73346f09f
Author: Deneb Meketa <deneb@pixar.com>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Fix filling of overlong first lines in Python doc strings
    
    * lisp/progmodes/python.el (python-fill-string): Fill overlong
    first lines correctly (bug#20860).
    
    Copyright-paperwork-exempt: yes
---
 lisp/progmodes/python.el            |  7 ++++++-
 test/lisp/progmodes/python-tests.el | 24 ++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 20ec339..f7267bd 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -4239,6 +4239,11 @@ JUSTIFY should be used (if applicable) as in 
`fill-paragraph'."
                     (point)))))
          (num-quotes (python-syntax-count-quotes
                       (char-after str-start-pos) str-start-pos))
+         (str-line-start-pos
+          (save-excursion
+            (goto-char str-start-pos)
+            (beginning-of-line)
+            (point-marker)))
          (str-end-pos
           (save-excursion
             (goto-char (+ str-start-pos num-quotes))
@@ -4262,7 +4267,7 @@ JUSTIFY should be used (if applicable) as in 
`fill-paragraph'."
             ('symmetric (and multi-line-p (cons 1 1)))))
          (fill-paragraph-function))
     (save-restriction
-      (narrow-to-region str-start-pos str-end-pos)
+      (narrow-to-region str-line-start-pos str-end-pos)
       (fill-paragraph justify))
     (save-excursion
       (when (and (python-info-docstring-p) python-fill-docstring-style)
diff --git a/test/lisp/progmodes/python-tests.el 
b/test/lisp/progmodes/python-tests.el
index 3e653cb..1af579b 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -5432,6 +5432,30 @@ buffer with overlapping strings."
     (run-python nil nil 'show)
     (should (eq buffer (current-buffer)))))
 
+(ert-deftest python-tests--fill-long-first-line ()
+  (should
+   (equal
+    (with-temp-buffer
+      (insert "def asdf():
+    \"\"\"123 123 123 123 123 123 123 123 123 123 123 123 123 SHOULDBEWRAPPED 
123 123 123 123
+
+    \"\"\"
+    a = 1
+")
+      (python-mode)
+      (goto-char (point-min))
+      (forward-line 1)
+      (end-of-line)
+      (fill-paragraph)
+      (buffer-substring-no-properties (point-min) (point-max)))
+    "def asdf():
+    \"\"\"123 123 123 123 123 123 123 123 123 123 123 123 123
+    SHOULDBEWRAPPED 123 123 123 123
+
+    \"\"\"
+    a = 1
+")))
+
 (provide 'python-tests)
 
 ;; Local Variables:



reply via email to

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