summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1995-08-06 07:18:06 +0000
committerRichard M. Stallman <rms@gnu.org>1995-08-06 07:18:06 +0000
commitbd5671fa303228af0dacd0e0ef4cf4f2516af6d3 (patch)
treeab7a4492ad7cfcdba24c93772d975cd536612f9a /lisp
parent131ba1257164e37c159278f487b1c407840af68f (diff)
downloademacs-bd5671fa303228af0dacd0e0ef4cf4f2516af6d3.tar.gz
(delete-selection-pre-hook): New type value `yank'.
(yank): Use `yank' as delete-selection property.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/delsel.el11
1 files changed, 10 insertions, 1 deletions
diff --git a/lisp/delsel.el b/lisp/delsel.el
index 4d52ab2f7ba..4b61f8130d0 100644
--- a/lisp/delsel.el
+++ b/lisp/delsel.el
@@ -51,6 +51,15 @@ insertion commands first delete the region and then insert.")
(get this-command 'delete-selection))))
(cond ((eq type 'kill)
(delete-active-region t))
+ ((eq type 'yank)
+ ;; Before a yank command,
+ ;; make sure we don't yank the same region
+ ;; that we are going to delete.
+ ;; That would make yank a no-op.
+ (if (string= (buffer-substring (point) (mark))
+ (car kill-ring))
+ (current-kill 1))
+ (delete-active-region nil))
((eq type 'supersede)
(if (delete-active-region nil)
(setq this-command '(lambda () (interactive)))))
@@ -62,7 +71,7 @@ insertion commands first delete the region and then insert.")
(put 'self-insert-command 'delete-selection t)
(put 'self-insert-iso 'delete-selection t)
-(put 'yank 'delete-selection t)
+(put 'yank 'delete-selection 'yank)
(put 'insert-register 'delete-selection t)
(put 'delete-backward-char 'delete-selection 'supersede)