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

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

[nongnu] elpa/go-mode 087f58f 043/495: don't expect a line end after lab


From: ELPA Syncer
Subject: [nongnu] elpa/go-mode 087f58f 043/495: don't expect a line end after labels or cases
Date: Sat, 7 Aug 2021 09:04:40 -0400 (EDT)

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

    don't expect a line end after labels or cases
    
    Of course there can be comments after cases and labels
---
 go-mode.el                  |  8 ++++----
 indentation_tests/labels.go | 11 +++++++++++
 indentation_tests/switch.go | 13 +++++++++++++
 3 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/go-mode.el b/go-mode.el
index d22febf..f597dfe 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -135,7 +135,7 @@ built-ins, functions, and some types.")
         (go-goto-beginning-of-string-or-comment))
     (setq pos (point))
     (beginning-of-line)
-    (if (or (looking-at "^[[:word:]]+:$") (looking-at "^[[:space:]]*\\(case 
.+\\|default\\):"))
+    (if (or (looking-at "^[[:word:]]+:") (looking-at "^[[:space:]]*\\(case 
.+\\|default\\):"))
         (progn (forward-line -1)
                (end-of-line))
       (goto-char pos))
@@ -202,11 +202,11 @@ built-ins, functions, and some types.")
         (pos (- (point-max) (point)))
         (beg (progn (beginning-of-line) (point))))
     (back-to-indentation)
-    (if (looking-at "case .+:[[:space:]]*$\\|default:[[:space:]]*$")
+    (if (looking-at "case .+:\\|default:")
         (setq indent (- indent tab-width)))
     (beginning-of-line)
-    (if (and (looking-at "^[[:space:]]*[[:word:]]+:$")
-             (not (looking-at "^[[:space:]]*default:$")))
+    (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)))
diff --git a/indentation_tests/labels.go b/indentation_tests/labels.go
new file mode 100644
index 0000000..a954855
--- /dev/null
+++ b/indentation_tests/labels.go
@@ -0,0 +1,11 @@
+package labels
+
+func main() {
+       code()
+Label:
+       code()
+Label2:
+       code()
+Label3: // Comments!
+       code()
+}
diff --git a/indentation_tests/switch.go b/indentation_tests/switch.go
new file mode 100644
index 0000000..259b293
--- /dev/null
+++ b/indentation_tests/switch.go
@@ -0,0 +1,13 @@
+package _switch
+
+func main() {
+       switch "" {
+       case "foo":
+               code()
+       case "bar":
+       case "baz":
+       case "meow": // some documentation
+       default:
+               code()
+       }
+}



reply via email to

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