unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Ignacio Casso <ignaciocasso@hotmail.com>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 53894@debbugs.gnu.org
Subject: bug#53894: 27.2; Clipboard copy -> C-y -> M-y -> Same clipboard copy does not push to kill ring
Date: Wed, 09 Feb 2022 13:52:20 +0100	[thread overview]
Message-ID: <PAXPR06MB77606A1A3C13AC4F23F6D513C62E9@PAXPR06MB7760.eurprd06.prod.outlook.com> (raw)
In-Reply-To: <87mtj0l0wp.fsf@gnus.org>

Hi Lars,

I read the debbugs.gnu.org thread about bug#27442 where you try to
figure out the reason behind that logic, and I think the conclusion you
arrive at is incomplete and that the bug I reported might give some more
insight about it. I might be wrong since I have not given that much
though to this, but here is what I mean:

Every time we yank, interprogram-paste-function is called. If it returns
nil we yank from the kill-ring, otherwise the returned string is pushed
to the kill-ring and yanked.

If we then rotate the kill ring, we do not want to paste from the
clipboard anymore, so interprogram-paste-function must return nil if
nothing newer has been copied to the clipboard. The way this is checked
is by just checking whether the clipboard content has changed.

If we do not rotate the kill ring, it doesn't matter if
interprogram-paste-function returns nil since the clipboard content is
already at the top of the kill-ring. In fact we need it to return nil in
order not to duplicate it in the kill ring.

So basically, while the content of the clipboard remains the same, we
want gui-selection-value to return it only the first time we call it
(for this use case at least), and from then onwards the kill ring will
handle it. That would be another reason behind that
logic aside from the one you thought of: ignoring clipboard content if it
was put there by Emacs itself with kill commands (since it's already in
the kill ring too).

This would also answer my original question: unless there was a
timestamp in the clipboard Emacs has indeed no way to know right now if
the exact same string was copied to the clipboard again in-between (in
which case I would expect it to be pushed to the top of the kill-ring
again)

Does it make sense?

Sorry if you had already figured it out or if I am wrong, I did not
understand the whole email thread nor debug this issue in depth. Or if
it's no longer relevant, but since I saw the email thread was less than
one year old I thought that you might want to know.

Regards,

Ignacio


Lars Ingebrigtsen <larsi@gnus.org> writes:

