code review 9762045: go-mode: fix godef-jump on Windows. (issue 9762045)

35 views
Skip to first unread message

zombi...@gmail.com

unread,
May 24, 2013, 11:45:40 PM5/24/13
to golan...@googlegroups.com, dominik...@gmail.com, re...@codereview-hr.appspotmail.com
Reviewers: golang-dev1,

Message:
Hello golan...@googlegroups.com (cc: dominik...@gmail.com),

I'd like you to review this change to
https://code.google.com/p/go


Description:
go-mode: fix godef-jump on Windows.

Fixes issue 5555.

Please review this at https://codereview.appspot.com/9762045/

Affected files:
M misc/emacs/go-mode.el


Index: misc/emacs/go-mode.el
===================================================================
--- a/misc/emacs/go-mode.el
+++ b/misc/emacs/go-mode.el
@@ -873,16 +873,18 @@
(defun godef--find-file-line-column (specifier)
"Given a file name in the format of `filename:line:column',
visit FILENAME and go to line LINE and column COLUMN."
- (let* ((components (split-string specifier ":"))
- (line (string-to-number (nth 1 components)))
- (column (string-to-number (nth 2 components))))
- (with-current-buffer (find-file (car components))
- (goto-char (point-min))
- (forward-line (1- line))
- (beginning-of-line)
- (forward-char (1- column))
- (if (buffer-modified-p)
- (message "Buffer is modified, file position might not have been
correct")))))
+ (if (not (string-match "\\(.+\\):\\([0-9]+\\):\\([0-9]+\\)" specifier))
+ (message "Unexpected godef output: %s" specifier)
+ (let ((filename (match-string 1 specifier))
+ (line (string-to-number (match-string 2 specifier)))
+ (column (string-to-number (match-string 3 specifier))))
+ (with-current-buffer (find-file filename)
+ (goto-char (point-min))
+ (forward-line (1- line))
+ (beginning-of-line)
+ (forward-char (1- column))
+ (if (buffer-modified-p)
+ (message "Buffer is modified, file position might not have
been correct"))))))

(defun godef--call (point)
"Call godef, acquiring definition position and expression


dominik...@gmail.com

unread,
May 25, 2013, 7:13:58 AM5/25/13
to zombi...@gmail.com, golan...@googlegroups.com, adon...@google.com, re...@codereview-hr.appspotmail.com
Please change the subject to "misc/emacs: ..." instead of "go-mode: ..."

It works fine for me on Unix, I'll take your word it works on Windows.
Make the remaining changes and it should be good to go.


https://codereview.appspot.com/9762045/diff/3002/misc/emacs/go-mode.el
File misc/emacs/go-mode.el (right):

https://codereview.appspot.com/9762045/diff/3002/misc/emacs/go-mode.el#newcode877
misc/emacs/go-mode.el:877: (message "Unexpected godef output: %s"
specifier)
Use error here, not message. The arguments can stay the same, error uses
a format string, too.

https://codereview.appspot.com/9762045/

go...@golang.org

unread,
May 25, 2013, 1:21:24 PM5/25/13
to zombi...@gmail.com, adon...@google.com, adon...@google.com, golan...@googlegroups.com, dominik...@gmail.com, re...@codereview-hr.appspotmail.com
R=adonovan (assigned by r)

https://codereview.appspot.com/9762045/
Reply all
Reply to author
Forward
0 new messages