From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: kill-new may replace the wrong item Date: Thu, 03 Jun 2010 22:17:09 +0300 Organization: JURTA Message-ID: <874ohjj4x2.fsf@mail.jurta.org> References: <87d3wasfpf.fsf@mail.jurta.org> <87y6exp5zi.fsf@mail.jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1275593372 24161 80.91.229.12 (3 Jun 2010 19:29:32 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 3 Jun 2010 19:29:32 +0000 (UTC) Cc: emacs-devel@gnu.org To: Leo Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jun 03 21:29:30 2010 connect(): No such file or directory Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OKG6b-000765-6V for ged-emacs-devel@m.gmane.org; Thu, 03 Jun 2010 21:29:30 +0200 Original-Received: from localhost ([127.0.0.1]:49624 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OKG6X-0006jB-U8 for ged-emacs-devel@m.gmane.org; Thu, 03 Jun 2010 15:29:26 -0400 Original-Received: from [140.186.70.92] (port=58875 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OKG6P-0006fe-Ko for emacs-devel@gnu.org; Thu, 03 Jun 2010 15:29:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OKG6K-0006DV-36 for emacs-devel@gnu.org; Thu, 03 Jun 2010 15:29:17 -0400 Original-Received: from smtp-out1.starman.ee ([85.253.0.3]:51723 helo=mx1.starman.ee) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OKG6J-0006D4-Py for emacs-devel@gnu.org; Thu, 03 Jun 2010 15:29:12 -0400 X-Virus-Scanned: by Amavisd-New at mx1.starman.ee Original-Received: from mail.starman.ee (82.131.93.210.cable.starman.ee [82.131.93.210]) by mx1.starman.ee (Postfix) with ESMTP id EC4B73F40A3; Thu, 3 Jun 2010 22:29:07 +0300 (EEST) In-Reply-To: (Leo's message of "Wed, 2 Jun 2010 22:33:28 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:125488 Archived-At: > 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/