branch: elpa/evil
commit b6629aef2c196a6910b9fcdefad2c34b4cf4f0c1
Author: Axel Forsman <[email protected]>
Commit: Axel Forsman <[email protected]>
Remove evil--visual-eol-anchored
There already exists a method for sticking to EOL: Setting
temporary-goal-column to most-positive-fixnum. As such, there is no
need for the variable evil--visual-eol-anchored introduced by commit
e31bff8cb64d773bbfd9a8e326db8645eaee43fd.
This commit also fixes a regression where "g$" made "gj"/"gk" stick to
visual EOLs.
---
evil-commands.el | 40 ++++++++--------------------------------
evil-common.el | 25 +++++++++++++------------
evil-tests.el | 16 +---------------
3 files changed, 22 insertions(+), 59 deletions(-)
diff --git a/evil-commands.el b/evil-commands.el
index feb5225612..5ccfce03b3 100644
--- a/evil-commands.el
+++ b/evil-commands.el
@@ -108,49 +108,29 @@ of the line or the buffer; just return nil."
(unless (or (evil-visual-state-p) (evil-operator-state-p))
(evil-adjust-cursor))))))
-(defvar evil--visual-eol-anchored nil
- "Non nil if the cursor should be anchored at the end of the visual line.
-Only reliably usable via `evil-visual-eol-anchored-p'.")
-
-(defun evil-visual-eol-anchored-p ()
- "Return non nil if the cursor should be anchored at the end of the visual
line."
- (if (memq last-command '(next-line previous-line evil-end-of-visual-line))
- evil--visual-eol-anchored
- (setq evil--visual-eol-anchored nil)))
-
(evil-define-motion evil-next-line (count)
"Move the cursor COUNT lines down."
:type line
(let (line-move-visual)
- (unless (memq last-command '(next-line previous-line
evil-end-of-visual-line))
- (setq evil--visual-eol-anchored nil))
(evil-line-move (or count 1))))
(evil-define-motion evil-previous-line (count)
"Move the cursor COUNT lines up."
:type line
(let (line-move-visual)
- (unless (memq last-command '(next-line previous-line
evil-end-of-visual-line))
- (setq evil--visual-eol-anchored nil))
(evil-line-move (- (or count 1)))))
(evil-define-motion evil-next-visual-line (count)
"Move the cursor COUNT screen lines down."
:type exclusive
(let ((line-move-visual t))
- (when (eq most-positive-fixnum temporary-goal-column)
- (setq temporary-goal-column (current-column))) ; Fix #1876
- (evil-line-move (or count 1))
- (when (evil-visual-eol-anchored-p) (evil-end-of-visual-line))))
+ (evil-line-move (or count 1))))
(evil-define-motion evil-previous-visual-line (count)
"Move the cursor COUNT screen lines up."
:type exclusive
(let ((line-move-visual t))
- (when (eq most-positive-fixnum temporary-goal-column)
- (setq temporary-goal-column (current-column))) ; Fix #1876
- (evil-line-move (- (or count 1)))
- (when (evil-visual-eol-anchored-p) (evil-end-of-visual-line))))
+ (evil-line-move (- (or count 1)))))
;; used for repeated commands like "dd"
(evil-define-motion evil-line (count)
@@ -188,16 +168,13 @@ If COUNT is given, move COUNT - 1 lines downward first."
(move-end-of-line count)
(when evil-track-eol
(setq temporary-goal-column most-positive-fixnum
- evil--visual-eol-anchored t
this-command 'next-line))
- (if (evil-visual-state-p)
- (when evil-v$-excludes-newline
- (let ((evil-move-beyond-eol nil))
- (evil-adjust-cursor)))
- (evil-adjust-cursor)
- (when (eolp)
- ;; prevent "c$" and "d$" from deleting blank lines
- (setq evil-this-type 'exclusive))))
+ (let ((evil-move-beyond-eol
+ (if (evil-visual-state-p) (not evil-v$-excludes-newline)
+ evil-move-beyond-eol)))
+ (evil-adjust-cursor))
+ ;; Prevent "c$" and "d$" from deleting blank lines
+ (when (eolp) (setq evil-this-type 'exclusive)))
(evil-define-motion evil-beginning-of-visual-line ()
"Move the cursor to the first character of the current screen line."
@@ -208,7 +185,6 @@ If COUNT is given, move COUNT - 1 lines downward first."
"Move the cursor to the last character of the current screen line.
If COUNT is given, move COUNT - 1 screen lines downward first."
:type inclusive
- (setq evil--visual-eol-anchored t)
(end-of-visual-line count))
(evil-define-motion evil-end-of-line-or-visual-line (count)
diff --git a/evil-common.el b/evil-common.el
index 2b228c236f..82eaddb37a 100644
--- a/evil-common.el
+++ b/evil-common.el
@@ -1239,7 +1239,7 @@ If STATE is given it used a parsing state at point."
;; comes from simple.el, and I hope it will work in future.
(defun evil-line-move (count &optional noerror)
"Like `line-move' but conserves the column.
-Signals an error at buffer boundaries unless NOERROR is non-nil."
+Signal an error at buffer boundaries unless NOERROR is non-nil."
(setq this-command (if (< count 0) 'previous-line 'next-line))
(let ((last-command
;; Reset tmp goal column between visual/logical movement
@@ -1247,17 +1247,18 @@ Signals an error at buffer boundaries unless NOERROR is
non-nil."
(eq temporary-goal-column most-positive-fixnum))
last-command))
(opoint (point)))
- (condition-case err
- (line-move count)
- ((beginning-of-buffer end-of-buffer)
- (let ((col (or goal-column
- (car-safe temporary-goal-column)
- temporary-goal-column)))
- (line-move-finish col opoint (< count 0)))
- (or noerror (/= (point) opoint) (signal (car err) (cdr err))))
- (args-out-of-range
- (unless (eq most-positive-fixnum temporary-goal-column)
- (signal (car err) (cdr err)))))))
+ (if (and line-move-visual
+ (eq temporary-goal-column most-positive-fixnum)
+ (memq last-command '(next-line previous-line)))
+ (let (temporary-goal-column) (end-of-visual-line (1+ count)))
+ (condition-case err
+ (line-move count)
+ ((beginning-of-buffer end-of-buffer)
+ (let ((col (or goal-column
+ (car-safe temporary-goal-column)
+ temporary-goal-column)))
+ (line-move-finish col opoint (< count 0)))
+ (or noerror (/= (point) opoint) (signal (car err) (cdr err))))))))
(defun evil-forward-syntax (syntax &optional count)
"Move point to the end or beginning of a sequence of characters in SYNTAX.
diff --git a/evil-tests.el b/evil-tests.el
index b8f81f59ec..9b4c53e79a 100644
--- a/evil-tests.el
+++ b/evil-tests.el
@@ -3536,26 +3536,12 @@ Below some empty line"
("Gkgk")
(should-not (bolp))))
-(ert-deftest evil-test-end-of-visual-line ()
- "Test `evil-end-of-visual-line'."
- :tags '(evil motion)
- (skip-unless (and (not noninteractive) (> (window-width) 2)))
- (evil-test-buffer
- "alpha bravo charlie\nd[e]lta echo\nfoxtrot golf hotel india"
- ("g$" "gj")
- "alpha bravo charlie\ndelta echo\nfoxtrot golf hotel indi[a]"
- ("gkgk")
- "alpha bravo charli[e]\ndelta echo\nfoxtrot golf hotel india"
- ("ro" "2gj")
- "alpha bravo charlio\ndelta echo\nfoxtrot golf hotel[ ]india"))
-
(ert-deftest evil-test-eol-anchoring-with-visual-line-movement ()
"Test gj and gk once the cursor is anchored at eol with $."
:tags '(evil motion)
- (skip-unless (and (not noninteractive) (> (window-width) 2)))
+ (skip-unless (and (not noninteractive) (> (window-width) 13)))
(evil-test-buffer
"Short [l]ine\nA longer line\nThird line"
- (visual-line-mode 1)
("$gj")
"Short line\nA longer lin[e]\nThird line"))