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

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

[nongnu] elpa/go-mode 775c77a 241/495: immediately store match data in g


From: ELPA Syncer
Subject: [nongnu] elpa/go-mode 775c77a 241/495: immediately store match data in go-unused-imports-lines
Date: Sat, 7 Aug 2021 09:05:23 -0400 (EDT)

branch: elpa/go-mode
commit 775c77a1b32e6012c55c59a8195483aff9f5bed4
Author: Iwasaki Yudai <yudai.iwasaki@ntti3.com>
Commit: Dominik Honnef <dominik@honnef.co>

    immediately store match data in go-unused-imports-lines
    
    Calling other functions, such as file-truename in our case, can
    overwrite the match data.
---
 go-mode.el | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/go-mode.el b/go-mode.el
index fca4937..132a4cd 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -1311,9 +1311,11 @@ If IGNORE-CASE is non-nil, the comparison is 
case-insensitive."
   (reverse (remove nil
                    (mapcar
                     (lambda (line)
-                      (if (string-match "^\\(.+\\):\\([[:digit:]]+\\): 
imported and not used: \".+\".*$" line)
-                          (if (string= (file-truename (match-string 1 line)) 
(file-truename buffer-file-name))
-                              (string-to-number (match-string 2 line)))))
+                      (when (string-match "^\\(.+\\):\\([[:digit:]]+\\): 
imported and not used: \".+\".*$" line)
+                        (let ((error-file-name (match-string 1 line))
+                              (error-line-num (match-string 2 line)))
+                          (if (string= (file-truename error-file-name) 
(file-truename buffer-file-name))
+                              (string-to-number error-line-num)))))
                     (split-string (shell-command-to-string
                                    (concat go-command
                                            (if (string-match "_test\.go$" 
buffer-file-truename)



reply via email to

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