From cccb39e73f2f4e636bea47d5c3b62238476d8729 Mon Sep 17 00:00:00 2001 From: Nathaniel Nicandro Date: Fri, 27 Jan 2023 14:02:18 -0600 Subject: [PATCH 1/7] Make setting registers more in line with VIM --- evil-commands.el | 43 ++++++++----- evil-common.el | 106 +++++++++++++++++++----------- evil-tests.el | 163 +++++++++++++++++++++++++++++++++++++++++++++++ evil-vars.el | 27 +++++++- 4 files changed, 281 insertions(+), 58 deletions(-) diff --git a/evil-commands.el b/evil-commands.el index dccd254c..bcdaab85 100644 --- a/evil-commands.el +++ b/evil-commands.el @@ -1406,24 +1406,26 @@ the left edge." ;;; Operator commands (evil-define-operator evil-yank (beg end type register yank-handler) - "Save the characters in motion into the kill-ring." + "Save the characters in motion into the `kill-ring'. +Save in REGISTER or in the yank register, \"0, with YANK-HANDLER. +Also save in the `kill-ring'. + +See `evil-kill-new' for more details on how text is saved." :move-point nil :repeat nil (interactive "") - (let ((evil-was-yanked-without-register - (and evil-was-yanked-without-register (not register)))) - (cond - ((and (fboundp 'cua--global-mark-active) - (fboundp 'cua-copy-region-to-global-mark) - (cua--global-mark-active)) - (cua-copy-region-to-global-mark beg end)) - ((eq type 'block) - (evil-yank-rectangle beg end register yank-handler)) - ((memq type '(line screen-line)) - (evil-yank-lines beg end register yank-handler)) - (t - (evil-yank-characters beg end register yank-handler) - (goto-char beg))))) + (cond + ((and (fboundp 'cua--global-mark-active) + (fboundp 'cua-copy-region-to-global-mark) + (cua--global-mark-active)) + (cua-copy-region-to-global-mark beg end)) + ((eq type 'block) + (evil-yank-rectangle beg end register yank-handler)) + ((memq type '(line screen-line)) + (evil-yank-lines beg end register yank-handler)) + (t + (evil-yank-characters beg end register yank-handler) + (goto-char beg)))) (defun evil-expand-line-for-line-based-operators (beg end type) "Expand to line when in visual mode possibly changing BEG, END and TYPE. @@ -1459,7 +1461,14 @@ Avoids double expansion for line based commands like 'V' or 'D'." (evil-define-operator evil-delete (beg end type register yank-handler) "Delete text from BEG to END with TYPE. -Save in REGISTER or in the kill-ring with YANK-HANDLER." +Save in REGISTER or in one of the delete registers with +YANK-HANDLER. Also save in the `kill-ring'. + +Saved in the first delete register, \"1, if the deleted text +spans multiple lines or in the small delete register, \"-, if the +deleted text is within a line. + +See `evil-kill-new' for more details on how text is saved." (interactive "") (when (and (memq type '(inclusive exclusive)) (not (evil-visual-state-p)) @@ -1478,7 +1487,7 @@ Save in REGISTER or in the kill-ring with YANK-HANDLER." (unless (string-match-p "\n" text) ;; set the small delete register (evil-set-register ?- text)))) - (let ((evil-was-yanked-without-register nil)) + (let ((this-command 'evil-delete)) (evil-yank beg end type register yank-handler)) (cond ((eq type 'block) diff --git a/evil-common.el b/evil-common.el index 4397a9c3..52a28afa 100644 --- a/evil-common.el +++ b/evil-common.el @@ -1954,7 +1954,9 @@ The following special registers are supported. ((eq register ?\") (current-kill 0)) ((<= ?1 register ?9) - (let ((reg (- register ?1))) + (let ((kill-ring evil-delete-kill-ring) + (kill-ring-yank-pointer evil-delete-kill-ring) + (reg (- register ?1))) (and (< reg (length kill-ring)) (current-kill reg t)))) ((memq register '(?* ?+)) @@ -2089,13 +2091,13 @@ register instead of replacing its content." (user-error "Can't modify read-only register")) ((eq register ?\") (kill-new text)) ((<= ?1 register ?9) - (if (null kill-ring) - (kill-new text) - (let ((kill-ring-yank-pointer kill-ring-yank-pointer) - interprogram-paste-function - interprogram-cut-function) - (current-kill (- register ?1)) - (setcar kill-ring-yank-pointer text)))) + (let ((kill-ring evil-delete-kill-ring) + (kill-ring-yank-pointer evil-delete-kill-ring) + interprogram-paste-function + interprogram-cut-function) + (current-kill (- register ?1)) + (setcar kill-ring-yank-pointer text) + (setq evil-delete-kill-ring kill-ring))) ((eq register ?*) (evil-set-selection 'PRIMARY text)) ((eq register ?+) (evil-set-selection 'CLIPBOARD text)) ((eq register ?-) (setq evil-last-small-deletion text)) @@ -2346,20 +2348,58 @@ The tracked insertion is set to `evil-last-insertion'." ;;; Paste +(defun evil-kill-new (text &optional register) + "Like `kill-new', but also handle `evil' registers. +When REGISTER is the black hole register, \"_, do nothing and +return. + +Otherwise store TEXT in the `kill-ring'. If REGISTER is +specified, store TEXT in that register. If REGISTER is not +specified and `this-command' is a yank command (i.e. not +`evil-delete'), store TEXT in the yank register, \"0. Also store +in the yank register if REGISTER is the unnamed register, \"\". + +If `this-command' is `evil-delete', TEXT is considered deleted +TEXT and will be stored in the first delete register, \"1, when +TEXT spans multiple lines or the small delete register, \"-, when +TEXT is within a line. This is only done if REGISTER is not +provided. + +As a special case, if the motion used to delete TEXT is one of +`evil-special-delete-motions', store TEXT in the first delete +register even when REGISTER is provided." + (prog1 text + (unless (eq register ?_) + (kill-new text) + (if register (evil-set-register register text) + (unless (eq this-command 'evil-delete) + ;; set the yank register + (evil-set-register ?0 text))) + (when (eq this-command 'evil-delete) + (let ((special-motion (memq evil-this-motion + evil-special-delete-motions)) + (within-line (not (string-match-p "\n" text)))) + (when (and within-line (not register)) + ;; set the small delete register + (evil-set-register ?- text)) + (when (or special-motion + (and (not register) (not within-line))) + ;; set the delete register + (let ((kill-ring evil-delete-kill-ring) + (kill-ring-yank-pointer) + (kill-ring-max 9)) + (kill-new text) + (setq evil-delete-kill-ring kill-ring)))))))) + (defun evil-yank-characters (beg end &optional register yank-handler) - "Save the characters defined by the region BEG and END in the kill-ring." + "Save the characters defined by the region BEG and END in the `kill-ring'." (let ((text (filter-buffer-substring beg end))) (when yank-handler - (put-text-property 0 (length text) 'yank-handler (list yank-handler) text)) - (when register - (evil-set-register register text)) - (when evil-was-yanked-without-register - (evil-set-register ?0 text)) ; "0 register contains last yanked text - (unless (eq register ?_) - (kill-new text)))) + (setq text (propertize text 'yank-handler (list yank-handler)))) + (evil-kill-new text register))) (defun evil-yank-lines (beg end &optional register yank-handler) - "Save the lines in the region BEG and END into the kill-ring." + "Save the lines in the region BEG and END into the `kill-ring'." (let ((text (filter-buffer-substring beg end)) (yank-handler (list (or yank-handler #'evil-yank-line-handler) nil @@ -2369,16 +2409,11 @@ The tracked insertion is set to `evil-last-insertion'." (when (or (zerop (length text)) (/= (aref text (1- (length text))) ?\n)) (setq text (concat text "\n"))) - (put-text-property 0 (length text) 'yank-handler yank-handler text) - (when register - (evil-set-register register text)) - (when evil-was-yanked-without-register - (evil-set-register ?0 text)) ; "0 register contains last yanked text - (unless (eq register ?_) - (kill-new text)))) + (setq text (propertize text 'yank-handler yank-handler)) + (evil-kill-new text register))) (defun evil-yank-rectangle (beg end &optional register yank-handler) - "Save the rectangle defined by region BEG and END into the kill-ring." + "Save the rectangle defined by region BEG and END into the `kill-ring'." (let ((lines (list nil))) (evil-apply-on-rectangle #'extract-rectangle-line beg end lines) ;; We remove spaces from the beginning and the end of the next. @@ -2387,19 +2422,14 @@ The tracked insertion is set to `evil-last-insertion'." (setq lines (nreverse (cdr lines))) ;; `text' is used as default insert text when pasting this rectangle ;; in another program, e.g., using the X clipboard. - (let ((yank-handler (list (or yank-handler #'evil-yank-block-handler) - lines - t - #'evil-delete-yanked-rectangle)) - (text (mapconcat #'identity lines "\n"))) - (put-text-property 0 (length text) 'yank-handler yank-handler text) - (when register - (evil-set-register register text)) - (when evil-was-yanked-without-register - (evil-set-register ?0 text)) ; "0 register contains last yanked text - (unless (eq register ?_) - (kill-new text)) - text))) + (let* ((yank-handler (list (or yank-handler + #'evil-yank-block-handler) + lines + t + 'evil-delete-yanked-rectangle)) + (text (propertize (mapconcat #'identity lines "\n") + 'yank-handler yank-handler))) + (evil-kill-new text register)))) (defun evil-remove-yank-excluded-properties (text) "Remove `yank-excluded-properties' from TEXT." diff --git a/evil-tests.el b/evil-tests.el index dcf8fce8..7d643962 100644 --- a/evil-tests.el +++ b/evil-tests.el @@ -3187,6 +3187,63 @@ word3[]")) ("Vp\C-p\C-p") "word1a word1b word1c\nword1[a]\nword3a word3b word3c word3d\n"))) +(ert-deftest evil-test-kill-new () + "Test `evil-kill-new'" + :tags '(evil yank paste) + ;; Ensure a kill is present + (kill-new "qqqqq") + (evil-set-register ?- "sd") + (evil-set-register ?1 "d") + (evil-set-register ?0 "y") + (ert-info ("black hole register") + (let ((current (current-kill 0 t)) + (del (evil-get-register ?1)) + (small-del (evil-get-register ?-)) + (yank (evil-get-register ?0))) + (evil-test-buffer + "[f]oo\n" + ("\"_vly") + (should-not (equal "fo" (evil-get-register ?_))) + (should (eq current (current-kill 0 t))) + (should (eq del (evil-get-register ?1))) + (should (eq small-del (evil-get-register ?-))) + (should (eq yank (evil-get-register ?0)))))) + (ert-info ("yank commands") + (evil-test-buffer + "[b]ar\n" + ("vly") + (should (equal "ba" (current-kill 0 t))) + (should (equal "ba" (evil-get-register ?0)))) + (evil-test-buffer + "[f]oo\n" + ("\"avly") + (should (equal "fo" (current-kill 0 t))) + (should (equal "fo" (evil-get-register ?a))) + (should (equal "ba" (evil-get-register ?0))))) + (ert-info ("delete commands") + (let ((del (evil-get-register ?1))) + (evil-test-buffer + ;; small delete register + "[x]xxx\n" + ("dw") + (should (equal "xxxx" (current-kill 0 t))) + (should (equal "xxxx" (evil-get-register ?-))) + (should (equal del (evil-get-register ?1))))) + (evil-test-buffer + "[z]zzz\n" + ("dd") + (should (equal "zzzz\n" (current-kill 0 t))) + (should (equal "xxxx" (evil-get-register ?-))) + (should (equal "zzzz\n" (evil-get-register ?1))))) + (ert-info ("special delete commands") + (evil-test-buffer + "[ ] aba b\n" + ("/a" [return] "\"adn") + (should (equal "ab" (current-kill 0 t))) + (should (equal "ab" (evil-get-register ?a))) + (should (equal "xxxx" (evil-get-register ?-))) + (should (equal "ab" (evil-get-register ?1)))))) + (ert-deftest evil-test-register () "Test yanking and pasting to and from register." :tags '(evil yank paste) @@ -3337,6 +3394,112 @@ sed do eiusmod tempor incididunt")) "Line one. [4]2"))) +(ert-deftest evil-test-number-registers-yank () + "Test number register behavior after `evil-yank'" + (ert-info ("yanks without named register") + (dotimes (i 3) + (evil-set-register (+ ?0 i) "")) + (evil-test-buffer + "a\n[b]\nc\nd\n" + ("yy" [return]) + "a\nb\n[c]\nd\n" + (should (string= (evil-get-register ?\") "b\n")) + (should (string= (evil-get-register ?0) "b\n")) + (should (string= (evil-get-register ?1) "")) + (should (string= (evil-get-register ?2) "")) + ("yy" [return]) + "a\nb\nc\n[d]\n" + (should (string= (evil-get-register ?\") "c\n")) + (should (string= (evil-get-register ?0) "c\n")) + (should (string= (evil-get-register ?1) "")) + (should (string= (evil-get-register ?2) "")) + ("yy") + (should (string= (evil-get-register ?\") "d\n")) + (should (string= (evil-get-register ?0) "d\n")) + (should (string= (evil-get-register ?1) "")) + (should (string= (evil-get-register ?2) "")))) + (ert-info ("yanks with named register") + (evil-set-register ?0 "") + (evil-test-buffer + "a\n[b]\nc\nd\n" + ("\"ayy") + (should (string= (evil-get-register ?\") "b\n")) + (should (string= (evil-get-register ?a) "b\n")) + (should (string= (evil-get-register ?0) "")) + (should (string= (evil-get-register ?1) "")) + (should (string= (evil-get-register ?2) "")) + ([return] "\"\"yy") + "a\nb\n[c]\nd\n" + (should (string= (evil-get-register ?\") "c\n")) + (should (string= (evil-get-register ?a) "b\n")) + (should (string= (evil-get-register ?0) "c\n")) + (should (string= (evil-get-register ?1) "")) + (should (string= (evil-get-register ?2) ""))))) + +(ert-deftest evil-test-number-registers-delete () + "Test number register behavior after `evil-delete'" + (dotimes (i 10) + (evil-set-register (+ ?0 i) "")) + (ert-info ("deletions without named register") + (evil-test-buffer + "[a]\nb\nc\nd\n" + ("dd") + "[b]\nc\nd\n" + (should (string= (evil-get-register ?\") "a\n")) + (should (string= (evil-get-register ?0) "")) + (should (string= (evil-get-register ?1) "a\n")) + (should (string= (evil-get-register ?2) "")) + (should (string= (evil-get-register ?3) "")) + ("dd") + "[c]\nd\n" + (should (string= (evil-get-register ?\") "b\n")) + (should (string= (evil-get-register ?0) "")) + (should (string= (evil-get-register ?1) "b\n")) + (should (string= (evil-get-register ?2) "a\n")) + (should (string= (evil-get-register ?3) "")) + ("dd") + "[d]\n" + (should (string= (evil-get-register ?\") "c\n")) + (should (string= (evil-get-register ?0) "")) + (should (string= (evil-get-register ?1) "c\n")) + (should (string= (evil-get-register ?2) "b\n")) + (should (string= (evil-get-register ?3) "a\n")))) + (dotimes (i 10) + (evil-set-register (+ ?0 i) "")) + (ert-info ("deletions with named register") + (evil-test-buffer + "[a]\nb\nc\nd\n" + ("\"add") + "[b]\nc\nd\n" + (should (string= (evil-get-register ?\") "a\n")) + (should (string= (evil-get-register ?a) "a\n")) + (should (string= (evil-get-register ?0) "")) + (should (string= (evil-get-register ?1) "")) + (should (string= (evil-get-register ?2) "")) + ("dd") + "[c]\nd\n" + (should (string= (evil-get-register ?\") "b\n")) + (should (string= (evil-get-register ?a) "a\n")) + (should (string= (evil-get-register ?0) "")) + (should (string= (evil-get-register ?1) "b\n")) + (should (string= (evil-get-register ?2) ""))) + (ert-info ("special handling of motion operators") + (evil-test-buffer + ;; Some operators still add the kill to the number registers + ;; in addition to the named register + "[c]\nd\n" + ("/d" [return] "k") + "[c]\nd\n" + ("\"adn") + "[d]\n" + ("dd") + "" + (should (string= (evil-get-register ?\") "d\n")) + (should (string= (evil-get-register ?a) "c\n")) + (should (string= (evil-get-register ?0) "")) + (should (string= (evil-get-register ?1) "d\n")) + (should (string= (evil-get-register ?2) "c\n")))))) + (ert-deftest evil-test-align () "Test `evil-align-left', `evil-align-right' and `evil-align-center'." :tags '(evil operator) diff --git a/evil-vars.el b/evil-vars.el index aea7eeea..8efa4141 100644 --- a/evil-vars.el +++ b/evil-vars.el @@ -1100,6 +1100,28 @@ intercepted." :set #'evil-set-custom-motions :initialize #'evil-custom-initialize-pending-reset) +(defcustom evil-special-delete-motions + '(evil-ex-search-forward + evil-ex-search-backward + evil-ex-search-next + evil-ex-search-previous + evil-search-forward + evil-search-backward + evil-search-next + evil-search-previous + evil-jump-item + evil-backward-sentence-begin + evil-forward-sentence-begin + evil-goto-mark + evil-backward-paragraph + evil-forward-paragraph) + "Evil motions that always store deleted text in register 1. +Normally if text is deleted using a motion command, the text is +stored in register 1 only when a named registered is not +specified." + :type '(repeat symbol) + :group 'evil) + (defcustom evil-visual-newline-commands '(LaTeX-section TeX-font) @@ -1677,9 +1699,8 @@ buffer-region of the newly inserted text.") "The last piece of deleted text. The text should be less than a line.") -(defvar evil-was-yanked-without-register t - "Whether text being saved to the numbered-register ring was -not deleted and not yanked to a specific register.") +(defvar evil-delete-kill-ring (make-list 9 "") + "The kill ring that stores text for the 1-9 registers.") (defvar evil-paste-count nil "The count argument of the current paste command.") From c024c151091dcbe589b818c4e084fd4411d8201b Mon Sep 17 00:00:00 2001 From: Nathaniel Nicandro Date: Thu, 19 Dec 2019 22:40:39 -0600 Subject: [PATCH 2/7] Revive `evil-was-yanked-without-register` Bring it back. But don't use it. Should be removed in a future commit. --- evil-vars.el | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/evil-vars.el b/evil-vars.el index 8efa4141..bc2bd7d2 100644 --- a/evil-vars.el +++ b/evil-vars.el @@ -1699,6 +1699,14 @@ buffer-region of the newly inserted text.") "The last piece of deleted text. The text should be less than a line.") +(defvar evil-was-yanked-without-register t + "Whether text being saved to the numbered-register ring was +not deleted and not yanked to a specific register.") +(make-obsolete-variable + 'evil-was-yanked-without-register + "This variable is no longer used and will be removed in future versions of Evil." + "1.15") + (defvar evil-delete-kill-ring (make-list 9 "") "The kill ring that stores text for the 1-9 registers.") From c2e1866a81bd12debe71855e7f7a136310c5c009 Mon Sep 17 00:00:00 2001 From: Nathaniel Nicandro Date: Fri, 10 May 2024 13:34:06 -0500 Subject: [PATCH 3/7] Set the yank register when the unnamed register is set This adheres to the Vim documentation which states Writing to the "" register writes to register "0. See `:help registers`. --- evil-common.el | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/evil-common.el b/evil-common.el index 52a28afa..ec24d8df 100644 --- a/evil-common.el +++ b/evil-common.el @@ -2371,10 +2371,15 @@ register even when REGISTER is provided." (prog1 text (unless (eq register ?_) (kill-new text) - (if register (evil-set-register register text) - (unless (eq this-command 'evil-delete) - ;; set the yank register - (evil-set-register ?0 text))) + (when register + (evil-set-register register text)) + (when (or (and (null register) + (not (eq this-command 'evil-delete))) + ;; As per Vim documentation, set the yank register + ;; when the unnamed register is specified. + (eq register ?\")) + ;; set the yank register + (evil-set-register ?0 text)) (when (eq this-command 'evil-delete) (let ((special-motion (memq evil-this-motion evil-special-delete-motions)) From b05ea8b1fda41a17d8bff2e4bd7daa2c80744f55 Mon Sep 17 00:00:00 2001 From: Nathaniel Nicandro Date: Thu, 2 May 2024 14:27:39 -0500 Subject: [PATCH 4/7] Fix a test in `evil-test-register` --- evil-tests.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/evil-tests.el b/evil-tests.el index 7d643962..a850cef8 100644 --- a/evil-tests.el +++ b/evil-tests.el @@ -3285,7 +3285,8 @@ word3[]")) (ert-info ("special register :") (evil-test-buffer "[f]oo bar\n" - (":noh\ni\C-r:"))) + (":noh" [return] "i\C-r:") + "noh[f]oo bar")) (ert-info ("Paste from register during change to register") (evil-test-buffer "[a]lpha beta" From a82a352a8ab61af71f48bdf594f5b8d522e3a3c2 Mon Sep 17 00:00:00 2001 From: Nathaniel Nicandro Date: Wed, 8 May 2024 21:01:26 -0500 Subject: [PATCH 5/7] Add registers tag to tests using registers --- evil-tests.el | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/evil-tests.el b/evil-tests.el index a850cef8..a1b39356 100644 --- a/evil-tests.el +++ b/evil-tests.el @@ -935,7 +935,7 @@ If nil, KEYS is used." (ert-deftest evil-test-repeat-register () "Test repeating a register command." - :tags '(evil repeat) + :tags '(evil repeat registers) (evil-test-buffer "[l]ine 1\nline 2\nline 3\nline 4\n" ("\"addyy\"aP") @@ -945,7 +945,7 @@ If nil, KEYS is used." (ert-deftest evil-test-repeat-numeric-register () "Test repeating a command with a numeric register." - :tags '(evil repeat) + :tags '(evil repeat registers) (evil-test-buffer "[l]ine 1\nline 2\nline 3\nline 4\nline 5\n" ("dd...") @@ -3189,7 +3189,7 @@ word3[]")) (ert-deftest evil-test-kill-new () "Test `evil-kill-new'" - :tags '(evil yank paste) + :tags '(evil yank paste registers) ;; Ensure a kill is present (kill-new "qqqqq") (evil-set-register ?- "sd") @@ -3246,7 +3246,7 @@ word3[]")) (ert-deftest evil-test-register () "Test yanking and pasting to and from register." - :tags '(evil yank paste) + :tags '(evil yank paste registers) (ert-info ("simple lower case register") (evil-test-buffer "[f]oo\n" @@ -3307,6 +3307,7 @@ word3[]")) (ert-deftest evil-test-last-insert-register () "Test last insertion register." + :tags '(evil registers) (evil-test-buffer "[l]ine 1\n" ("GiABC" [escape]) @@ -3316,6 +3317,7 @@ word3[]")) (ert-deftest evil-test-zero-register () "\"0 contains the last text that was yanked without specificying a register." + :tags '(evil registers) (evil-test-buffer "[l]ine 1\nline 2\n" ("yy\"0p") @@ -3327,6 +3329,7 @@ word3[]")) (ert-deftest evil-test-=-register () "\"= is not really a register . It inserts the result of evaluating some elisp" + :tags '(evil registers) (ert-info ("Can eval elisp, and can fetch default (last) result") (evil-test-buffer :state insert @@ -3397,6 +3400,7 @@ sed do eiusmod tempor incididunt")) (ert-deftest evil-test-number-registers-yank () "Test number register behavior after `evil-yank'" + :tags '(evil registers) (ert-info ("yanks without named register") (dotimes (i 3) (evil-set-register (+ ?0 i) "")) @@ -3439,6 +3443,7 @@ sed do eiusmod tempor incididunt")) (ert-deftest evil-test-number-registers-delete () "Test number register behavior after `evil-delete'" + :tags '(evil registers) (dotimes (i 10) (evil-set-register (+ ?0 i) "")) (ert-info ("deletions without named register") @@ -9695,7 +9700,7 @@ parameter set." (evil-tests-initialize)) (ert-deftest evil-test-black-hole-register () - :tags '(evil) + :tags '(evil registers) (ert-info ("Test \"_ on delete word") (evil-test-buffer "[E]vil evil is awesome." From ad7bd8f3afd9286f0fa09c3fda1e0ec51bd665e4 Mon Sep 17 00:00:00 2001 From: Nathaniel Nicandro Date: Fri, 10 May 2024 13:14:50 -0500 Subject: [PATCH 6/7] Remove setting of small delete register in `evil-delete` The setting of registers is now handled by the eventual call to `evil-kill-new` when calling `evil-yank`. --- evil-commands.el | 5 ----- 1 file changed, 5 deletions(-) diff --git a/evil-commands.el b/evil-commands.el index bcdaab85..f86b246f 100644 --- a/evil-commands.el +++ b/evil-commands.el @@ -1482,11 +1482,6 @@ See `evil-kill-new' for more details on how text is saved." (setq beg (car new-range) end (cadr new-range) type 'line))) - (unless register - (let ((text (filter-buffer-substring beg end))) - (unless (string-match-p "\n" text) - ;; set the small delete register - (evil-set-register ?- text)))) (let ((this-command 'evil-delete)) (evil-yank beg end type register yank-handler)) (cond From 45f3ffe22dd1ac6c8bbfd09d100382e278d379f3 Mon Sep 17 00:00:00 2001 From: Nathaniel Nicandro Date: Tue, 14 May 2024 20:56:48 -0500 Subject: [PATCH 7/7] Fix `evil-test-visual-paste` tests Some of the tests assumed that the delete registers 1-9 store yanked text, this is no longer the case. Those registers now store only deleted text. --- evil-tests.el | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/evil-tests.el b/evil-tests.el index a1b39356..47998309 100644 --- a/evil-tests.el +++ b/evil-tests.el @@ -3087,38 +3087,35 @@ cccc cccc")))) ";; This buffer is for notes you don't want to save. \[;]; This buffer is for notes you don't want to save.") (ert-info ("Visual-paste from register 3") - ;; This behaviour deviates from vim, which populates registers 1-9 with - ;; deleted text only, not yanked text. This is an aspect of `evil-yank's - ;; use of the emacs kill-ring, so is consistent with non-visual paste. (evil-test-buffer - "[w]ord1a word1b word1c word1d + "[w]ord1a\nword1b\nword1c\nword1d word2a word2b word2c word2d" - ("yiwwyiwwyiw") - "word1a word1b [w]ord1c word1d + ("dddddd") + "[w]ord1d word2a word2b word2c word2d" ("+viw\"3p") - "word1a word1b word1c word1d -word1[a] word2b word2c word2d")) + "word1d +\n[w]ord1a\n word2b word2c word2d")) (ert-info ("Visual-paste respects `evil-kill-on-visual-paste'") (evil-test-buffer "[w]ord1 word2 word3" (setq evil-kill-on-visual-paste nil) ("yewyew") "word1 word2 [w]ord3" - ("ve\"2p") - "word1 word2 word[1]" + ("ve\"0p") + "word1 word2 word[2]" ("o\C-r\"") - "word1 word2 word1 + "word1 word2 word2 word2[]") (evil-test-buffer "[w]ord1 word2 word3" (setq evil-kill-on-visual-paste t) ("yewyew") "word1 word2 [w]ord3" - ("ve\"2p") - "word1 word2 word[1]" + ("ve\"0p") + "word1 word2 word[2]" ("o\C-r\"") - "word1 word2 word1 + "word1 word2 word2 word3[]")) (ert-info ("Visual-paste from `=' register") (evil-test-buffer