From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.help Subject: RE: how to get subsequent text copies to emacs kill ring? Date: Thu, 16 May 2013 22:00:34 -0700 Message-ID: <24A033FA61ED474DBA3996584BAA4A96@us.oracle.com> References: <871u967myb.fsf@web.de><2D114A341A214863AF76E9C5CC2D145B@us.oracle.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1368766866 15067 80.91.229.3 (17 May 2013 05:01:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 17 May 2013 05:01:06 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: "'Samuel Wales'" , "'Stefan Monnier'" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri May 17 07:01:04 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UdCmt-0006Bj-0r for geh-help-gnu-emacs@m.gmane.org; Fri, 17 May 2013 07:01:03 +0200 Original-Received: from localhost ([::1]:58494 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UdCms-0006k0-MR for geh-help-gnu-emacs@m.gmane.org; Fri, 17 May 2013 01:01:02 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:34625) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UdCmb-0006jf-Vd for help-gnu-emacs@gnu.org; Fri, 17 May 2013 01:00:48 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UdCma-0000qk-Ls for help-gnu-emacs@gnu.org; Fri, 17 May 2013 01:00:45 -0400 Original-Received: from userp1040.oracle.com ([156.151.31.81]:23281) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UdCma-0000qb-9y for help-gnu-emacs@gnu.org; Fri, 17 May 2013 01:00:44 -0400 Original-Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r4H50dUU030775 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 17 May 2013 05:00:40 GMT Original-Received: from userz7022.oracle.com (userz7022.oracle.com [156.151.31.86]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r4H50bLW024370 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Fri, 17 May 2013 05:00:38 GMT Original-Received: from abhmt116.oracle.com (abhmt116.oracle.com [141.146.116.68]) by userz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r4H50bPs027715; Fri, 17 May 2013 05:00:37 GMT Original-Received: from dradamslap1 (/71.202.147.44) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 16 May 2013 22:00:37 -0700 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: Thread-Index: Ac5SnzQ87ecJ9bs1SIaI+HZLyOYN5QADh7tQ X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-Source-IP: acsinet22.oracle.com [141.146.126.238] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 156.151.31.81 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:90866 Archived-At: > (setq save-interprogram-paste-before-kill t) Thanks for pointing this out, Samuel! It seems to do just what I requested. Dunno how I missed it. Stefan, what does your local patch do differently from what this option does? --- I think the option name and doc for this are a bit misleading, however. The Emacs manual, at (emacs) `Clipboard', is almost OK about this. But it suggests that the problem, in which copied text gets "lost" or "replaced", is that the clipboard text is overwritten by a kill or a copy to the kill ring: When an Emacs kill command puts text in the clipboard, the existing clipboard contents are normally lost. ^^^^^^^^^ The problem is not that the _clipboard_ gets overwritten by a kill. It is that the Emacs `current-kill', copied automatically from the clipboard (good), is overwritten (replaced) by an Emacs kill or copy to the kill ring. (When you yank (`C-y') you get the `current-kill'.) IOW, the problem is about the opposite of what the doc says. It does not matter to Emacs behavior that the clipboard gets overwritten. What matters here is that the "current kill", which came from the clipboard, gets replaced when you kill text. This problem has to do with the fact that the clipboard text was never copied to the `kill-ring' (the list variable). It gets treated as the (zeroth) `current-kill', so an immediate `C-y' yanks it, but though it is called "current kill" and it can be yanked it is not really on the `kill-ring'. That is quite different from the behavior provided by `kill-ring-save' or `copy-region-as-kill' - they add the text to `kill-ring', as well as making it the `current-kill'. A non-nil value of this option effectively copies the clipboard text to the `kill-ring', just as `kill-ring-save' and `copy-region-as-kill' do. And that's all it does, I think. The option should perhaps have been called something like `clipboard-to-kill-ring', `copy-clipboard-as-kill', `copy-clipboard-before-kill' or `kill-copies-clipboard-first'. The name should, above all, say that it causes the clipboard text to be copied to the kill ring. A problem with such a (better) name could be that some people might think that the clipboard text already gets copied to the kill ring anyway, without the option, because of the curious behavior of `current-kill'. You can yank the clipboard text (provided you do so immediately), but it is not on the `kill-ring'. IOW, it might not be clear to everyone that what `C-y' yanks is the `current-kill', which is not necessarily the first item (or any item) in the `kill-ring'. The Emacs doc, at (emacs) `Yanking', makes that clear: Emacs effectively treats "cut" or "copy" clipboard operations performed in other applications like Emacs kills, except that ^^^^^^^^^^^^^^^^ they are not recorded in the kill ring. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Regardless of this possible confusion, the most important thing the option name could suggest is that it causes the clipboard text to be added to the `kill-ring'. Currently, the name does not convey that. The current option name is also misleading because it can suggest that it controls "pasting" in Emacs. I'm guessing the name was taken from "interprogram paste function", but as used here the word "paste" is misleading, even for those who might happen to know about "interprogram paste function". The name can unfortunately suggest that this is about saving a _paste_ from another program (before a kill). There is no such paste here. And even if there were, what does it mean to save a paste? What happens is that before a kill (and before a copy to the kill ring, which is also important), the clipboard text is copied to the `kill-ring'. The doc string should just say that: Non-nil means copy clipboard text to kill ring before text you kill. That is, when you kill or copy text to the kill ring, as its first item, the clipboard text is put on the ring as the second (older) item. You can thus yank it using `C-y M-y'. It could also say this, which might not be obvious though it follows from what has already been said: Whatever is on the clipboard when you kill or copy in Emacs gets added to the kill ring. It does not matter how long ago it was cut or copied to the clipboard or by which program. The doc string can go on to point out what happens if the value is nil, and that you can always yank the clipboard text immediately: If nil, clipboard text is not added to the kill ring. Whether nil or non-nil, you can yank the text using `C-y' immediately after it is added to the clipboard. But if nil then a subsequent kill or copy to the kill ring overwrites the text as the current kill, so it is no longer available to be yanked. The doc string should also, like Emacs doc generally, speak of yanking, not pasting, when it talks about yanking text in Emacs. And whatever this doc string says about yanking text (i.e., `C-y M-y') should be only secondary. The point of the option is to make sure that the clipboard text gets copied (really) to the kill ring. What you do with text on the kill ring is secondary here to the effect of the option.