Skip to content

Fix gofmt error handler on non-file buffer #422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions go-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -1241,17 +1241,17 @@ INDENT is the normal indent of this line, i.e. that of the case body."

(defun go-beginning-of-defun (&optional count)
(when (and (not (go-in-string-or-comment-p))
(not (bolp))
(save-excursion
(beginning-of-line)
(looking-at go-func-meth-regexp)))
;; Point is already somewhere on the function definition. Move to the end of line so that searching backwards finds
;; it. We don't go to the end of line unconditionally because that confuses evil-mode
;; (https://github.com/dominikh/go-mode.el/issues/186)
;;
;; If point is already at the beginning of line and looking at a function, then we want go-beginning-of-defun to
;; jump to the previous function instead.
(end-of-line))
(not (bolp))
(save-excursion
(beginning-of-line)
(looking-at go-func-meth-regexp)))
;; Point is already somewhere on the function definition. Move to the end of line so that searching backwards finds
;; it. We don't go to the end of line unconditionally because that confuses evil-mode
;; (https://github.com/dominikh/go-mode.el/issues/186)
;;
;; If point is already at the beginning of line and looking at a function, then we want go-beginning-of-defun to
;; jump to the previous function instead.
(end-of-line))
(setq count (or count 1))
(let (first failure)
(dotimes (i (abs count))
Expand Down Expand Up @@ -1957,7 +1957,7 @@ arguments can be set as a list via ‘gofmt-args’."
(message "Applied gofmt"))
(if errbuf (gofmt--kill-error-buffer errbuf)))
(message "Could not apply gofmt")
(if errbuf (gofmt--process-errors (buffer-file-name) tmpfile errbuf))))
(if errbuf (gofmt--process-errors (or (buffer-file-name) (buffer-name)) tmpfile errbuf))))

(kill-buffer patchbuf)
(delete-file tmpfile))))
Expand Down Expand Up @@ -2384,14 +2384,14 @@ description at POINT."
"Jump to the definition of the expression at POINT."
(interactive "d")
(condition-case nil
(let ((file (car (godef--call point))))
(if (not (godef--successful-p file))
(message "%s" (godef--error file))
(push-mark)
;; TODO: Integrate this facility with XRef.
(xref-push-marker-stack)
(godef--find-file-line-column file other-window)))
(file-error (message "Could not run godef binary"))))
(let ((file (car (godef--call point))))
(if (not (godef--successful-p file))
(message "%s" (godef--error file))
(push-mark)
;; TODO: Integrate this facility with XRef.
(xref-push-marker-stack)
(godef--find-file-line-column file other-window)))
(file-error (message "Could not run godef binary"))))

(defun godef-jump-other-window (point)
(interactive "d")
Expand Down