1
0
mirror of https://github.com/golang/go synced 2024-11-18 09:04:49 -07:00

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 <adonovan@google.com>
This commit is contained in:
Dominik Honnef 2016-03-09 14:51:31 +01:00 committed by Alan Donovan
parent 5c5d833208
commit 999f507100

View File

@ -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.