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

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

[nongnu] elpa/go-mode 8fb900e 062/495: refactor


From: ELPA Syncer
Subject: [nongnu] elpa/go-mode 8fb900e 062/495: refactor
Date: Sat, 7 Aug 2021 09:04:44 -0400 (EDT)

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

    refactor
---
 go-mode.el | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/go-mode.el b/go-mode.el
index 7559966..bea6c15 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -149,6 +149,15 @@ built-ins, functions, and some types.")
     (go--backward-irrelevant t)
     (looking-back go-dangling-operators-regexp)))
 
+(defun go-goto-opening-parenthesis ()
+  (let ((start-nesting (go-paren-level)))
+    (while (and (not (bobp))
+                (>= (go-paren-level) start-nesting))
+      (if (= 0 (skip-chars-backward "^[{("))
+          (if (go-in-string-or-comment-p)
+              (go-goto-beginning-of-string-or-comment)
+            (backward-char))))))
+
 (defun go-indentation-at-point (point)
   (save-excursion
     (let (start-nesting (outindent 0))
@@ -159,10 +168,7 @@ built-ins, functions, and some types.")
         (setq start-nesting (go-paren-level))
         (if (looking-at "[])}]")
             (progn
-              (while (and (not (bobp))
-                          (>= (go-paren-level) start-nesting))
-                (skip-chars-backward "^[]{}()")
-                (backward-char))
+              (go-goto-opening-parenthesis)
               (if (go-previous-line-has-dangling-op-p)
                   (- (current-indentation) tab-width)
                 (current-indentation)))
@@ -175,12 +181,7 @@ built-ins, functions, and some types.")
             (go--backward-irrelevant)
             (if (= (go-paren-level) 0)
                 0
-              (while (and (not (bobp))
-                          (>= (go-paren-level) start-nesting))
-                (if (= 0 (skip-chars-backward "^[]{}()"))
-                    (backward-char))
-                (if (go-in-string-p)
-                    (go--backward-irrelevant)))
+              (go-goto-opening-parenthesis)
               (if (< (go-paren-level) start-nesting)
                   (progn
                     (if (go-previous-line-has-dangling-op-p)



reply via email to

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