From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.bugs Subject: bug#31097: 27.0.50; Interprogram paste is destructively modified Date: Fri, 13 Apr 2018 12:56:38 +0100 Message-ID: <87woxbb9qh.fsf@tcd.ie> References: <87fu45loow.fsf@tcd.ie> <87bmetloaq.fsf@tcd.ie> <87a7u8kng0.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1523620513 23407 195.159.176.226 (13 Apr 2018 11:55:13 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 13 Apr 2018 11:55:13 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 31097@debbugs.gnu.org To: Noam Postavsky Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Apr 13 13:55:08 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f6xII-0005sE-69 for geb-bug-gnu-emacs@m.gmane.org; Fri, 13 Apr 2018 13:55:06 +0200 Original-Received: from localhost ([::1]:47539 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f6xKN-0007bo-0i for geb-bug-gnu-emacs@m.gmane.org; Fri, 13 Apr 2018 07:57:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43835) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f6xKF-0007bK-RD for bug-gnu-emacs@gnu.org; Fri, 13 Apr 2018 07:57:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f6xKA-0004zo-UG for bug-gnu-emacs@gnu.org; Fri, 13 Apr 2018 07:57:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:41258) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f6xKA-0004zT-Fz for bug-gnu-emacs@gnu.org; Fri, 13 Apr 2018 07:57:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1f6xKA-0002bS-6K for bug-gnu-emacs@gnu.org; Fri, 13 Apr 2018 07:57:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Basil L. Contovounesios" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 13 Apr 2018 11:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31097 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 31097-submit@debbugs.gnu.org id=B31097.15236206089984 (code B ref 31097); Fri, 13 Apr 2018 11:57:02 +0000 Original-Received: (at 31097) by debbugs.gnu.org; 13 Apr 2018 11:56:48 +0000 Original-Received: from localhost ([127.0.0.1]:49155 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f6xJv-0002ay-U9 for submit@debbugs.gnu.org; Fri, 13 Apr 2018 07:56:48 -0400 Original-Received: from mail-wr0-f171.google.com ([209.85.128.171]:35892) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f6xJu-0002ai-AN for 31097@debbugs.gnu.org; Fri, 13 Apr 2018 07:56:46 -0400 Original-Received: by mail-wr0-f171.google.com with SMTP id q13so4605827wre.3 for <31097@debbugs.gnu.org>; Fri, 13 Apr 2018 04:56:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=jaeSVbxqvV/HYJWJytSSCPb8X1mGfPI3oCxy3lYnM44=; b=TgM/FjVImTKVZtuj0iPbOKicMMF9r0bcmEMUkZUYGn3LUFyag/r0xrZDaai8xnYhm5 j0P3zpAcfvEQArXlys40gjHwPQyWTzC1Ik3YWfvgHBaBWj5qJuBGWxJdZfEnXaNZnwvZ Edady16o2dn4jmsrFpqIac+SRoFb5B/W/GDSsgO+5QQ+e8mD3NSaHMtRfVf03bzikQaM FJSV1OqjVqQjD6c0dyKCcRCoibd6uZhz0sb72HHYp6N2Nv1TDj7Slx30LTU+d/FeM8KS ry6gM2mzG43lQ8dyJX3z0rGjKpnHHGseiS0eBQFLCk+QFBjir3AmIG8mbCAfZD+9AsLm 7rsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=jaeSVbxqvV/HYJWJytSSCPb8X1mGfPI3oCxy3lYnM44=; b=CuuPfFMR4n9A/JRQ7vaWUw55Fb+KVE9xFn6vQmPkRn/G7+MZro4qtfM9IlTnvwa6yV L0g9AqKcOZyYKdFaTZwRmP/FIoTsMEYQ1JKstVbLWkOhd+800Sr8JssuNJEqfHBZubtn aDgLxMlNCPTD+RpRSQKJvpANP4T/HbB8txZT+frIGW7coI3HrumN+qrkOoHnBD2lhjg5 1sFrlke/zlRenSk7VFdeiTqg7ZCmFCuF4ndDn8qWqOqubbRkgD6AxNscVGytzrz/1bud USnVObeH0VyOulyzWCc/UNzYZtqMHnzMtuU3BC1fZTIy0DNsMHYBpCL4WQIPj1m7x2lN ZwMQ== X-Gm-Message-State: ALQs6tCqUcQTr3SK5SQ1FTO3F3IgWHzFhsewh81bN0ZN9T2IZ9xDgs30 fxmYo3cGZEAtG0ZwNvqoFaPcpQ== X-Google-Smtp-Source: AIpwx49vvklszJgG6H65gFPM915BzOFxELefmN9hdTlIebUV+ipTvs8mW8+AMO3pfl6IlHDLmOwmCA== X-Received: by 10.223.193.5 with SMTP id r5mr3314557wre.274.1523620600255; Fri, 13 Apr 2018 04:56:40 -0700 (PDT) Original-Received: from localhost ([86.43.118.33]) by smtp.gmail.com with ESMTPSA id h9sm1220192wmc.13.2018.04.13.04.56.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Apr 2018 04:56:39 -0700 (PDT) In-Reply-To: <87a7u8kng0.fsf@gmail.com> (Noam Postavsky's message of "Thu, 12 Apr 2018 19:35:43 -0400") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:145248 Archived-At: --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Do-not-destructively-modify-interprogram-paste.patch Content-Description: Updated patch >From 5bde054f8c80f64c15e105e21aaddccff67d9e7a Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Fri, 13 Apr 2018 12:47:30 +0100 Subject: [PATCH] Do not destructively modify interprogram paste * simple.el (kill-new, current-kill): Non-destructively reverse list returned by interprogram-paste-function. (bug#31097) --- lisp/simple.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lisp/simple.el b/lisp/simple.el index efe5406bf7..19e41344d1 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -4369,7 +4369,8 @@ kill-new (funcall interprogram-paste-function)))) (when interprogram-paste (dolist (s (if (listp interprogram-paste) - (nreverse interprogram-paste) + ;; Use `reverse' to avoid modifying external data + (reverse interprogram-paste) (list interprogram-paste))) (unless (and kill-do-not-save-duplicates (equal-including-properties s (car kill-ring))) @@ -4448,7 +4449,8 @@ current-kill ;; selection, with identical text. (let ((interprogram-cut-function nil)) (if (listp interprogram-paste) - (mapc 'kill-new (nreverse interprogram-paste)) + ;; Use `reverse' to avoid modifying external data + (mapc #'kill-new (reverse interprogram-paste)) (kill-new interprogram-paste))) (car kill-ring)) (or kill-ring (error "Kill ring is empty")) -- 2.16.3 --=-=-= Content-Type: text/plain Noam Postavsky writes: > "Basil L. Contovounesios" writes: > >> * simple.el (kill-new, current-kill): Non-destructively reverse list >> returned by interprogram-paste-function. (bug#31097) > > Seems reasonable. Perhaps add some comments in case someone tries to > "optimize" it later? Are the comments in the updated patch attached clear enough? >> If optional arg DO-NOT-MOVE is non-nil, then don't actually >> move the yanking point; just return the Nth kill forward." >> - >> (let ((interprogram-paste (and (= n 0) > >> - (let ((ARGth-kill-element >> + (let ((nth-kill-element >> (nthcdr (mod (- n (length kill-ring-yank-pointer)) >> (length kill-ring)) >> kill-ring))) >> (unless do-not-move >> - (setq kill-ring-yank-pointer ARGth-kill-element) >> + (setq kill-ring-yank-pointer nth-kill-element) >> (when (and yank-pop-change-selection >> (> n 0) >> interprogram-cut-function) >> - (funcall interprogram-cut-function (car ARGth-kill-element)))) >> - (car ARGth-kill-element))))) >> + (funcall interprogram-cut-function (car nth-kill-element)))) >> + (car nth-kill-element))))) > > I don't think these hunks are needed. Fair enough, I just thought it was strange having an ARGth element without an ARG. Thanks, -- Basil --=-=-=--