From aa3ea1dcfc54fe25581841a8685679d482e99b3f Mon Sep 17 00:00:00 2001 From: Justin Burkett Date: Thu, 8 Aug 2019 22:11:03 -0400 Subject: Unwed evil-move-beyond-eol and evil-move-cursor-back The docstring of evil-cursor-back only mentions that it applies to moving the cursor back when exiting insert state, but in many cases it was tied to also moving the cursor when reaching the end of the line. We have evil-move-beyond-eol to control that behavior, and there doesn't seem to be a good reason that the two must be tied together. Fixes #1178 --- evil-commands.el | 4 +--- evil-common.el | 6 +++--- evil-macros.el | 3 +-- evil-search.el | 2 +- evil-states.el | 11 +++++------ evil-tests.el | 2 +- 6 files changed, 12 insertions(+), 16 deletions(-) diff --git a/evil-commands.el b/evil-commands.el index d860238..7d87d6b 100644 --- a/evil-commands.el +++ b/evil-commands.el @@ -83,8 +83,7 @@ of the line or the buffer; just return nil." (evil-motion-loop (nil (or count 1)) (forward-char) ;; don't put the cursor on a newline - (when (and evil-move-cursor-back - (not evil-move-beyond-eol) + (when (and (not evil-move-beyond-eol) (not (evil-visual-state-p)) (not (evil-operator-state-p)) (eolp) (not (eobp)) (not (bolp))) @@ -1607,7 +1606,6 @@ of the block." (when evil-this-motion (goto-char end) (when (and evil-cross-lines - evil-move-cursor-back (not evil-move-beyond-eol) (not (evil-visual-state-p)) (not (evil-operator-state-p)) diff --git a/evil-common.el b/evil-common.el index 2ef3b23..26b6b39 100644 --- a/evil-common.el +++ b/evil-common.el @@ -1127,13 +1127,13 @@ This function should be used in forward motions. If `point' is close to eob so that no further forward motion is possible the error 'end-of-buffer is raised. This is the case if `point' is at `point-max' or if is one position before `point-max', -`evil-move-cursor-back' is non-nil and `point' is not at the end +`evil-move-beyond-eol' is nil and `point' is not at the end of a line. The latter is necessary because `point' cannot be -moved to `point-max' if `evil-move-cursor-back' is non-nil and +moved to `point-max' if `evil-move-beyond-eol' is nil and the last line in the buffer is not empty." (when (or (eobp) (and (not (eolp)) - evil-move-cursor-back + (not evil-move-beyond-eol) (save-excursion (forward-char) (eobp)))) (signal 'end-of-buffer nil))) diff --git a/evil-macros.el b/evil-macros.el index 117d9d7..66d550d 100644 --- a/evil-macros.el +++ b/evil-macros.el @@ -168,8 +168,7 @@ upon reaching the beginning or end of the current line. (when (save-excursion (goto-char end) (bolp)) (setq end (max beg (1- end)))) ;; don't include the newline in Normal state - (when (and evil-move-cursor-back - (not evil-move-beyond-eol) + (when (and (not evil-move-beyond-eol) (not (evil-visual-state-p)) (not (evil-operator-state-p))) (setq end (max beg (1- end)))) diff --git a/evil-search.el b/evil-search.el index b995866..c622fa5 100644 --- a/evil-search.el +++ b/evil-search.el @@ -774,7 +774,7 @@ the direcion is determined by `evil-ex-search-direction'." (when (eq evil-ex-search-direction 'forward) (unless (eobp) (forward-char)) ;; maybe skip end-of-line - (when (and evil-move-cursor-back (eolp) (not (eobp))) + (when (and (not evil-move-beyond-eol) (eolp) (not (eobp))) (forward-char))) (let ((res (evil-ex-find-next nil nil (not evil-search-wrap)))) (cond diff --git a/evil-states.el b/evil-states.el index 8cb2c32..8ffc1d6 100644 --- a/evil-states.el +++ b/evil-states.el @@ -128,10 +128,10 @@ commands opening a new line." (evil-set-marker ?^ nil t) (unless (eq evil-want-fine-undo t) (evil-end-undo-step)) - (when evil-move-cursor-back - (when (or (evil-normal-state-p evil-next-state) - (evil-motion-state-p evil-next-state)) - (evil-move-cursor-back)))))) + (when (or (evil-normal-state-p evil-next-state) + (evil-motion-state-p evil-next-state)) + (evil-move-cursor-back + (and (eolp) (not evil-move-beyond-eol))))))) (defun evil-insert-repeat-hook () "Record insertion keys in `evil-insert-repeat-info'." @@ -856,8 +856,7 @@ CORNER defaults to `upper-left'." (remove-hook 'pre-command-hook #'evil-replace-pre-command t) (unless (eq evil-want-fine-undo t) (evil-end-undo-step)) - (when evil-move-cursor-back - (evil-move-cursor-back)))) + (evil-move-cursor-back))) (setq evil-replace-alist nil)) (defun evil-replace-pre-command () diff --git a/evil-tests.el b/evil-tests.el index e2480eb..879fed9 100644 --- a/evil-tests.el +++ b/evil-tests.el @@ -2694,7 +2694,7 @@ This bufferThis bufferThis buffe[r];; and for Lisp evaluation.")) ";[;] This buffer is for notes.")) (ert-info ("End of line") (let ((evil-cross-lines t) - (evil-move-cursor-back t)) + (evil-move-beyond-eol nil)) (evil-test-buffer ";; This buffer is for notes[,] ;; and for Lisp evaluation." -- cgit v1.0