emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/go-mode 4f15abf 449/495: Fix fill-paragraph for certain bl


From: ELPA Syncer
Subject: [nongnu] elpa/go-mode 4f15abf 449/495: Fix fill-paragraph for certain block comments.
Date: Sat, 7 Aug 2021 09:06:06 -0400 (EDT)

branch: elpa/go-mode
commit 4f15abf0e8822c24e45590ef3f161e97920568aa
Author: Muir Manders <muir@mnd.rs>
Commit: Peter Sanford <psanford@sanford.io>

    Fix fill-paragraph for certain block comments.
    
    We weren't filling cases like this properly:
    
    /*
       Hello I am
         an important comment.
    */
    
    Now we properly detect the fill prefix that precedes "Hello".
---
 go-mode.el                     | 21 ++++++++++++++-------
 test/go-fill-paragraph-test.el | 22 ++++++++++++++++++++++
 2 files changed, 36 insertions(+), 7 deletions(-)

diff --git a/go-mode.el b/go-mode.el
index a5a6890..85d1bf5 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -656,13 +656,20 @@ case keyword. It returns nil for the case line itself."
             (or (go--empty-line-p) (go--boring-comment-p))
             (zerop (forward-line 1))))
 
-    ;; If we are looking at the start of an interesting comment, our
-    ;; prefix is the comment opener and any space following.
-    (if (looking-at (concat go--comment-start-regexp "[[:space:]]*"))
-        ;; Replace "/*" opener with spaces so following lines don't
-        ;; get "/*" prefix.
-        (replace-regexp-in-string "/\\*" "  "
-                                  (match-string-no-properties 0)))))
+    ;; If we are in a block comment, set prefix based on first line
+    ;; with content.
+    (if (go-in-comment-p)
+        (progn
+          (looking-at "[[:space:]]*")
+          (match-string-no-properties 0))
+
+      ;; Else if we are looking at the start of an interesting comment, our
+      ;; prefix is the comment opener and any space following.
+      (if (looking-at (concat go--comment-start-regexp "[[:space:]]*"))
+          ;; Replace "/*" opener with spaces so following lines don't
+          ;; get "/*" prefix.
+          (replace-regexp-in-string "/\\*" "  "
+                                    (match-string-no-properties 0))))))
 
 (defun go--fill-paragraph (&rest args)
   "Wrap fill-paragraph to set custom fill-prefix."
diff --git a/test/go-fill-paragraph-test.el b/test/go-fill-paragraph-test.el
index 7a2c34e..5775018 100644
--- a/test/go-fill-paragraph-test.el
+++ b/test/go-fill-paragraph-test.el
@@ -127,6 +127,28 @@ func main() {
 }"
    ))
 
+
+(ert-deftest go--fill-paragraph-block-offset ()
+  (go--should-fill
+   "
+func main() {
+<>  /*
+       Lorem ipsum dolor sit amet, consectetur adipisicing elit,
+         sed do eiusmod tempor incididunt ut labore
+         et dolore magna aliqua.
+  */
+}"
+
+   "
+func main() {
+  /*
+       Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed
+       do eiusmod tempor incididunt ut labore et dolore magna aliqua.
+  */
+}"
+   ))
+
+
 (ert-deftest go--fill-paragraph-block-region ()
   (go--should-fill
    "



reply via email to

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