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

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

[nongnu] elpa/go-mode b5960fe 099/495: nicer messages in gofmt


From: ELPA Syncer
Subject: [nongnu] elpa/go-mode b5960fe 099/495: nicer messages in gofmt
Date: Sat, 7 Aug 2021 09:04:51 -0400 (EDT)

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

    nicer messages in gofmt
---
 go-mode.el | 33 +++++++++++++++++++--------------
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/go-mode.el b/go-mode.el
index 9d4ee10..1c4ca30 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -412,6 +412,7 @@ Replace the current buffer on success; display errors on 
failure."
                         (set-window-configuration currconf))
 
                     ;; gofmt failed: display the errors
+                    (message "Could not apply gofmt. Check errors for details")
                     (gofmt--process-errors filename errbuf))))))
 
           ;; Collapse any window opened on outbuf if shell-command-on-region
@@ -422,23 +423,27 @@ Replace the current buffer on success; display errors on 
failure."
 (defun gofmt--replace-buffer (srcbuf patchbuf)
   (with-current-buffer srcbuf
     (erase-buffer)
-    (insert-buffer-substring patchbuf)))
+    (insert-buffer-substring patchbuf))
+  (message "Applied gofmt"))
 
 (defun gofmt--apply-patch (filename srcbuf patchbuf)
   ;; apply all the patch hunks
-  (with-current-buffer patchbuf
-    (goto-char (point-min))
-    ;; The .* is for TMPDIR, but to avoid dealing with TMPDIR
-    ;; having a trailing / or not, it's easier to just search for .*
-    ;; especially as we're only replacing the first instance.
-    (if (re-search-forward "^--- \\(.*/gofmt[0-9]*\\)" nil t)
-        (replace-match filename nil nil nil 1))
-    (condition-case nil
-        (while t
-          (diff-hunk-next)
-          (diff-apply-hunk))
-      ;; When there's no more hunks, diff-hunk-next signals an error, ignore it
-      (error nil))))
+  (let (changed)
+    (with-current-buffer patchbuf
+      (goto-char (point-min))
+      ;; The .* is for TMPDIR, but to avoid dealing with TMPDIR
+      ;; having a trailing / or not, it's easier to just search for .*
+      ;; especially as we're only replacing the first instance.
+      (if (re-search-forward "^--- \\(.*/gofmt[0-9]*\\)" nil t)
+          (replace-match filename nil nil nil 1))
+      (condition-case nil
+          (while t
+            (diff-hunk-next)
+            (diff-apply-hunk)
+            (setq changed t))
+        ;; When there's no more hunks, diff-hunk-next signals an error, ignore 
it
+        (error nil)))
+    (if changed (message "Applied gofmt") (message "Buffer was already 
gofmted"))))
 
 (defun gofmt--process-errors (filename errbuf)
   ;; Convert the gofmt stderr to something understood by the compilation mode.



reply via email to

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