mirror of
https://github.com/golang/go
synced 2024-11-18 12:44:49 -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:
parent
459f0c0f73
commit
adda3a6894
@ -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)
|
||||||
@ -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)))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user