Subject: bug#31097: 27.0.50; Interprogram paste is destructively modified

From: "Basil L. Contovounesios" <[email-masked]>
Date: Sun, 08 Apr 2018 16:18:21 +0100

>From a5e62f9dafde2cc0695d26730b4b67d84ddfd88d Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <[email-masked]>
Date: Sun, 8 Apr 2018 15:31:57 +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 | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/lisp/simple.el b/lisp/simple.el
index 3d50e38b59..d81db16fff 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -4369,7 +4369,7 @@ kill-new
                                    (funcall interprogram-paste-function))))
       (when interprogram-paste
         (dolist (s (if (listp interprogram-paste)
-		       (nreverse interprogram-paste)
+                       (reverse interprogram-paste)
 		     (list interprogram-paste)))
 	  (unless (and kill-do-not-save-duplicates
 		       (equal-including-properties s (car kill-ring)))
@@ -4437,7 +4437,6 @@ current-kill
 
 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)
 				 interprogram-paste-function
 				 (funcall interprogram-paste-function))))
@@ -4448,21 +4447,21 @@ current-kill
 	  ;; selection, with identical text.
 	  (let ((interprogram-cut-function nil))
 	    (if (listp interprogram-paste)
-	      (mapc 'kill-new (nreverse interprogram-paste))
+                (mapc #'kill-new (reverse interprogram-paste))
 	      (kill-new interprogram-paste)))
 	  (car kill-ring))
       (or kill-ring (error "Kill ring is empty"))
-      (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)))))

-- 
2.16.3

"Basil L. Contovounesios" <[email-masked]> writes:

> Patch to follow in case others share my opinion.

I attach said patch.

Thanks,

-- 
Basil