From 999f50710050053de9ee43a7f3f4ae7651c184c4 Mon Sep 17 00:00:00 2001 From: Dominik Honnef Date: Wed, 9 Mar 2016 14:51:31 +0100 Subject: [PATCH] cmd/guru: emacs: store output in separate buffer Now that we have both interactive and non-interactive uses of the guru, we should separate the command output buffer from the display buffer. Change-Id: I50082fdc3847c7b12869e204509141e906df3852 Reviewed-on: https://go-review.googlesource.com/20473 Reviewed-by: Alan Donovan --- cmd/guru/go-guru.el | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/cmd/guru/go-guru.el b/cmd/guru/go-guru.el index ec4fa8efea..7d8ad655bf 100644 --- a/cmd/guru/go-guru.el +++ b/cmd/guru/go-guru.el @@ -118,8 +118,13 @@ region of the current buffer. If NEED-SCOPE, prompt for a scope if not already set. Mark up the output using `compilation-mode`, replacing each file name with a small hyperlink, and display the result." - (with-current-buffer (go-guru--exec mode need-scope) - (go-guru--compilation-markup))) + (let ((output (go-guru--exec mode need-scope)) + (display (get-buffer-create "*go-guru*"))) + (with-current-buffer display + (setq buffer-read-only nil) + (erase-buffer) + (insert-buffer-substring output) + (go-guru--compilation-markup)))) (defun go-guru--exec (mode &optional need-scope flags allow-unnamed) "Execute the Go guru in the specified MODE, passing it the @@ -151,7 +156,7 @@ Return the output buffer." (env-vars (go-root-and-paths)) (goroot-env (concat "GOROOT=" (car env-vars))) (gopath-env (concat "GOPATH=" (mapconcat #'identity (cdr env-vars) ":"))) - (output-buffer (get-buffer-create "*go-guru*")) + (output-buffer (get-buffer-create "*go-guru-output*")) (buf (current-buffer))) (with-current-buffer output-buffer (setq buffer-read-only nil) @@ -192,6 +197,7 @@ Return the output buffer." (defun go-guru--compilation-markup () "Present guru output in the current buffer using `compilation-mode'." + (goto-char (point-max)) (insert "\n") (compilation-mode) (setq compilation-error-screen-columns nil) @@ -438,12 +444,6 @@ timeout." (defun go-guru--hl-identifiers-before-change-function (_beg _end) (go-guru-unhighlight-identifiers)) -;; FIXME(dominikh): currently we're using the same buffer for -;; interactive and non-interactive output. E.g. if a user ran the -;; referrers query, and then the hl-identifier timer ran a what query, -;; the what query's json response would be visible and overwrite the -;; referrers output - ;; TODO(dominikh): a future feature may be to cycle through all uses ;; of an identifier.