unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: alain.cochard@unistra.fr
Cc: Alain.Cochard@unistra.fr, emacs-devel@gnu.org
Subject: Re: org-copy-visible does not work with x-select-enable-primary
Date: Mon, 10 Sep 2018 17:49:33 +0300	[thread overview]
Message-ID: <83o9d5o1aa.fsf@gnu.org> (raw)
In-Reply-To: <23446.24671.697405.158351@frac.u-strasbg.fr> (Alain.Cochard@unistra.fr)

> Date: Mon, 10 Sep 2018 14:15:27 +0200
> From: Alain.Cochard@unistra.fr
> Cc: Alain Cochard <Alain.Cochard@unistra.fr>
> 
> 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 <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	other threads:[~2018-09-10 14:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-10 12:15 org-copy-visible does not work with x-select-enable-primary Alain.Cochard
2018-09-10 14:49 ` Eli Zaretskii [this message]
2018-09-10 15:20   ` Alain.Cochard
2018-09-10 17:27     ` Eli Zaretskii
2018-09-10 17:00 ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83o9d5o1aa.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=alain.cochard@unistra.fr \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).