GNU bug report logs - #57147
27.2; Problem with kill-new

Previous Next

Package: emacs;

Reported by: Ihor Radchenko <yantar92 <at> gmail.com>

Date: Fri, 12 Aug 2022 00:34:01 UTC

Severity: normal

Merged with 57148

Found in version 27.2

Done: Po Lu <luangruo <at> yahoo.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 57147 in the body.
You can then email your comments to 57147 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#57147; Package emacs. (Fri, 12 Aug 2022 00:34:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ihor Radchenko <yantar92 <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 12 Aug 2022 00:34:01 GMT) Full text and rfc822 format available.

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

From: Ihor Radchenko <yantar92 <at> gmail.com>
To: alain.cochard <at> unistra.fr
Cc: bug-gnu-emacs <at> gnu.org
Subject: Re: 27.2; Problem with kill-new
Date: Fri, 12 Aug 2022 08:34:40 +0800
Alain.Cochard <at> unistra.fr writes:

> 3. emacs -Q -l /path/to/bug.el /path/to/bug.org
> 4. S-<TAB>
> 5. M-x my/copy-const
> 6. C-y
>
> Expected: "Constant string" is inserted
> Observed: Selected region is inserted.

An amendment to the recipe:

4.5. Move point to bob, activate mark, and select down to the eob

The whole Org buffer should be selected.

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92




