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

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

[nongnu] elpa/go-mode a6717a1 318/495: Fix filename replacement in gofmt


From: ELPA Syncer
Subject: [nongnu] elpa/go-mode a6717a1 318/495: Fix filename replacement in gofmt error buffer
Date: Sat, 7 Aug 2021 09:05:39 -0400 (EDT)

branch: elpa/go-mode
commit a6717a1bd9b5cdbec861f77e577301260c8d257b
Author: Will <will@glozer.net>
Commit: Dominik Honnef <dominik@honnef.co>

    Fix filename replacement in gofmt error buffer
    
    goimport's new -srcdir option rewrites the directory but not the
    filename causing the regexp search & replace to fail
    
    Closes: gh-129
    Closes: gh-130 [via git-merge-pr]
---
 AUTHORS    | 1 +
 go-mode.el | 8 ++++++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index 75f1cc9..eefc714 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -32,4 +32,5 @@ Scott Lawrence <bytbox@gmail.com>
 Steven Elliot Harris <seharris@gmail.com>
 Taiki Sugawara <buzz.taiki@gmail.com>
 Viacheslav Chimishuk <vchimishuk@yandex-team.ru>
+Will <will@glozer.net>
 Yasuyuki Oka <yasuyk@gmail.com>
diff --git a/go-mode.el b/go-mode.el
index dac2a38..f3ca05e 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -1117,8 +1117,12 @@ with goflymake \(see URL 
`https://github.com/dougm/goflymake'), gocode
               (search-forward "flag provided but not defined: -srcdir" nil t)))
           (insert "Your version of goimports is too old and doesn't support 
vendoring. Please update goimports!\n\n"))
       (insert "gofmt errors:\n")
-      (while (search-forward-regexp (concat "^\\(" (regexp-quote tmpfile) 
"\\):") nil t)
-        (replace-match (file-name-nondirectory filename) t t nil 1))
+      (let ((truefile
+             (if (gofmt--is-goimports-p)
+                 (concat (file-name-directory filename) 
(file-name-nondirectory tmpfile))
+               tmpfile)))
+        (while (search-forward-regexp (concat "^\\(" (regexp-quote truefile) 
"\\):") nil t)
+          (replace-match (file-name-nondirectory filename) t t nil 1)))
       (compilation-mode)
       (display-buffer errbuf))))
 



reply via email to

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