branch: externals/ivy-hydra
commit a33af9bfef82d4ab735728a30e91e8563224c5f8
Author: Basil L. Contovounesios <[email protected]>
Commit: Oleh Krehel <[email protected]>
Unset yank-undo-function in counsel-yank-pop
* counsel.el (counsel-yank-pop-action): Unset yank-undo-function
before calling yank-pop, to avoid deleting the region when
yank-undo-function is set but the last command was not really a
yank. Suggested by Gustavo Barros.
Fixes #2714.
---
counsel.el | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/counsel.el b/counsel.el
index db0e612..b762b1a 100644
--- a/counsel.el
+++ b/counsel.el
@@ -4432,13 +4432,18 @@ Signal a `buffer-read-only' error if called from a
read-only
buffer position."
(with-ivy-window
(barf-if-buffer-read-only)
- (setq last-command 'yank)
(setq yank-window-start (window-start))
+ (unless (eq last-command 'yank)
+ ;; Avoid unexpected deletions with `yank-handler' properties.
+ (setq yank-undo-function nil))
(condition-case nil
- ;; Avoid unexpected additions to `kill-ring'
- (let (interprogram-paste-function)
+ (let (;; Deceive `yank-pop'.
+ (last-command 'yank)
+ ;; Avoid unexpected additions to `kill-ring'.
+ interprogram-paste-function)
(yank-pop (counsel--yank-pop-position s)))
(error
+ ;; Support strings not present in the kill ring.
(insert s)))
(when (funcall (if counsel-yank-pop-after-point #'> #'<)
(point) (mark t))