From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#27442: Un-obsolete x-clipboard-yank, or provide analogous functional Date: Mon, 05 Jul 2021 16:13:43 +0200 Message-ID: <877di4yhk8.fsf@gnus.org> References: <83r2ydupg7.fsf@gnu.org> <9b98217a-be79-56ed-16a9-0c15622111c5@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18157"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Stefan Monnier , 27442@debbugs.gnu.org To: Constantine Kharlamov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jul 05 16:15:18 2021 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 1m0PNW-0004Yl-4O for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 05 Jul 2021 16:15:18 +0200 Original-Received: from localhost ([::1]:50500 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0PNV-0005BV-2v for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 05 Jul 2021 10:15:17 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38490) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0PNG-0005B2-I9 for bug-gnu-emacs@gnu.org; Mon, 05 Jul 2021 10:15:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:34794) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m0PNG-000520-AO for bug-gnu-emacs@gnu.org; Mon, 05 Jul 2021 10:15:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m0PNG-0003u0-73 for bug-gnu-emacs@gnu.org; Mon, 05 Jul 2021 10:15:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 05 Jul 2021 14:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27442 X-GNU-PR-Package: emacs Original-Received: via spool by 27442-submit@debbugs.gnu.org id=B27442.162549444114874 (code B ref 27442); Mon, 05 Jul 2021 14:15:02 +0000 Original-Received: (at 27442) by debbugs.gnu.org; 5 Jul 2021 14:14:01 +0000 Original-Received: from localhost ([127.0.0.1]:46333 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m0PMH-0003ra-8X for submit@debbugs.gnu.org; Mon, 05 Jul 2021 10:14:01 -0400 Original-Received: from quimby.gnus.org ([95.216.78.240]:57914) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m0PMD-0003rI-OI for 27442@debbugs.gnu.org; Mon, 05 Jul 2021 10:13:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Dm38JuwGZIdTHeKnH+tf0odVntMygt/rd5op7zFl1U4=; b=eW2SBNMQcIwUCvfXuV7JTpJ9ju Pt69tkasQmWtLCE1ZK8kx3Tsl580Dlc5zxtx8SqJAaVEjdolB3awA5nv3VdECRfcfhPXmFcO6Ofjw FTeT1uqFvVFXanWl+3iLn8EEwsb+fs3n/afkoLYsK8Z2y54AQwcQENXoTud/lf22Vq+A=; Original-Received: from cm-84.212.220.105.getinternet.no ([84.212.220.105] helo=elva) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m0PM3-00056d-LF; Mon, 05 Jul 2021 16:13:50 +0200 X-Now-Playing: Neil Young with Crazy Horse's _Archives Vol. II (8): Dume (1975)_: "Kansas" In-Reply-To: <9b98217a-be79-56ed-16a9-0c15622111c5@yandex.ru> (Constantine Kharlamov's message of "Wed, 21 Jun 2017 22:55:58 +0300") 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:209464 Archived-At: Constantine Kharlamov writes: > 1. start `emacs -Q` > 2. Press M-: to execute `(setq select-enable-clipboard nil)` > 3. Copy a text in the system, i.e. outside of Emacs. > 4. Press M-: to execute `(clipboard-yank)` (you'll get at the point a > content from system clipboard) > 5. Press M-< M-d (so now you have the word ";; This" in kill-ring) > 6. Press M-: to execute `(clipboard-yank)` > > You will see ";; This" got pasted at point, not the value in > the system clipboard. > > 7. Press M-: to execute `(x-clipboard-yank)` > > You will see content from the system clipboard got pasted at point. Aaah! This explains the weird behaviour I've been seeing when I'm trying to paste stuff from the clipboard -- as you say, `M-x clipboard-yank' doesn't work reliably if you've yanked the clipboard contents once. And that's because of this: (defun gui-selection-value () (let ((clip-text (when select-enable-clipboard (let ((text (gui--selection-value-internal 'CLIPBOARD))) (if (string= text "") (setq text nil)) ;; Check the CLIPBOARD selection for 'newness', is it different ;; from what we remembered them to be last time we did a ;; cut/paste operation. (prog1 (unless (equal text gui--last-selected-text-clipboard) text) (setq gui--last-selected-text-clipboard text))))) So, indeed, if you `M-x clipboard-yank', then kill some text in Emacs, you can't `M-x clipboard-yank' until you've clipboarded some other text, yanked it, and then clipboarded the original text again. Fixing this should be pretty trivial -- the following patch should do the trick, I think (although I haven't tested it). But I'm not quite sure about the intended logic here, so I've added Stefan M to the CCs -- perhaps he has some comments. diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el index 739e751d8a..dac04e113e 100644 --- a/lisp/menu-bar.el +++ b/lisp/menu-bar.el @@ -570,7 +570,8 @@ menu-bar-edit-menu (defun clipboard-yank () "Insert the clipboard contents, or the last stretch of killed text." (interactive "*") - (let ((select-enable-clipboard t)) + (let ((select-enable-clipboard t) + (gui--last-selected-text-clipboard nil)) (yank))) (defun clipboard-kill-ring-save (beg end &optional region) -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no