From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ignacio Casso Newsgroups: gmane.emacs.bugs 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 Message-ID: References: <87mtj0l0wp.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3575"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.6.10; emacs 27.2 Cc: 53894@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Feb 09 15:04:15 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nHnZu-0000dV-TW for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 09 Feb 2022 15:04:15 +0100 Original-Received: from localhost ([::1]:37900 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHnZt-00015S-VD for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 09 Feb 2022 09:04:14 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:56796) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHn0B-0006G3-F1 for bug-gnu-emacs@gnu.org; Wed, 09 Feb 2022 08:27:21 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:56316) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nHmzu-0004r3-Hb for bug-gnu-emacs@gnu.org; Wed, 09 Feb 2022 08:27:17 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nHmzu-0007BS-FJ for bug-gnu-emacs@gnu.org; Wed, 09 Feb 2022 08:27:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Ignacio Casso Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 09 Feb 2022 13:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53894 X-GNU-PR-Package: emacs Original-Received: via spool by 53894-submit@debbugs.gnu.org id=B53894.164441320027584 (code B ref 53894); Wed, 09 Feb 2022 13:27:02 +0000 Original-Received: (at 53894) by debbugs.gnu.org; 9 Feb 2022 13:26:40 +0000 Original-Received: from localhost ([127.0.0.1]:50213 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nHmzX-0007Ap-Rg for submit@debbugs.gnu.org; Wed, 09 Feb 2022 08:26:40 -0500 Original-Received: from mail-db8eur05olkn2037.outbound.protection.outlook.com ([40.92.89.37]:61153 helo=EUR05-DB8-obe.outbound.protection.outlook.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nHmzV-0007AX-JC for 53894@debbugs.gnu.org; Wed, 09 Feb 2022 08:26:38 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MKY+Y08ybXFYIeRovHMywKjHPpvdsVx7rCN7WOy6iU84ClxXN3yw6RqAYxdzs4kt1MdoO/mupiVEpFQZ66SFsHkY+8mmkf7p/x0ZZzb3MctIKGVXN1K10N6ssWki4prKVrnX4vj+81zItBsOKTaVhxu+t/WNOhQz+aGus365mgixpx0mP/hGn9XMbDiN3kz9HyhlyT4BmaXm5+5sTNq+Mwcx70veTJ5JjV9P2yBpkxCyiFCbscYlPEfPWAtPvG7sPWk6JwvDOOEJ//AkjS+Ac7FcMiUJnH5YDjFV/WBR+w7uZMeHvyxifmZ158fa/rFXAJy31/xjQ4H7QzkHP86s+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1m5H3YLzK00ncUx4JFlbSD18fiWWsSyihpHKTqtnH3A=; b=XvrqGVKswUBeCqJj9Lxl3FjCtVEh+JLMiQPF3C3FHyypIUTX2NyOubi0aL8UDJOh6e+34oA1q9jZr4AaQMfSwfzeEyYnTLM5sMMHficxFpT3bxH+W600S6ZZC+j8L7s+PEspOCU7SEhYK4a/Go/AN/aoqrQ/Wzd6/wL/6sTvRAqhZyaIzrWUZ3vr1ufY2OB+JRBzUzzkNSc8Oqiz08H51atETXb08rCMPERrupBAFPGEv/y5pB+czW1PdW5NbzM7OjggiHqyRferkuPNvyOZ1hTQ3emXZgT/wbE/ANRLdaQWRSSCumoeRDCSXdilG0LHOlXFcORipp9jA0NZLiAx4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1m5H3YLzK00ncUx4JFlbSD18fiWWsSyihpHKTqtnH3A=; b=SBNvSltW/sCdIzfrPeXtP8koGU7wqwGjoilxdiIrh99sAma8itoGB0eV5rO8BBNImcEhxJvZa0KredA6ltDmJymsmHqrWJq+4A510/ydQnHL19cjGvGZPwylEQM/GCRLF9wekB82qOeP5ZOYwpAfq+vnm8PzRbh4DFPSnky3SKS/coW0ij2uSRf1rZP88p7ZTgvMNyf0O0FCowzJ/3rSy+N7pGfMZUq6+wkhLBbnFLJylcij6m2VtwDGalkhU/9lwlyo9cumI15DK56AnRZdQaF96Qe++enun6VMmE2PLqmGpTCy7NaZSIbJvh4h5FzJxGHKIpMZVAEf3YmHrZrj/w== Original-Received: from PAXPR06MB7760.eurprd06.prod.outlook.com (2603:10a6:102:155::8) by AS8PR06MB7543.eurprd06.prod.outlook.com (2603:10a6:20b:319::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Wed, 9 Feb 2022 13:26:30 +0000 Original-Received: from PAXPR06MB7760.eurprd06.prod.outlook.com ([fe80::50de:9162:7856:2782]) by PAXPR06MB7760.eurprd06.prod.outlook.com ([fe80::50de:9162:7856:2782%5]) with mapi id 15.20.4951.019; Wed, 9 Feb 2022 13:26:30 +0000 In-reply-to: <87mtj0l0wp.fsf@gnus.org> X-TMN: [tpLEUbXegfDl8NY3Qmue4ntwrUbbaekV] X-ClientProxiedBy: MR1P264CA0051.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:3e::26) To PAXPR06MB7760.eurprd06.prod.outlook.com (2603:10a6:102:155::8) X-Microsoft-Original-Message-ID: <871r0c9nnj.fsf@hotmail.com> X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f3dec1da-cd62-4f40-e44c-08d9ebcfc800 X-MS-TrafficTypeDiagnostic: AS8PR06MB7543:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aEn/QQklm555OhTh/Na2amKzpYMuGdV7EfFkrBj5ylLTehRKFiZcSX0ivfy9sAM++fvA2hhZnc8/yzdhiz0mirGbJzAYgif+zbOwaG8SSLSG2yIMz6ZXh4fTJJj5NPQjorqcvz6AJpQ0DZqu5FqiX2Y4sQI9SuSiK5cA0ZSElV0Fs+4XC9tKP4ZZkgBNvSjUyRi67ZefnYL2a2Ro+5xup+frISYoWKALnnEnt6lKiAeedQEi5QM9dLsNTfWOgxtBFFSszOKhV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Qq83gH70npSrzejROI6phHcOqEqt/0EOtJW1Je3MSI1gbatFjY84BLhRa9ze8OagoqscYniy3wkX8Rcrgq1UsLJLW F092lTjKKqkGDyJglc0QgS7XLUbecm8cdPjR8kh14wr/XCYL6wBKMmWg5BSic4w+YN1fg4yoKmvi79lRM6Q2Xrc0cpz+iitT7b X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-6e454.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: f3dec1da-cd62-4f40-e44c-08d9ebcfc800 X-MS-Exchange-CrossTenant-AuthSource: PAXPR06MB7760.eurprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 13:26:29.9488 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR06MB7543 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:226480 Archived-At: 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 writes: > Ignacio Casso 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.