[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: org-copy-visible does not work with x-select-enable-primary

From: Eli Zaretskii
Subject: Re: org-copy-visible does not work with x-select-enable-primary
Date: Mon, 10 Sep 2018 17:49:33 +0300

> Date: Mon, 10 Sep 2018 14:15:27 +0200
> From: address@hidden
> Cc: Alain Cochard <address@hidden>
> Hello.  I already sent an email about this issue to
> address@hidden  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 <TAB> 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.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]