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

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

[nongnu] elpa/go-mode 846ed32 063/495: optimizations


From: ELPA Syncer
Subject: [nongnu] elpa/go-mode 846ed32 063/495: optimizations
Date: Sat, 7 Aug 2021 09:04:44 -0400 (EDT)

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

    optimizations
---
 go-mode.el | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/go-mode.el b/go-mode.el
index bea6c15..af962e5 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -149,11 +149,14 @@ 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)))
+(defun go-goto-opening-parenthesis (&optional char)
+  (let ((start-nesting (go-paren-level)) group)
+    (if char
+        (setq group (case char (?\] "^[") (?\} "^{") (?\) "^(")))
+      (setq group "^[{("))
     (while (and (not (bobp))
                 (>= (go-paren-level) start-nesting))
-      (if (= 0 (skip-chars-backward "^[{("))
+      (if (= 0 (skip-chars-backward group))
           (if (go-in-string-or-comment-p)
               (go-goto-beginning-of-string-or-comment)
             (backward-char))))))
@@ -168,7 +171,7 @@ built-ins, functions, and some types.")
         (setq start-nesting (go-paren-level))
         (if (looking-at "[])}]")
             (progn
-              (go-goto-opening-parenthesis)
+              (go-goto-opening-parenthesis (char-after))
               (if (go-previous-line-has-dangling-op-p)
                   (- (current-indentation) tab-width)
                 (current-indentation)))



reply via email to

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