[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/go-mode f03998154b: go-beginning-of-defun: only move to en
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/go-mode f03998154b: go-beginning-of-defun: only move to end of line when we're on a declaration |
Date: |
Tue, 27 Dec 2022 18:59:02 -0500 (EST) |
branch: elpa/go-mode
commit f03998154bbed359f1912284a49b598fef074406
Author: Dominik Honnef <dominik@honnef.co>
Commit: Dominik Honnef <dominik@honnef.co>
go-beginning-of-defun: only move to end of line when we're on a declaration
Some code (e.g. evil-mode) doesn't expect beginning-of-defun (with
positive arguments) to move the point forward. We move it to the end of
line to ensure we find the function declaration that point might already
be on. Do this conditionally to ensure we only move the point to eol
when a later re-search-backward will undo that motion.
Updates gh-186
---
go-mode.el | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/go-mode.el b/go-mode.el
index f31e4bffdd..8bc912e1ab 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -1240,8 +1240,18 @@ INDENT is the normal indent of this line, i.e. that of
the case body."
(goto-char (- (point-max) pos))))))
(defun go-beginning-of-defun (&optional count)
- (unless (bolp)
- (end-of-line))
+ (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))
(setq count (or count 1))
(let (first failure)
(dotimes (i (abs count))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [nongnu] elpa/go-mode f03998154b: go-beginning-of-defun: only move to end of line when we're on a declaration,
ELPA Syncer <=