[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil 0c535d6dab 1/6: Simplify temporary-goal-column logic
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil 0c535d6dab 1/6: Simplify temporary-goal-column logic |
Date: |
Thu, 29 Dec 2022 12:58:48 -0500 (EST) |
branch: elpa/evil
commit 0c535d6dabb9f30ab16ab428c9a123dba9d6ef75
Author: Axel Forsman <axelsfor@gmail.com>
Commit: Tom Dalziel <33435574+tomdl89@users.noreply.github.com>
Simplify temporary-goal-column logic
In `evil-ensure-column` there is no point in normalizing
`temporary-goal-column` a second time after BODY, since that variable is
used to store the saved column that need not be overwritten. Also
tracking EOL after `evil-end-of-line` is already handled as it fakes
being a `next-line` command.
Adds a test for commit 7aa71576d258b9546238f6dbd4cf5ca0a1b70088.
---
evil-commands.el | 6 ++----
evil-common.el | 56 ++++++++++++++++++++++++--------------------------------
evil-tests.el | 7 ++++++-
3 files changed, 32 insertions(+), 37 deletions(-)
diff --git a/evil-commands.el b/evil-commands.el
index adaf6c3523..3b73dfdd54 100644
--- a/evil-commands.el
+++ b/evil-commands.el
@@ -2061,8 +2061,7 @@ See also `evil-shift-left'."
(move-to-column (max 0 (+ col-for-insert first-shift))))
(evil-start-of-line (evil-first-non-blank))
((evil--stick-to-eol-p) (move-end-of-line 1))
- (t (move-to-column (or goal-column evil-operator-start-col
col-for-insert))))
- (setq temporary-goal-column 0)))
+ (t (move-to-column (or goal-column evil-operator-start-col
col-for-insert))))))
(defun evil-delete-indentation ()
"Delete all indentation on current line."
@@ -2689,8 +2688,7 @@ the lines."
((or (eq (evil-visual-type) 'line)
(and (eq (evil-visual-type) 'block)
(memq last-command '(next-line previous-line))
- (numberp temporary-goal-column)
- (= temporary-goal-column most-positive-fixnum)))
+ (eq temporary-goal-column most-positive-fixnum)))
(evil-visual-rotate 'upper-left)
(evil-append-line count vcount))
((eq (evil-visual-type) 'block)
diff --git a/evil-common.el b/evil-common.el
index 15095d9ff4..1ac543b231 100644
--- a/evil-common.el
+++ b/evil-common.el
@@ -971,13 +971,9 @@ See also `evil-save-goal-column'."
(defun evil--stick-to-eol-p ()
"Called by vertical movement commands to help determine cursor position."
- (let ((goal-col (or goal-column
- (if (consp temporary-goal-column)
- (car temporary-goal-column)
- temporary-goal-column))))
- (and evil-track-eol
- (= most-positive-fixnum goal-col)
- (eq last-command 'next-line))))
+ (and evil-track-eol
+ (eq (or goal-column temporary-goal-column) most-positive-fixnum)
+ (memq last-command '(next-line previous-line))))
(defun evil-eolp ()
"Like `eolp' but accounts for `evil-move-beyond-eol' being nil."
@@ -991,32 +987,28 @@ See also `evil-save-goal-column'."
"Execute BODY so that column after execution is correct.
If `evil-start-of-line' is nil, treat BODY as if it were a `next-line' command.
This mostly copies the approach of Emacs' `line-move-1', but is modified
-so it is more compatible with evil's notions of eol & tracking."
+so it is more compatible with Evil's notions of eol & tracking."
(declare (indent defun)
(debug t))
- (let ((normalize-temporary-goal-column
- `(if (consp temporary-goal-column)
- ;; Ensure a negative value is never set for
`temporary-goal-column'
- ;; as it may have a negative component when both
`whitespace-mode'
- ;; and `display-line-numbers-mode' are enabled.
- ;; See #1297
- (setq temporary-goal-column (max 0 (+ (car temporary-goal-column)
- (cdr
temporary-goal-column)))))))
- `(progn
- (unless evil-start-of-line (setq this-command 'next-line))
- ,normalize-temporary-goal-column
- (if (not (memq last-command '(next-line previous-line)))
- (setq temporary-goal-column
- (if (and evil-track-eol
- (evil-eolp)
- (memq real-last-command '(move-end-of-line
evil-end-of-line)))
- most-positive-fixnum
- (current-column))))
- ,@body
- (if evil-start-of-line
- (evil-first-non-blank)
- ,normalize-temporary-goal-column
- (line-move-to-column (truncate (or goal-column
temporary-goal-column)))))))
+ `(progn
+ (unless evil-start-of-line
+ (setq this-command 'next-line
+ temporary-goal-column
+ (cond
+ ((memq last-command '(next-line previous-line))
+ (if (consp temporary-goal-column)
+ ;; Guard against a negative value as `temporary-goal-column'
+ ;; may have a negative component when both `whitespace-mode'
+ ;; and `display-line-numbers-mode' are enabled (#1297).
+ (max 0 (+ (truncate (car temporary-goal-column))
+ (cdr temporary-goal-column)))
+ temporary-goal-column))
+ ((and track-eol (eolp) (not (bolp))) most-positive-fixnum)
+ (t (current-column)))))
+ ,@body
+ (if evil-start-of-line
+ (evil-first-non-blank)
+ (line-move-to-column (or goal-column temporary-goal-column)))))
(defun evil-narrow (beg end)
"Restrict the buffer to BEG and END.
@@ -1400,7 +1392,7 @@ If STATE is given it used a parsing state at point."
;; the line (we never want point to leave its column). The code here
;; comes from simple.el, and I hope it will work in future.
(defun evil-line-move (count &optional noerror)
- "A wrapper for line motions that conserves the column.
+ "Like `line-move' but conserves the column.
Signals an error at buffer boundaries unless NOERROR is non-nil."
(setq this-command (if (< count 0) #'previous-line #'next-line))
(let ((last-command
diff --git a/evil-tests.el b/evil-tests.el
index 26734f6c28..6358087e3f 100644
--- a/evil-tests.el
+++ b/evil-tests.el
@@ -1630,7 +1630,12 @@ New Tex[t]
:state visual
"< Line with too much indentation.>"
("=")
- "Line with too much indentation."))
+ "Line with too much indentation.")
+ (ert-info ("Can repeat evil-indent without errors")
+ (evil-test-buffer
+ "[ ]x\n x"
+ ("==j.")
+ "x\nx")))
(ert-deftest evil-test-keypress-parser ()
"Test `evil-keypress-parser'"
- [nongnu] elpa/evil updated (2e8576188b -> 13f01f6245), ELPA Syncer, 2022/12/29
- [nongnu] elpa/evil 1226944a5d 4/6: Remove some unnecessary evil-normalize-position:s, ELPA Syncer, 2022/12/29
- [nongnu] elpa/evil e2ec733b05 3/6: Remove str-conversions in evil-visual-block-corner, ELPA Syncer, 2022/12/29
- [nongnu] elpa/evil a87d5fd1ad 5/6: evil-core: don't change match data in the advice of set-window-buffer, ELPA Syncer, 2022/12/29
- [nongnu] elpa/evil be6b09bcec 2/6: Make visual block selection after j/k match Vim, ELPA Syncer, 2022/12/29
- [nongnu] elpa/evil 0c535d6dab 1/6: Simplify temporary-goal-column logic,
ELPA Syncer <=
- [nongnu] elpa/evil 13f01f6245 6/6: Make evil-mode-line-format recognise nil value, ELPA Syncer, 2022/12/29