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

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

[nongnu] elpa/go-mode c97dacc 044/495: do not change the indentation of


From: ELPA Syncer
Subject: [nongnu] elpa/go-mode c97dacc 044/495: do not change the indentation of multiline comments
Date: Sat, 7 Aug 2021 09:04:40 -0400 (EDT)

branch: elpa/go-mode
commit c97dacc0ecc2b5ba24e09ff3db750409e48624be
Author: Dominik Honnef <dominikh@fork-bomb.org>
Commit: Dominik Honnef <dominikh@fork-bomb.org>

    do not change the indentation of multiline comments
---
 go-mode.el                             | 46 ++++++++++++++++++----------------
 indentation_tests/multiline_comment.go | 11 ++++++++
 2 files changed, 35 insertions(+), 22 deletions(-)

diff --git a/go-mode.el b/go-mode.el
index f597dfe..039607b 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -196,28 +196,30 @@ built-ins, functions, and some types.")
 
 (defun go-mode-indent-line ()
   (interactive)
-  (let ((indent (go-indentation-at-point (point)))
-        shift-amt
-        end
-        (pos (- (point-max) (point)))
-        (beg (progn (beginning-of-line) (point))))
-    (back-to-indentation)
-    (if (looking-at "case .+:\\|default:")
-        (setq indent (- indent tab-width)))
-    (beginning-of-line)
-    (if (and (looking-at "^[[:space:]]*[[:word:]]+:\\([[:space:]]*/.+\\)?$")
-             (not (looking-at "^[[:space:]]*default:")))
-        (setq indent 0))
-    (skip-chars-forward " \t")
-    (setq shift-amt (- indent (current-column)))
-    (if (zerop shift-amt)
-        nil
-      (delete-region beg (point))
-      (indent-to indent))
-    ;; If initial point was within line's indentation,
-    ;; position after the indentation.  Else stay at same point in text.
-    (if (> (- (point-max) pos) (point))
-        (goto-char (- (point-max) pos)))))
+  (beginning-of-line)
+  (if (not (go-in-comment-p))
+      (let ((indent (go-indentation-at-point (point)))
+            shift-amt
+            end
+            (pos (- (point-max) (point)))
+            (beg (progn (beginning-of-line) (point))))
+        (back-to-indentation)
+        (if (looking-at "case .+:\\|default:")
+            (setq indent (- indent tab-width)))
+        (beginning-of-line)
+        (if (and (looking-at 
"^[[:space:]]*[[:word:]]+:\\([[:space:]]*/.+\\)?$")
+                 (not (looking-at "^[[:space:]]*default:")))
+            (setq indent 0))
+        (skip-chars-forward " \t")
+        (setq shift-amt (- indent (current-column)))
+        (if (zerop shift-amt)
+            nil
+          (delete-region beg (point))
+          (indent-to indent))
+        ;; If initial point was within line's indentation,
+        ;; position after the indentation.  Else stay at same point in text.
+        (if (> (- (point-max) pos) (point))
+            (goto-char (- (point-max) pos))))))
 
 (defun go-beginning-of-defun (&optional count)
   (unless count (setq count 1))
diff --git a/indentation_tests/multiline_comment.go 
b/indentation_tests/multiline_comment.go
new file mode 100644
index 0000000..002f60c
--- /dev/null
+++ b/indentation_tests/multiline_comment.go
@@ -0,0 +1,11 @@
+package multilinecomment
+
+/* Some comment here
+       with my very own
+               indentation as it pleases me */
+
+func main() {
+       if true {
+               // code
+       }
+}



reply via email to

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