branch: elpa/go-mode
commit 3fdac0816abb5b71e7b2a8d079b87430bdf20fef
Author: Felix Lange <[email protected]>
Commit: Dominik Honnef <[email protected]>

    use quit-window to hide the gofmt error window
    
    gofmt pops up a window to display syntax error messages. When one fixes
    those errors and re-runs gofmt, the window shouldn't stay open. Note
    that quit-window will only delete the window if it was opened
    specifically for the *Gofmt Errors* buffer.
---
 AUTHORS    |  1 +
 go-mode.el | 10 ++++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index 37c8d16..edea4ad 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -7,6 +7,7 @@ Charles Lee <[email protected]>
 Dominik Honnef <[email protected]>
 Eric Eisner <[email protected]>
 Evan Martin <[email protected]>
+Felix Lange <[email protected]>
 Florian Weimer <[email protected]>
 Istvan Marko <[email protected]>
 James Aguilar <[email protected]>
diff --git a/go-mode.el b/go-mode.el
index 09408a8..fad9e31 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -966,7 +966,7 @@ buffer."
                 (message "Buffer is already gofmted")
               (go--apply-rcs-patch patchbuf)
               (message "Applied gofmt"))
-            (if errbuf (kill-buffer errbuf)))
+            (if errbuf (gofmt--kill-error-buffer errbuf)))
         (message "Could not apply gofmt")
         (if errbuf (gofmt--process-errors (buffer-file-name) tmpfile errbuf)))
 
@@ -979,7 +979,7 @@ buffer."
     (if (eq gofmt-show-errors 'echo)
         (progn
           (message "%s" (buffer-string))
-          (kill-buffer errbuf))
+          (gofmt--kill-error-buffer errbuf))
       ;; Convert the gofmt stderr to something understood by the compilation 
mode.
       (goto-char (point-min))
       (insert "gofmt errors:\n")
@@ -988,6 +988,12 @@ buffer."
       (compilation-mode)
       (display-buffer errbuf))))
 
+(defun gofmt--kill-error-buffer (errbuf)
+  (let ((win (get-buffer-window errbuf)))
+    (if win
+        (quit-window t win)
+      (kill-buffer errbuf))))
+
 ;;;###autoload
 (defun gofmt-before-save ()
   "Add this to .emacs to run gofmt on the current buffer when saving:

Reply via email to