[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: kill-new may replace the wrong item
From: |
Juri Linkov |
Subject: |
Re: kill-new may replace the wrong item |
Date: |
Thu, 03 Jun 2010 22:17:09 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu) |
> All I am trying to point out is there's something incorrect there.
The whole implementation of `kill-do-not-save-duplicates' is incorrect.
It should do nothing instead of setting `replace' to t and replacing the
same string with itself (that may override the value pushed from
`interprogram-paste' to `kill-ring').
I believe this patch will provide the consistent interaction between
`kill-do-not-save-duplicates' and `save-interprogram-paste-before-kill'.
Before pushing a string to kill-ring it compares the head of kill-ring with
the string from interprogram-paste and later with the input argument `string':
=== modified file 'lisp/simple.el'
--- lisp/simple.el 2010-05-19 19:17:29 +0000
+++ lisp/simple.el 2010-06-03 19:16:18 +0000
@@ -3009,24 +3009,25 @@ (defun kill-new (string &optional replac
(if yank-handler
(signal 'args-out-of-range
(list string "yank-handler specified for empty string"))))
- (when (and kill-do-not-save-duplicates
- (equal string (car kill-ring)))
- (setq replace t))
(if (fboundp 'menu-bar-update-yank-menu)
(menu-bar-update-yank-menu string (and replace (car kill-ring))))
(when save-interprogram-paste-before-kill
(let ((interprogram-paste (and interprogram-paste-function
(funcall interprogram-paste-function))))
(when interprogram-paste
- (if (listp interprogram-paste)
- (dolist (s (nreverse interprogram-paste))
- (push s kill-ring))
- (push interprogram-paste kill-ring)))))
- (if (and replace kill-ring)
- (setcar kill-ring string)
- (push string kill-ring)
- (if (> (length kill-ring) kill-ring-max)
- (setcdr (nthcdr (1- kill-ring-max) kill-ring) nil)))
+ (dolist (s (if (listp interprogram-paste)
+ (nreverse interprogram-paste)
+ (list interprogram-paste)))
+ (unless (and kill-do-not-save-duplicates
+ (equal s (car kill-ring)))
+ (push s kill-ring))))))
+ (unless (and kill-do-not-save-duplicates
+ (equal string (car kill-ring)))
+ (if (and replace kill-ring)
+ (setcar kill-ring string)
+ (push string kill-ring)
+ (if (> (length kill-ring) kill-ring-max)
+ (setcdr (nthcdr (1- kill-ring-max) kill-ring) nil))))
(setq kill-ring-yank-pointer kill-ring)
(if interprogram-cut-function
(funcall interprogram-cut-function string (not replace))))
--
Juri Linkov
http://www.jurta.org/emacs/