From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: org-copy-visible does not work with x-select-enable-primary Date: Mon, 10 Sep 2018 17:49:33 +0300 Message-ID: <83o9d5o1aa.fsf@gnu.org> References: <23446.24671.697405.158351@frac.u-strasbg.fr> NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1536591458 13779 195.159.176.226 (10 Sep 2018 14:57:38 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 10 Sep 2018 14:57:38 +0000 (UTC) Cc: Alain.Cochard@unistra.fr, emacs-devel@gnu.org To: alain.cochard@unistra.fr Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Sep 10 16:57:33 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fzNd7-0003S0-Bp for ged-emacs-devel@m.gmane.org; Mon, 10 Sep 2018 16:57:33 +0200 Original-Received: from localhost ([::1]:52110 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fzNfD-00030y-UV for ged-emacs-devel@m.gmane.org; Mon, 10 Sep 2018 10:59:43 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50626) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fzNcq-0006WE-Vh for emacs-devel@gnu.org; Mon, 10 Sep 2018 10:57:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fzNVN-0005d9-3O for emacs-devel@gnu.org; Mon, 10 Sep 2018 10:49:33 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:41369) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fzNVH-0005X2-5k; Mon, 10 Sep 2018 10:49:27 -0400 Original-Received: from [176.228.60.248] (port=2373 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1fzNVG-0005xD-Ou; Mon, 10 Sep 2018 10:49:27 -0400 In-reply-to: <23446.24671.697405.158351@frac.u-strasbg.fr> (Alain.Cochard@unistra.fr) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:229641 Archived-At: > Date: Mon, 10 Sep 2018 14:15:27 +0200 > From: Alain.Cochard@unistra.fr > Cc: Alain Cochard > > Hello. I already sent an email about this issue to > emacs-orgmode@gnu.org. Nicolas Goaziou, one of the Org mode > developers, suggested to report to Emacs Devel instead because "Since > it works in some cases, it may not be related to Org." I think it is related to Org, see below. > Using 'emacs -Q', visit or create a file with the '.org' extension > (say 'bug.org') with the following 2 lines: > > * foo > bar > > (As I am not fully sure this will be transmitted correctly, let me > specify: the 1st line is '* foo', the 2nd line is 'bar'; there is no > indentation.) > > With the cursor on the star, hitting repetitively the key should > cycle between a state for which one sees all the content of the file, > and the so-called folded state where one only sees the line: > > * foo... > > Now, selecting the single line above, e.g., with the mouse, hitting > 'C-c C-x v' (M-x org-copy-visible), then 'C-y' (M-x org-yank), should > yank '* foo'. > > This is the normal behavior. As far as I understand, there is no > reason this behavior should be affected by the variable > 'x-select-enable-primary', but it it, at least for me. A possible > test is to repeat the same experiment using 'emacs -Q -l .emacs.debug' > (instead of 'emacs -Q'), where the '.emacs.debug' file contains only > the line: > > (setq x-select-enable-primary t) > > In that case, for me, 'C-y' yanks both lines, instead of only > 'foo...'. It will yank only "* foo" if you move the cursor in the Org buffer before yanking, or do anything else that removes the selection (i.e. removes the highlight due to selecting text). The problem here is that C-y first checks if there's any selected text, and if so, it prefers it to the text you killed last. When you set x-select-enable-primary non-nil, Emacs calls gui-selection-value to see if there's any selected text, and gui-selection-value doesn'ty know about Org's hidden text, so it returns both lines as selected (because selecting the ellipsis actually selects both lines, from the POV of buffer positions). So that is what you get from yanking in this case. I think if Org wants to support this use case, it should override gui-selection-value with its own function, or do something else to prevent X selection from getting into the kill-ring.