Forcibly Merged 57147 57148. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 12 Aug 2022 15:16:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57147; Package emacs. (Fri, 12 Aug 2022 15:55:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Ihor Radchenko <yantar92 <at> gmail.com>
Cc: po Po Lu <luangruo <at> yahoo.com>, 57148 <at> debbugs.gnu.org,
 alain.cochard <at> unistra.fr, 57147 <at> debbugs.gnu.org
Subject: Re: bug#57148: 27.2; Problem with kill-new
Date: Fri, 12 Aug 2022 17:53:57 +0200
Ihor Radchenko <yantar92 <at> gmail.com> writes:

>> 3. emacs -Q -l /path/to/bug.el /path/to/bug.org
>> 4. S-<TAB>
>> 5. M-x my/copy-const
>> 6. C-y
>>
>> Expected: "Constant string" is inserted
>> Observed: Selected region is inserted.
>
> An amendment to the recipe:
>
> 4.5. Move point to bob, activate mark, and select down to the eob
>
> The whole Org buffer should be selected.

I have not tried to debug this, but if I remember correctly, there's
been some changes in the selection ownership code lately, so I'm adding
Po Lu to the CCs.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57147; Package emacs. (Sat, 13 Aug 2022 02:00:02 GMT) Full text and rfc822 format available.

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

From: Po Lu <luangruo <at> yahoo.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 57148 <at> debbugs.gnu.org, 57147 <at> debbugs.gnu.org,
 Ihor Radchenko <yantar92 <at> gmail.com>, alain.cochard <at> unistra.fr
Subject: Re: bug#57148: 27.2; Problem with kill-new
Date: Sat, 13 Aug 2022 09:59:21 +0800
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> I have not tried to debug this, but if I remember correctly, there's
> been some changes in the selection ownership code lately, so I'm adding
> Po Lu to the CCs.

Isn't this report for Emacs 27.2, before any changes were made to the
selection code?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57147; Package emacs. (Sat, 13 Aug 2022 02:44:02 GMT) Full text and rfc822 format available.

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

From: Alain.Cochard <at> unistra.fr
To: Po Lu <luangruo <at> yahoo.com>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 57148 <at> debbugs.gnu.org,
 57147 <at> debbugs.gnu.org, Ihor Radchenko <yantar92 <at> gmail.com>,
 alain.cochard <at> unistra.fr
Subject: Re: bug#57148: 27.2; Problem with kill-new
Date: Sat, 13 Aug 2022 04:43:17 +0200
Po Lu writes on Sat 13 Aug 2022 09:59:

 > Isn't this report for Emacs 27.2, before any changes were made to
 > the selection code?

But I can reproduce with Emacs 28.1 the problem I have with org-mode
(https://list.orgmode.org/87czd8e7wf.fsf <at> localhost/).

GNU Emacs 28.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.30,
cairo version 1.17.4) of 2022-07-12






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57147; Package emacs. (Sat, 13 Aug 2022 06:16:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: alain.cochard <at> unistra.fr
Cc: yantar92 <at> gmail.com, 57147 <at> debbugs.gnu.org, luangruo <at> yahoo.com,
 57148 <at> debbugs.gnu.org, alain.cochard <at> unistra.fr, larsi <at> gnus.org
Subject: Re: bug#57147: bug#57148: 27.2; Problem with kill-new
Date: Sat, 13 Aug 2022 09:15:12 +0300
> Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 57148 <at> debbugs.gnu.org,
>  57147 <at> debbugs.gnu.org, Ihor Radchenko <yantar92 <at> gmail.com>,
>  alain.cochard <at> unistra.fr
> Date: Sat, 13 Aug 2022 04:43:17 +0200
> From: Alain.Cochard <at> unistra.fr
> 
> Po Lu writes on Sat 13 Aug 2022 09:59:
> 
>  > Isn't this report for Emacs 27.2, before any changes were made to
>  > the selection code?
> 
> But I can reproduce with Emacs 28.1 the problem I have with org-mode
> (https://list.orgmode.org/87czd8e7wf.fsf <at> localhost/).

The changes Po Lu mentions were done in Emacs 29, so please try that
if you can.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57147; Package emacs. (Sat, 13 Aug 2022 09:21:02 GMT) Full text and rfc822 format available.

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

From: Ihor Radchenko <yantar92 <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: luangruo <at> yahoo.com, larsi <at> gnus.org, 57148 <at> debbugs.gnu.org,
 alain.cochard <at> unistra.fr, 57147 <at> debbugs.gnu.org
Subject: Re: bug#57147: bug#57148: 27.2; Problem with kill-new
Date: Sat, 13 Aug 2022 17:21:21 +0800
Eli Zaretskii <eliz <at> gnu.org> writes:

>> But I can reproduce with Emacs 28.1 the problem I have with org-mode
>> (https://list.orgmode.org/87czd8e7wf.fsf <at> localhost/).
>
> The changes Po Lu mentions were done in Emacs 29, so please try that
> if you can.

I can reproduce using Emacs 29:

GNU Emacs 29.0.50
Development version e2ccd358c9d5 on master branch; build date 2022-07-17.

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57147; Package emacs. (Sat, 13 Aug 2022 09:42:02 GMT) Full text and rfc822 format available.

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

From: Po Lu <luangruo <at> yahoo.com>
To: Ihor Radchenko <yantar92 <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 57148 <at> debbugs.gnu.org, 57147 <at> debbugs.gnu.org,
 larsi <at> gnus.org, alain.cochard <at> unistra.fr
Subject: Re: bug#57147: bug#57148: 27.2; Problem with kill-new
Date: Sat, 13 Aug 2022 17:40:58 +0800
Ihor Radchenko <yantar92 <at> gmail.com> writes:

> I can reproduce using Emacs 29:
>
> GNU Emacs 29.0.50
> Development version e2ccd358c9d5 on master branch; build date 2022-07-17.

Thanks.  I can't find the rest of this bug report inside
"gnus-read-ephemeral-bug-group", so could you please explain what the
problem is and how to reproduce it?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57147; Package emacs. (Sat, 13 Aug 2022 09:56:01 GMT) Full text and rfc822 format available.

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

From: Ihor Radchenko <yantar92 <at> gmail.com>
To: Po Lu <luangruo <at> yahoo.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 57148 <at> debbugs.gnu.org, 57147 <at> debbugs.gnu.org,
 larsi <at> gnus.org, alain.cochard <at> unistra.fr
Subject: Re: bug#57147: bug#57148: 27.2; Problem with kill-new
Date: Sat, 13 Aug 2022 17:56:20 +0800
Po Lu <luangruo <at> yahoo.com> writes:

> Thanks.  I can't find the rest of this bug report inside
> "gnus-read-ephemeral-bug-group", so could you please explain what the
> problem is and how to reproduce it?

I think that's because I accidentally replied to the report before it
got registered by debbugs.

Anyway, here is the recipe:

1. Create bug.el with the following contents:
----
(custom-set-variables
 '(select-enable-clipboard nil)
 '(select-enable-primary t))
(defun my/copy-const (beg end)
  (interactive "r")
  (setq deactivate-mark t)
  (kill-new "Constant string"))
----
2. Create bug.org with the following contents:
----
* headline
Hidden text inside
* another headline
----
3. emacs -Q -l /path/to/bug.el /path/to/bug.org
4. S-<TAB>
5. Move point to bob, activate mark, and select down to the eob
6. M-x my/copy-const
7. C-y

Expected: "Constant string" is inserted
Observed: Selected region is inserted.


-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57147; Package emacs. (Sat, 13 Aug 2022 11:55:02 GMT) Full text and rfc822 format available.

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

From: Po Lu <luangruo <at> yahoo.com>
To: Ihor Radchenko <yantar92 <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 57148 <at> debbugs.gnu.org, 57147 <at> debbugs.gnu.org,
 larsi <at> gnus.org, alain.cochard <at> unistra.fr
Subject: Re: bug#57147: bug#57148: 27.2; Problem with kill-new
Date: Sat, 13 Aug 2022 19:54:25 +0800
Ihor Radchenko <yantar92 <at> gmail.com> writes:

> I think that's because I accidentally replied to the report before it
> got registered by debbugs.
>
> Anyway, here is the recipe:
>
> 1. Create bug.el with the following contents:
> ----
> (custom-set-variables
>  '(select-enable-clipboard nil)
>  '(select-enable-primary t))
> (defun my/copy-const (beg end)
>   (interactive "r")
>   (setq deactivate-mark t)
>   (kill-new "Constant string"))
> ----
> 2. Create bug.org with the following contents:
> ----
> * headline
> Hidden text inside
> * another headline
> ----
> 3. emacs -Q -l /path/to/bug.el /path/to/bug.org
> 4. S-<TAB>
> 5. Move point to bob, activate mark, and select down to the eob
> 6. M-x my/copy-const
> 7. C-y
>
> Expected: "Constant string" is inserted
> Observed: Selected region is inserted.

This is intended behavior.  Deactivating the mark will always assert
ownership over the primary selection with the contents of the region.

See the doc string of `deactivate-mark' for more details.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57147; Package emacs. (Sat, 13 Aug 2022 12:20:03 GMT) Full text and rfc822 format available.

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

From: Ihor Radchenko <yantar92 <at> gmail.com>
To: Po Lu <luangruo <at> yahoo.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 57148 <at> debbugs.gnu.org, 57147 <at> debbugs.gnu.org,
 larsi <at> gnus.org, alain.cochard <at> unistra.fr
Subject: Re: bug#57147: bug#57148: 27.2; Problem with kill-new
Date: Sat, 13 Aug 2022 20:20:48 +0800
Po Lu <luangruo <at> yahoo.com> writes:

>> Expected: "Constant string" is inserted
>> Observed: Selected region is inserted.
>
> This is intended behavior.  Deactivating the mark will always assert
> ownership over the primary selection with the contents of the region.
>
> See the doc string of `deactivate-mark' for more details.

Can this behaviour be disabled then? It is clearly not the user intention
here when the user calls a function that is supposed to push some
filtered text to `kill-ring' right before deactivating the region.

I am thinking about workaround like

;; Prevent Emacs from adding full selected text to `kill-ring'
;; when `select-enable-primary' is non-nil.
(setq-local filter-buffer-substring-function
            `(lambda (&rest _)
               (setq-local filter-buffer-substring-function
                           ',filter-buffer-substring-function)
               nil))

which seems to work, but looks like a hack.

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57147; Package emacs. (Sat, 13 Aug 2022 12:29:02 GMT) Full text and rfc822 format available.

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

From: Po Lu <luangruo <at> yahoo.com>
To: Ihor Radchenko <yantar92 <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 57148 <at> debbugs.gnu.org, 57147 <at> debbugs.gnu.org,
 larsi <at> gnus.org, alain.cochard <at> unistra.fr
Subject: Re: bug#57147: bug#57148: 27.2; Problem with kill-new
Date: Sat, 13 Aug 2022 20:28:08 +0800
Ihor Radchenko <yantar92 <at> gmail.com> writes:

> Can this behaviour be disabled then?

Sure, we could add a flag that tells deactivate-mark not to save the
region.  But others might object, so I'd rather wait a while before
doing that.

> It is clearly not the user intention here when the user calls a
> function that is supposed to push some filtered text to `kill-ring'
> right before deactivating the region.

I agree.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57147; Package emacs. (Sat, 13 Aug 2022 12:33:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Po Lu <luangruo <at> yahoo.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 57148 <at> debbugs.gnu.org, 57147 <at> debbugs.gnu.org,
 Ihor Radchenko <yantar92 <at> gmail.com>, alain.cochard <at> unistra.fr
Subject: Re: bug#57147: bug#57148: 27.2; Problem with kill-new
Date: Sat, 13 Aug 2022 14:32:12 +0200
Po Lu <luangruo <at> yahoo.com> writes:

>> Can this behaviour be disabled then?
>
> Sure, we could add a flag that tells deactivate-mark not to save the
> region.  But others might object, so I'd rather wait a while before
> doing that.

The variable is currently:

---
deactivate-mark is a variable defined in src/keyboard.c.

[...]

If an editing command sets this to t, deactivate the mark afterward.
---

So adding a new value like `no-save' should be safe.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57147; Package emacs. (Sat, 13 Aug 2022 13:14:02 GMT) Full text and rfc822 format available.

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

From: Po Lu <luangruo <at> yahoo.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 57148 <at> debbugs.gnu.org, 57147 <at> debbugs.gnu.org,
 Ihor Radchenko <yantar92 <at> gmail.com>, alain.cochard <at> unistra.fr
Subject: Re: bug#57147: bug#57148: 27.2; Problem with kill-new
Date: Sat, 13 Aug 2022 21:13:43 +0800
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> So adding a new value like `no-save' should be safe.

Now done (though I named it dont-save instead).  Ihor, can you see if
using that value solves the problem for you as well?

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57147; Package emacs. (Sat, 13 Aug 2022 14:38:02 GMT) Full text and rfc822 format available.

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

From: Ihor Radchenko <yantar92 <at> gmail.com>
To: Po Lu <luangruo <at> yahoo.com>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 57148 <at> debbugs.gnu.org,
 57147 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>, alain.cochard <at> unistra.fr
Subject: Re: bug#57147: bug#57148: 27.2; Problem with kill-new
Date: Sat, 13 Aug 2022 22:37:59 +0800
Po Lu <luangruo <at> yahoo.com> writes:

> Lars Ingebrigtsen <larsi <at> gnus.org> writes:
>
>> So adding a new value like `no-save' should be safe.
>
> Now done (though I named it dont-save instead).  Ihor, can you see if
> using that value solves the problem for you as well?

Yep. I just tested modifying the recipe to use 'dont-save instead of t
and the text is yanked as expected. Same for the original issue with
org-copy-visible.

Thanks!

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92




Reply sent to Po Lu <luangruo <at> yahoo.com>:
You have taken responsibility. (Sun, 14 Aug 2022 01:20:02 GMT) Full text and rfc822 format available.

Notification sent to Ihor Radchenko <yantar92 <at> gmail.com>:
bug acknowledged by developer. (Sun, 14 Aug 2022 01:20:02 GMT) Full text and rfc822 format available.

Message #51 received at 57147-done <at> debbugs.gnu.org (full text, mbox):

From: Po Lu <luangruo <at> yahoo.com>
To: Ihor Radchenko <yantar92 <at> gmail.com>
Cc: alain.cochard <at> unistra.fr, Lars Ingebrigtsen <larsi <at> gnus.org>,
 57147-done <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>,
 57148-done <at> debbugs.gnu.org
Subject: Re: bug#57147: bug#57148: 27.2; Problem with kill-new
Date: Sun, 14 Aug 2022 09:19:11 +0800
Ihor Radchenko <yantar92 <at> gmail.com> writes:

> Yep. I just tested modifying the recipe to use 'dont-save instead of t
> and the text is yanked as expected. Same for the original issue with
> org-copy-visible.

Thanks for testing, closing.

(I hope I'm doing this correctly, there are two debbugs addresses in Cc.)




Reply sent to Po Lu <luangruo <at> yahoo.com>:
You have taken responsibility. (Sun, 14 Aug 2022 01:20:02 GMT) Full text and rfc822 format available.

Notification sent to alain.cochard <at> unistra.fr:
bug acknowledged by developer. (Sun, 14 Aug 2022 01:20: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. (Sun, 11 Sep 2022 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 224 days ago.

Previous Next


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