aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Dalziel <tom_dl@hotmail.com>2024-03-31 00:34:10 +0100
committerTom Dalziel <33435574+tomdl89@users.noreply.github.com>2024-03-31 00:39:27 +0100
commit476f5fbcf1288c5a46a6ba35efe0b8dd1e4dd0ec (patch)
treedc22ca50018afb5abb3784b1cdfe2252b6ab50ab
parent643e01d1a07fc472b5a9ff6fa3ec001ddc8681ba (diff)
Visual X, deletion column respects stick eol
-rw-r--r--evil-commands.el13
-rw-r--r--evil-maps.el1
-rw-r--r--evil-tests.el10
3 files changed, 21 insertions, 3 deletions
diff --git a/evil-commands.el b/evil-commands.el
index 2ae01d5..9494030 100644
--- a/evil-commands.el
+++ b/evil-commands.el
@@ -1510,7 +1510,10 @@ Save in REGISTER or in the kill-ring with YANK-HANDLER."
;; Special exceptions to ever saving column:
(not (memq evil-this-motion '(evil-forward-word-begin
evil-forward-WORD-begin))))
- (move-to-column evil-operator-start-col))))
+ (move-to-column (if (and (eq most-positive-fixnum temporary-goal-column)
+ (memq last-command '(next-line previous-line)))
+ temporary-goal-column
+ evil-operator-start-col)))))
(evil-define-operator evil-delete-line (beg end type register yank-handler)
"Delete to end of line."
@@ -1526,7 +1529,13 @@ Save in REGISTER or in the kill-ring with YANK-HANDLER."
(let ((temporary-goal-column most-positive-fixnum)
(last-command 'next-line))
(evil-delete beg end 'block register yank-handler))
- (evil-delete beg end type register yank-handler))))
+ (evil-delete beg end type register yank-handler)
+ (evil-first-non-blank)
+ (when (and (not evil-start-of-line) evil-operator-start-col)
+ (move-to-column (if (and (eq most-positive-fixnum temporary-goal-column)
+ (memq last-command '(next-line previous-line)))
+ temporary-goal-column
+ evil-operator-start-col))))))
(evil-define-operator evil-delete-whole-line
(beg end type register yank-handler)
diff --git a/evil-maps.el b/evil-maps.el
index 4387d8b..284da3c 100644
--- a/evil-maps.el
+++ b/evil-maps.el
@@ -389,6 +389,7 @@
(define-key evil-visual-state-map "R" 'evil-change-whole-line)
(define-key evil-visual-state-map "u" 'evil-downcase)
(define-key evil-visual-state-map "U" 'evil-upcase)
+(define-key evil-visual-state-map "X" 'evil-delete-line)
(define-key evil-visual-state-map "z=" 'ispell-word)
(define-key evil-visual-state-map "a" evil-outer-text-objects-map)
(define-key evil-visual-state-map "i" evil-inner-text-objects-map)
diff --git a/evil-tests.el b/evil-tests.el
index b474770..4650710 100644
--- a/evil-tests.el
+++ b/evil-tests.el
@@ -2135,7 +2135,7 @@ then enter the text in that file's own buffer."))
";; This <buffe[r]> is for notes,
and for Lisp evaluation."
("D")
- "[a]nd for Lisp evaluation."))
+ "and for Lisp [e]valuation."))
(ert-info ("Act on each line of block selection")
(evil-test-buffer
:visual block
@@ -2218,6 +2218,14 @@ ine3 line3 line3 l\n"))
("\C-w")
"alpha [b]ravo charlie delta")))
+(ert-deftest evil-test-visual-X ()
+ "Test `X' in visual state."
+ :tags '(evil)
+ (evil-test-buffer
+ "This is line one\nThis is lin[e] two\nThis is line three"
+ ("v$oX")
+ "This is line one\nThis is lin[e] three"))
+
(ert-deftest evil-test-delete-back-to-indentation ()
"Test `evil-delete-back-to-indentation' in insert & replace states."
:tags '(evil)