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

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

[nongnu] elpa/go-mode d511e35 402/495: Replace obsolete one-argument fo


From: ELPA Syncer
Subject: [nongnu] elpa/go-mode d511e35 402/495: Replace obsolete one-argument form of ‘looking-back’.
Date: Sat, 7 Aug 2021 09:05:56 -0400 (EDT)

branch: elpa/go-mode
commit d511e352c81ccdc08271024104d567b3bd15bf67
Author: Philipp Stephani <phst@google.com>
Commit: Dominik Honnef <dominik@honnef.co>

    Replace obsolete one-argument form of ‘looking-back’.
    
    Replace it with the two-argument form most of the time, except when looking 
at
    exactly one character.
---
 go-mode.el | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/go-mode.el b/go-mode.el
index 3786240..bbd9267 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -69,6 +69,12 @@ function."
 
 
 (defconst go-dangling-operators-regexp "[^-]-\\|[^+]\\+\\|[/*&><.=|^]")
+(defconst go--max-dangling-operator-length 2
+  "The maximum length of dangling operators.
+This must be at least the length of the longest string matched by
+‘go-dangling-operators-regexp.’, and must be updated whenever
+that constant is changed.")
+
 (defconst go-identifier-regexp "[[:word:][:multibyte:]]+")
 (defconst go-type-name-no-prefix-regexp 
"\\(?:[[:word:][:multibyte:]]+\\.\\)?[[:word:][:multibyte:]]+")
 (defconst go-qualified-identifier-regexp (concat go-identifier-regexp "\\." 
go-identifier-regexp))
@@ -495,13 +501,13 @@ STOP-AT-STRING is not true, over strings."
   (let (pos (start-pos (point)))
     (skip-chars-backward "\n\s\t")
     (if (and (save-excursion (beginning-of-line) (go-in-string-p))
-             (looking-back "`")
+             (= (char-before) ?`)
              (not stop-at-string))
         (backward-char))
     (if (and (go-in-string-p)
              (not stop-at-string))
         (go-goto-beginning-of-string-or-comment))
-    (if (looking-back "\\*/")
+    (if (looking-back "\\*/" (line-beginning-position))
         (backward-char))
     (if (go-in-comment-p)
         (go-goto-beginning-of-string-or-comment))
@@ -529,7 +535,8 @@ STOP-AT-STRING is not true, over strings."
         (save-excursion
           (beginning-of-line)
           (go--backward-irrelevant t)
-          (setq val (looking-back go-dangling-operators-regexp))
+          (setq val (looking-back go-dangling-operators-regexp
+                                  (- (point) 
go--max-dangling-operator-length)))
           (if (not (go--buffer-narrowed-p))
               (puthash cur-line val go-dangling-cache))))
     val))
@@ -584,7 +591,9 @@ current line will be returned."
         (if (go-previous-line-has-dangling-op-p)
             (- (current-indentation) tab-width)
           (go--indentation-for-opening-parenthesis)))
-       ((progn (go--backward-irrelevant t) (looking-back 
go-dangling-operators-regexp))
+       ((progn (go--backward-irrelevant t)
+               (looking-back go-dangling-operators-regexp
+                             (- (point) go--max-dangling-operator-length)))
         ;; only one nesting for all dangling operators in one operation
         (if (go-previous-line-has-dangling-op-p)
             (current-indentation)
@@ -659,7 +668,8 @@ current line will be returned."
       (skip-chars-forward "^{")
       (forward-char)
       (or (go-in-string-or-comment-p)
-          (looking-back "\\(struct\\|interface\\)\\s-*{"))))
+          (looking-back "\\(struct\\|interface\\)\\s-*{"
+                        (line-beginning-position)))))
     (setq orig-level (go-paren-level))
     (while (>= (go-paren-level) orig-level)
       (skip-chars-forward "^}")
@@ -1714,7 +1724,8 @@ If ARG is non-nil, anonymous functions are ignored."
            (skip-chars-forward "^{")
            (forward-char)
            (or (go-in-string-or-comment-p)
-               (looking-back "\\(struct\\|interface\\)\\s-*{"))))
+               (looking-back "\\(struct\\|interface\\)\\s-*{"
+                             (line-beginning-position)))))
   (backward-char))
 
 (defun go--in-function-p (compare-point)



reply via email to

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