aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Dalziel <tom_dl@hotmail.com>2022-04-18 00:30:49 +0100
committerTom Dalziel <33435574+tomdl89@users.noreply.github.com>2022-04-18 12:24:56 +0200
commita00e16899cc7a0446a4ef4f5e4a658ae42248b2e (patch)
tree4acc8f00c81417760961b0c4b3a8ecb552aee4a5
parentfd0644ebfc7e827ea790a7b8fb6c590aada6b225 (diff)
Simple fix for blockwise visual paste
Fixes #906
-rw-r--r--evil-commands.el22
-rw-r--r--evil-common.el4
2 files changed, 16 insertions, 10 deletions
diff --git a/evil-commands.el b/evil-commands.el
index 94b1ba7..80a89d7 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 3bb67a1..521ecf7 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)