mirror of
https://github.com/golang/go.git
synced 2025-05-30 19:52:53 +00:00
misc/emacs: support godef-jump on import statements
The newest version of godef supports jumping to a package's source directory if point is on an import statement. R=adonovan CC=golang-dev https://golang.org/cl/18230043
This commit is contained in:
parent
7dbbb53f37
commit
3b0e6c21ae
@ -950,11 +950,12 @@ will be commented, otherwise they will be removed completely."
|
|||||||
"Given a file name in the format of `filename:line:column',
|
"Given a file name in the format of `filename:line:column',
|
||||||
visit FILENAME and go to line LINE and column COLUMN."
|
visit FILENAME and go to line LINE and column COLUMN."
|
||||||
(if (not (string-match "\\(.+\\):\\([0-9]+\\):\\([0-9]+\\)" specifier))
|
(if (not (string-match "\\(.+\\):\\([0-9]+\\):\\([0-9]+\\)" specifier))
|
||||||
(error "Unexpected godef output: %s" specifier)
|
;; We've only been given a directory name
|
||||||
|
(funcall (if other-window #'find-file-other-window #'find-file) specifier)
|
||||||
(let ((filename (match-string 1 specifier))
|
(let ((filename (match-string 1 specifier))
|
||||||
(line (string-to-number (match-string 2 specifier)))
|
(line (string-to-number (match-string 2 specifier)))
|
||||||
(column (string-to-number (match-string 3 specifier))))
|
(column (string-to-number (match-string 3 specifier))))
|
||||||
(with-current-buffer (funcall (if other-window 'find-file-other-window 'find-file) filename)
|
(with-current-buffer (funcall (if other-window #'find-file-other-window #'find-file) filename)
|
||||||
(go--goto-line line)
|
(go--goto-line line)
|
||||||
(beginning-of-line)
|
(beginning-of-line)
|
||||||
(forward-char (1- column))
|
(forward-char (1- column))
|
||||||
@ -1008,6 +1009,8 @@ description at POINT."
|
|||||||
(message "%s" file))
|
(message "%s" file))
|
||||||
((go--string-prefix-p "godef: no declaration found for " file)
|
((go--string-prefix-p "godef: no declaration found for " file)
|
||||||
(message "%s" file))
|
(message "%s" file))
|
||||||
|
((go--string-prefix-p "error finding import path for " file)
|
||||||
|
(message "%s" file))
|
||||||
(t
|
(t
|
||||||
(push-mark)
|
(push-mark)
|
||||||
(ring-insert find-tag-marker-ring (point-marker))
|
(ring-insert find-tag-marker-ring (point-marker))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user