GNU bug report logs - #31097
27.0.50; Interprogram paste is destructively modified

Previous Next

Package: emacs;

Reported by: "Basil L. Contovounesios" <contovob <at> tcd.ie>

Date: Sun, 8 Apr 2018 15:11:01 UTC

Severity: minor

Tags: fixed, patch

Found in version 27.0.50

Fixed in version 27.1

Done: Noam Postavsky <npostavs <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 31097 in the body.
You can then email your comments to 31097 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#31097; Package emacs. (Sun, 08 Apr 2018 15:11:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Basil L. Contovounesios" <contovob <at> tcd.ie>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 08 Apr 2018 15:11:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.0.50; Interprogram paste is destructively modified
Date: Sun, 08 Apr 2018 16:09:51 +0100
Consider the following case:

(defvar my-paste '("foo" "bar"))
(defun my-paste () my-paste)
(setq interprogram-paste-function #'my-paste)

my-paste           ; => ("foo" "bar")
(current-kill 0 t) ; => "foo"
my-paste           ; => ("foo")

This is clearly a contrived use of interprogram-paste-function, but IMO
functions ought not needlessly make destructive changes to non-internal
values not known to be newly created.

Patch to follow in case others share my opinion.

Thanks,

-- 
Basil

In GNU Emacs 27.0.50 (build 2, x86_64-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2018-04-08 built on thunk
Repository revision: 8df23a82042fa7dbaaa4377bc376d705595b073f
Windowing system distributor 'The X.Org Foundation', version 11.0.11906000
System Description: Debian GNU/Linux buster/sid

Configured features:
XAW3D XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS
NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS LUCID X11 MODULES THREADS LIBSYSTEMD JSON LCMS2




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31097; Package emacs. (Sun, 08 Apr 2018 15:19:02 GMT) Full text and rfc822 format available.

Message #8 received at 31097 <at> debbugs.gnu.org (full text, mbox):

From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: 31097 <at> debbugs.gnu.org
Subject: Re: bug#31097: 27.0.50; Interprogram paste is destructively modified
Date: Sun, 08 Apr 2018 16:18:21 +0100
[0001-Do-not-destructively-modify-interprogram-paste.patch (text/x-diff, attachment)]
[Message part 2 (text/plain, inline)]
"Basil L. Contovounesios" <contovob <at> tcd.ie> writes:

> Patch to follow in case others share my opinion.

I attach said patch.

Thanks,

-- 
Basil

Added tag(s) patch. Request was from "Basil L. Contovounesios" <contovob <at> tcd.ie> to control <at> debbugs.gnu.org. (Sun, 08 Apr 2018 15:22:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31097; Package emacs. (Thu, 12 Apr 2018 23:36:02 GMT) Full text and rfc822 format available.

Message #13 received at 31097 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> gmail.com>
To: "Basil L. Contovounesios" <contovob <at> tcd.ie>
Cc: 31097 <at> debbugs.gnu.org
Subject: Re: bug#31097: 27.0.50; Interprogram paste is destructively modified
Date: Thu, 12 Apr 2018 19:35:43 -0400
severity 31097 minor
quit

"Basil L. Contovounesios" <contovob <at> tcd.ie> 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?

>  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.




Severity set to 'minor' from 'normal' Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Thu, 12 Apr 2018 23:36:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31097; Package emacs. (Fri, 13 Apr 2018 11:57:02 GMT) Full text and rfc822 format available.

Message #18 received at 31097 <at> debbugs.gnu.org (full text, mbox):

From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: Noam Postavsky <npostavs <at> gmail.com>
Cc: 31097 <at> debbugs.gnu.org
Subject: Re: bug#31097: 27.0.50; Interprogram paste is destructively modified
Date: Fri, 13 Apr 2018 12:56:38 +0100
[0001-Do-not-destructively-modify-interprogram-paste.patch (text/x-diff, attachment)]
[Message part 2 (text/plain, inline)]
Noam Postavsky <npostavs <at> gmail.com> writes:

> "Basil L. Contovounesios" <contovob <at> tcd.ie> 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

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31097; Package emacs. (Sat, 14 Apr 2018 06:12:02 GMT) Full text and rfc822 format available.

Message #21 received at 31097 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> gmail.com>
To: "Basil L. Contovounesios" <contovob <at> tcd.ie>
Cc: 31097 <at> debbugs.gnu.org
Subject: Re: bug#31097: 27.0.50; Interprogram paste is destructively modified
Date: Sat, 14 Apr 2018 02:11:01 -0400
tags 31097 fixed
close 31097 27.1
quit

"Basil L. Contovounesios" <contovob <at> tcd.ie> writes:

>> Seems reasonable.  Perhaps add some comments in case someone tries to
>> "optimize" it later?
>
> Are the comments in the updated patch attached clear enough?

Yeah, seems fine.  I added periods at the end and pushed to master [1: 2825d84945].

> Fair enough, I just thought it was strange having an ARGth element
> without an ARG.

I don't disagree exactly, but it's kind of distracting when more than
half your patch is about an unrelated side-fix like that.

[1: 2825d84945]: 2018-04-14 01:20:03 -0400
  Do not destructively modify interprogram paste
  https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=2825d849451be45ea738e2d2b2567c834fe5a0fb>




Added tag(s) fixed. Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Sat, 14 Apr 2018 06:12:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 27.1, send any further explanations to 31097 <at> debbugs.gnu.org and "Basil L. Contovounesios" <contovob <at> tcd.ie> Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Sat, 14 Apr 2018 06:12:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 12 May 2018 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 7 years and 43 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.