[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: kill-new may replace the wrong item
From: |
Leo |
Subject: |
Re: kill-new may replace the wrong item |
Date: |
Wed, 2 Jun 2010 04:10:49 +0100 |
On 1 June 2010 20:58, Juri Linkov <address@hidden> wrote:
>> In the BODY of kill-new, it sets REPLACE t if the new entry is the same
>> as the head of the kill-ring.
>>
>> When save-interprogram-paste-before-kill is non-nil, at the time of
>> replacing it may replace the entry from 'clipboard' instead of the one
>> it used to set REPLACE to t.
>>
>> Is this a bug?
>
> I have non-nil save-interprogram-paste-before-kill and non-nil
> kill-do-not-save-duplicates, but I never noticed a problem with them.
>
> Could you please provide step-by-step test case to reproduce this?
I was debugging another problem due to pasting images but it was not
the fault of kill-new.
The problem with kill-new is as commented here:
;;; 1. here REPLACE is set to T according to the CAR at this time.
(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))))
;;; 2. things from clipboard or whatnot get pushed into 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)))))
;;; 3. when REPLACE happens, CAR may have changed due to step 2
(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)))
So kill-new could end up replacing the item it is not supposed to replace.
> --
> Juri Linkov
> http://www.jurta.org/emacs/
Leo