branch: elpa/go-mode
commit 004575eb128ab01a11b4a4d278c544f91cf752fd
Author: Yutian Li <[email protected]>
Commit: Dominik Honnef <[email protected]>
Don't leave godef buffer around
Closes: gh-143 [via git-merge-pr]
---
go-mode.el | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/go-mode.el b/go-mode.el
index 8acc0e1..cc6422b 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -1527,25 +1527,25 @@ description at POINT."
(error "godef does not reliably work in XEmacs, expect bad results"))
(if (not (buffer-file-name (go--coverage-origin-buffer)))
(error "Cannot use godef on a buffer without a file name")
- (let ((outbuf (get-buffer-create "*godef*"))
+ (let ((outbuf (generate-new-buffer "*godef*"))
(coding-system-for-read 'utf-8)
(coding-system-for-write 'utf-8))
- (with-current-buffer outbuf
- (erase-buffer))
- (call-process-region (point-min)
- (point-max)
- godef-command
- nil
- outbuf
- nil
- "-i"
- "-t"
- "-f"
- (file-truename (buffer-file-name
(go--coverage-origin-buffer)))
- "-o"
- (number-to-string (go--position-bytes point)))
- (with-current-buffer outbuf
- (split-string (buffer-substring-no-properties (point-min) (point-max))
"\n")))))
+ (prog2
+ (call-process-region (point-min)
+ (point-max)
+ godef-command
+ nil
+ outbuf
+ nil
+ "-i"
+ "-t"
+ "-f"
+ (file-truename (buffer-file-name
(go--coverage-origin-buffer)))
+ "-o"
+ (number-to-string (go--position-bytes point)))
+ (with-current-buffer outbuf
+ (split-string (buffer-substring-no-properties (point-min)
(point-max)) "\n"))
+ (kill-buffer outbuf)))))
(defun godef--successful-p (output)
(not (or (string= "-" output)