> Ignacio Casso <ignaciocasso@hotmail.com> writes:
>
>> I'm not sure if it's intentional or not, or even if Emacs can do
>> anything about it (maybe since the text is the same, the clipboard is not
>> actually modified and Emacs has no way to know). I just wanted to report
>> it in case it is a bug.
>
> It's intentional:
>
> (defun gui-selection-value ()
>   (let ((clip-text
>          (when select-enable-clipboard
>            (let ((text (gui--selection-value-internal 'CLIPBOARD)))
>              (when (string= text "")
>                (setq text nil))
>              ;; When `select-enable-clipboard' is non-nil,
>              ;; killing/copying text (with, say, `C-w') will push the
>              ;; text to the clipboard (and store it in
>              ;; `gui--last-selected-text-clipboard').  We check
>              ;; whether the text on the clipboard is identical to this
>              ;; text, and if so, we report that the clipboard is
>              ;; empty.  See (bug#27442) for further discussion about
>              ;; this DWIM action, and possible ways to make this check
>              ;; less fragile, if so desired.
>              (prog1
>                  (unless (equal text gui--last-selected-text-clipboard)
>                    text)
>                (setq gui--last-selected-text-clipboard text)))))
>
> But it's pretty fragile DWIM action, and is frequently not what I mean,
> so I often resort to `clipboard-yank' instead to ensure that I really
> get the clipboard contents.






  reply	other threads:[~2022-02-09 12:52 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-09  9:13 bug#53894: 27.2; Clipboard copy -> C-y -> M-y -> Same clipboard copy does not push to kill ring Ignacio Casso
2022-02-09 11:44 ` Lars Ingebrigtsen
2022-02-09 12:52   ` Ignacio Casso [this message]
2022-02-09 20:21     ` Lars Ingebrigtsen
2022-02-10  1:56       ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-10  6:20         ` Eli Zaretskii
2022-02-10  6:31           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-10  6:42             ` Lars Ingebrigtsen
2022-02-10  6:48               ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-10  8:37                 ` Lars Ingebrigtsen
2022-02-10 10:03                   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-10  6:39           ` Lars Ingebrigtsen
2022-02-10  8:06             ` Eli Zaretskii
2022-02-10  8:43               ` Lars Ingebrigtsen
2022-02-10 10:04                 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-10 11:37                   ` Lars Ingebrigtsen
2022-02-10 12:08                 ` Eli Zaretskii
2022-02-10 12:14                   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-10 12:29                     ` Eli Zaretskii
2022-02-10 12:38                       ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-10 12:49                         ` Lars Ingebrigtsen
2022-02-10 13:20                           ` Ignacio Casso
2022-02-11  1:05                             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-11 10:24                               ` Ignacio Casso
2022-02-11 11:16                                 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-11 11:28                                   ` Ignacio Casso
2022-02-11 12:38                                     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-11 12:42                                       ` Ignacio Casso
2022-02-11 12:58                                         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-12  2:28                                           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-27 18:57                                             ` Ignacio Casso
2022-02-28  1:01                                               ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-28 12:12                                                 ` Ignacio Casso
2022-02-28 13:35                                                   ` Eli Zaretskii
2022-02-28 14:22                                                     ` Ignacio Casso
2022-02-28 13:48                                                   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-28 14:35                                                     ` Ignacio Casso
     [not found]                                                     ` <87wnhfoy5h.fsf@hotmail.com>
2022-02-28 16:10                                                       ` Ignacio Casso
2022-03-01  0:42                                                         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-03-01  7:51                                                           ` Ignacio Casso
2022-03-01 13:19                                                             ` Eli Zaretskii
2022-03-01 15:29                                                               ` Ignacio Casso
2022-03-02  0:51                                                                 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-03-02  7:44                                                                   ` Ignacio Casso
2022-03-02  7:59                                                                     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-03-02  8:37                                                                       ` Ignacio Casso
2022-03-02 10:03                                                                         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-03-09  7:41                                                                           ` Ignacio Casso
2022-03-09 13:47                                                                             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-03-24 19:59                                                                           ` Ignacio Casso
2022-03-25  6:25                                                                             ` Eli Zaretskii
2022-03-29 12:01                                                                           ` Ignacio Casso
2022-03-29 13:00                                                                         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-04-01 10:15                                                                           ` Ignacio Casso
2022-04-01 10:59                                                                             ` Eli Zaretskii
2022-04-01 11:23                                                                               ` Ignacio Casso
2022-04-01 12:04                                                                                 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-04-01 12:15                                                                                   ` Eli Zaretskii
2022-04-01 12:57                                                                                     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-04-01 12:10                                                                                 ` Eli Zaretskii
2022-03-01 15:19                                                           ` Lars Ingebrigtsen
     [not found]                                                       ` <871qznc4qg.fsf@hotmail.com>
2022-02-28 16:56                                                         ` Ignacio Casso
     [not found]                                       ` <87v8xl376s.fsf@hotmail.com>
2022-02-11 12:48                                         ` Ignacio Casso
     [not found]                           ` <87pmnurelg.fsf@hotmail.com>
2022-02-10 14:29                             ` Ignacio Casso
2022-02-11  6:15                               ` Lars Ingebrigtsen
2022-02-11  8:16                                 ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=PAXPR06MB77606A1A3C13AC4F23F6D513C62E9@PAXPR06MB7760.eurprd06.prod.outlook.com \
    --to=ignaciocasso@hotmail.com \
    --cc=53894@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).