1
0
mirror of https://github.com/golang/go synced 2024-11-18 10:54:40 -07:00

cmd/guru: emacs: push mark in go-guru-definition

This allows users to swap point and mark to jump between use and
definition in the same buffer, or pop-tag-mark (M-*) to jump back to the
use even between multiple buffers.

This mirrors the behaviour of godef-jump from go-mode.

Also remove an obosolete TODO and fix a typo.

Change-Id: I614090493b565acadf359ebb4c7092f4c673fd56
Reviewed-on: https://go-review.googlesource.com/20303
Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
Dominik Honnef 2016-03-07 13:34:47 +01:00 committed by Alan Donovan
parent 459f0c0f73
commit adda3a6894

View File

@ -65,13 +65,6 @@
(define-key go-mode-map (kbd "C-c C-o") #'go-guru-map) (define-key go-mode-map (kbd "C-c C-o") #'go-guru-map)
;; TODO(dominikh): Rethink set-scope some. Setting it to a file is
;; painful because it doesn't use find-file, and variables/~ aren't
;; expanded. Setting it to an import path is somewhat painful because
;; it doesn't make use of go-mode's import path completion. One option
;; would be having two different functions, but then we can't
;; automatically call it when no scope has been set. Also it wouldn't
;; easily allow specifying more than one file/package.
;;;###autoload ;;;###autoload
(defun go-guru-set-scope () (defun go-guru-set-scope ()
"Set the scope for the Go guru, prompting the user to edit the "Set the scope for the Go guru, prompting the user to edit the
@ -100,7 +93,7 @@ specify to 'go build'."
(defun go-guru--run (mode &optional need-scope) (defun go-guru--run (mode &optional need-scope)
"Run the Go guru in the specified MODE, passing it the selected "Run the Go guru in the specified MODE, passing it the selected
region of the current buffer. If NEED-SCOPE, prompt for a scope region of the current buffer. If NEED-SCOPE, prompt for a scope
if not already set. Mark up the output using `compilation-node`, if not already set. Mark up the output using `compilation-mode`,
replacing each file name with a small hyperlink, and display the replacing each file name with a small hyperlink, and display the
result." result."
(with-current-buffer (go-guru--exec mode need-scope) (with-current-buffer (go-guru--exec mode need-scope)
@ -167,7 +160,7 @@ a scope if not already set. Return the output buffer."
(insert "\n") (insert "\n")
(compilation-mode) (compilation-mode)
(setq compilation-error-screen-columns nil) (setq compilation-error-screen-columns nil)
;; Hide the file/line info to save space. ;; Hide the file/line info to save space.
;; Replace each with a little widget. ;; Replace each with a little widget.
;; compilation-mode + this loop = slooow. ;; compilation-mode + this loop = slooow.
@ -196,7 +189,7 @@ a scope if not already set. Return the output buffer."
(incf np))) ; so we don't get stuck (e.g. on a panic stack dump) (incf np))) ; so we don't get stuck (e.g. on a panic stack dump)
(setq p np))) (setq p np)))
(message nil)) (message nil))
(let ((w (display-buffer (current-buffer)))) (let ((w (display-buffer (current-buffer))))
(set-window-point w (point-min)))) (set-window-point w (point-min))))
@ -267,6 +260,8 @@ function containing the current point."
(goto-char (point-min)) (goto-char (point-min))
(cdr (car (json-read))))) (cdr (car (json-read)))))
(desc (cdr (assoc 'desc res)))) (desc (cdr (assoc 'desc res))))
(push-mark)
(ring-insert find-tag-marker-ring (point-marker))
(go-guru--goto-pos (cdr (assoc 'objpos res))) (go-guru--goto-pos (cdr (assoc 'objpos res)))
(message "%s" desc))) (message "%s" desc)))