[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil a00e16899c 1/5: Simple fix for blockwise visual paste
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil a00e16899c 1/5: Simple fix for blockwise visual paste |
Date: |
Mon, 18 Apr 2022 06:58:07 -0400 (EDT) |
branch: elpa/evil
commit a00e16899cc7a0446a4ef4f5e4a658ae42248b2e
Author: Tom Dalziel <tom_dl@hotmail.com>
Commit: Tom Dalziel <33435574+tomdl89@users.noreply.github.com>
Simple fix for blockwise visual paste
Fixes #906
---
evil-commands.el | 22 ++++++++++++++--------
evil-common.el | 4 ++--
2 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/evil-commands.el b/evil-commands.el
index 94b1ba7f33..80a89d7005 100644
--- a/evil-commands.el
+++ b/evil-commands.el
@@ -2213,6 +2213,11 @@ The return value is the yanked text."
(setq evil-last-paste nil))
(and (> (length text) 0) text)))))
+(defun evil-insert-for-yank-at-col (startcol _endcol string)
+ "Insert STRING at STARTCOL."
+ (move-to-column startcol)
+ (insert-for-yank string))
+
(evil-define-command evil-visual-paste (count &optional register)
"Paste over Visual selection."
:suppress-operator t
@@ -2227,10 +2232,12 @@ The return value is the yanked text."
(current-kill 0)))
(yank-handler (car-safe (get-text-property
0 'yank-handler text)))
- paste-eob)
+ beg end paste-eob)
(evil-with-undo
(let ((kill-ring-yank-pointer (when kill-ring (list (current-kill 0)))))
(when (evil-visual-state-p)
+ (setq beg evil-visual-beginning
+ end evil-visual-end)
(evil-visual-rotate 'upper-left)
;; if we replace the last buffer line that does not end in a
;; newline, we use `evil-paste-after' because `evil-delete'
@@ -2238,10 +2245,7 @@ The return value is the yanked text."
(when (and (= evil-visual-end (point-max))
(/= (char-before (point-max)) ?\n))
(setq paste-eob t))
- (evil-delete evil-visual-beginning
- evil-visual-end
- (evil-visual-type)
- (unless evil-kill-on-visual-paste ?_))
+ (evil-delete beg end (evil-visual-type) (unless
evil-kill-on-visual-paste ?_))
(when (and (eq yank-handler #'evil-yank-line-handler)
(not (eq (evil-visual-type) 'line))
(not (= evil-visual-end (point-max))))
@@ -2252,9 +2256,11 @@ The return value is the yanked text."
;; side-effecting (e.g. for the `=' register)...
(cl-letf (((symbol-function 'evil-get-register)
(lambda (&rest _) text)))
- (if paste-eob
- (evil-paste-after count register)
- (evil-paste-before count register))))
+ (cond
+ ((eq 'block (evil-visual-type))
+ (evil-apply-on-block #'evil-insert-for-yank-at-col beg end t text))
+ (paste-eob (evil-paste-after count register))
+ (t (evil-paste-before count register)))))
(when evil-kill-on-visual-paste
(current-kill -1))
;; Ensure that gv can restore visually pasted area...
diff --git a/evil-common.el b/evil-common.el
index 3bb67a1d9f..521ecf7355 100644
--- a/evil-common.el
+++ b/evil-common.el
@@ -2458,8 +2458,8 @@ Then restore Transient Mark mode to its previous setting."
"Call FUNC for each line of a block selection.
The selection is specified by the region BEG and END. FUNC must
take at least two arguments, the beginning and end of each
-line. If PASS-COLUMNS is non-nil, these values are the columns,
-otherwise tey are buffer positions. Extra arguments to FUNC may
+line. If PASS-COLUMNS is non-nil, these values are the columns,
+otherwise they are buffer positions. Extra arguments to FUNC may
be passed via ARGS."
(let ((eol-col (and (memq last-command '(next-line previous-line))
(numberp temporary-goal-column)