all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* org-copy-visible does not work with x-select-enable-primary
@ 2018-09-02 13:37 Alain.Cochard
  2018-09-02 19:25 ` Nicolas Goaziou
  0 siblings, 1 reply; 9+ messages in thread
From: Alain.Cochard @ 2018-09-02 13:37 UTC (permalink / raw)
  To: emacs-orgmode


Hello.


I use

   emacs -Q -l ~/.emacs.debug

with the ~/.emacs.debug file containing only

   (add-to-list 'load-path "/home/cochard/Org/Coch-git/org-mode/lisp")

I tried 2 versions of emacs, giving:

   Emacs : GNU Emacs 24.5.1 (x86_64-redhat-linux-gnu, GTK+ Version
   3.18.9) of 2016-04-11 on buildvm-25.phx2.fedoraproject.org Package:
   Org mode version 9.1.14 (release_9.1.14-908-gf1269e @
   /home/cochard/Org/Coch-git/org-mode/lisp/)

   Emacs : GNU Emacs 26.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version
   3.18.9) of 2018-05-30 Package: Org mode version 9.1.14
   (release_9.1.14-908-gf1269e @
   /home/cochard/Org/Coch-git/org-mode/lisp/)

In both cases, org-copy-visible works as I expect: if I select region
containing a folded tree, use 'M-x org-copy-visible', then put the
cursor elsewhere and use 'M-x org-yank', only the visible part is
copied.

Now, if I append the line

   (setq x-select-enable-primary t) 

to ~/.emacs.debug, the whole tree is copied instead of the expected
result, that is, including the invisible parts, also for the two emacs
versions.

NB: For emacs 26, as the manual says that 

   [x-select-enable-primary] is an alias for ‘select-enable-primary’.
   This variable is obsolete since 25.1; use ‘select-enable-primary’
   instead.

I have also tried (setq select-enable-primary t) but this fails in the
same way.

Regards


-- 
EOST (École et Observatoire des Sciences de la Terre) 
IPG (Institut de Physique du Globe) | alain.cochard@unistra.fr
5 rue René Descartes   [bureau 106] | Phone: +33 (0)3 68 85 50 44 
F-67084 Strasbourg Cedex, France    | Fax:   +33 (0)3 68 85 01 25     

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: org-copy-visible does not work with x-select-enable-primary
  2018-09-02 13:37 org-copy-visible does not work with x-select-enable-primary Alain.Cochard
@ 2018-09-02 19:25 ` Nicolas Goaziou
  2018-09-11  7:05   ` Alain.Cochard
  0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2018-09-02 19:25 UTC (permalink / raw)
  To: Alain.Cochard; +Cc: emacs-orgmode

Hello,

Alain.Cochard@unistra.fr writes:

> Hello.
>
>
> I use
>
>    emacs -Q -l ~/.emacs.debug
>
> with the ~/.emacs.debug file containing only
>
>    (add-to-list 'load-path "/home/cochard/Org/Coch-git/org-mode/lisp")
>
> I tried 2 versions of emacs, giving:
>
>    Emacs : GNU Emacs 24.5.1 (x86_64-redhat-linux-gnu, GTK+ Version
>    3.18.9) of 2016-04-11 on buildvm-25.phx2.fedoraproject.org Package:
>    Org mode version 9.1.14 (release_9.1.14-908-gf1269e @
>    /home/cochard/Org/Coch-git/org-mode/lisp/)
>
>    Emacs : GNU Emacs 26.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version
>    3.18.9) of 2018-05-30 Package: Org mode version 9.1.14
>    (release_9.1.14-908-gf1269e @
>    /home/cochard/Org/Coch-git/org-mode/lisp/)
>
> In both cases, org-copy-visible works as I expect: if I select region
> containing a folded tree, use 'M-x org-copy-visible', then put the
> cursor elsewhere and use 'M-x org-yank', only the visible part is
> copied.
>
> Now, if I append the line
>
>    (setq x-select-enable-primary t) 
>
> to ~/.emacs.debug, the whole tree is copied instead of the expected
> result, that is, including the invisible parts, also for the two emacs
> versions.
>
> NB: For emacs 26, as the manual says that 
>
>    [x-select-enable-primary] is an alias for ‘select-enable-primary’.
>    This variable is obsolete since 25.1; use ‘select-enable-primary’
>    instead.
>
> I have also tried (setq select-enable-primary t) but this fails in the
> same way.

You may want to report it to Emacs Devel instead. Since it works in some
cases, it may not be related to Org.

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 9+ messages in thread

* org-copy-visible does not work with x-select-enable-primary
@ 2018-09-10 12:15 Alain.Cochard
  2018-09-10 14:49 ` Eli Zaretskii
  2018-09-10 17:00 ` Stefan Monnier
  0 siblings, 2 replies; 9+ messages in thread
From: Alain.Cochard @ 2018-09-10 12:15 UTC (permalink / raw)
  To: emacs-devel; +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."

The issue is also present with the development version of Org, but,
below, I assume no access to this development version and no knowledge
of Org.  I only assume an Emacs version with org-mode included (if I
understand well, any Emacs version >= 24.5.1 should do).

So here it is:

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...'. 

I have tried with the following 2 versions of Emacs+Org (plus, as I
said, with the development version of Org instead of the bundled
ones):

Emacs : GNU Emacs 24.5.1 (x86_64-redhat-linux-gnu, GTK+ Version
3.18.9) of 2016-04-11 on buildvm-25.phx2.fedoraproject.org Package:
Org-mode version 8.2.10 (release_8.2.10 @
/usr/share/emacs/24.5/lisp/org/)

Emacs : GNU Emacs 26.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.18.9) of 2018-05-30 Package: Org mode version 9.1.9
(release_9.1.9-65-g5e4542 @
/home/cochard/usr/local/emacs-26.1/lisp/org/)

Regards

-- 
EOST (École et Observatoire des Sciences de la Terre) 
IPG (Institut de Physique du Globe) | alain.cochard@unistra.fr
5 rue René Descartes   [bureau 106] | Phone: +33 (0)3 68 85 50 44 
F-67084 Strasbourg Cedex, France    | Fax:   +33 (0)3 68 85 01 25     



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: org-copy-visible does not work with x-select-enable-primary
  2018-09-10 12:15 Alain.Cochard
@ 2018-09-10 14:49 ` Eli Zaretskii
  2018-09-10 15:20   ` Alain.Cochard
  2018-09-10 17:00 ` Stefan Monnier
  1 sibling, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2018-09-10 14:49 UTC (permalink / raw)
  To: alain.cochard; +Cc: Alain.Cochard, emacs-devel

> 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.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: org-copy-visible does not work with x-select-enable-primary
  2018-09-10 14:49 ` Eli Zaretskii
@ 2018-09-10 15:20   ` Alain.Cochard
  2018-09-10 17:27     ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Alain.Cochard @ 2018-09-10 15:20 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: alain.cochard, emacs-devel


Hi, and thanks for the feedback.

Eli Zaretskii writes on Mon 10 Sep 2018 17:49:

 > 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).

Are you sure??  For me and all the configurations tried (emacs and org
versions), when x-select-enable-primary is true, it does not simply
yank "* foo", even after I remove the selection.

The already mentioned tests I made were on my laptop.  I just tried on
2 different machines, with, respectively, those configurations:

Emacs : GNU Emacs 25.3.1 (x86_64-redhat-linux-gnu, GTK+ Version
3.22.19) of 2017-09-15 Package: Org-mode version 8.2.10
(release_8.2.10 @ /usr/share/emacs/25.3/lisp/org/)

GNU Emacs 23.1.1 (x86_64-redhat-linux-gnu, GTK+ Version 2.24.23) of
2015-02-19 on c6b8.bsys.dev.centos.org Org-mode version 6.21b

and the bad behavior is identical -- removing the selection does not
help.   All the machines are redhat based, though... Could it be that
you used a completely different distribution?

(NB: With x-select-enable-primary false --default--, it yanks "* foo"
whether I remove the selection or not.)



-- 
EOST (École et Observatoire des Sciences de la Terre) 
IPG (Institut de Physique du Globe) | alain.cochard@unistra.fr
5 rue René Descartes   [bureau 106] | Phone: +33 (0)3 68 85 50 44 
F-67084 Strasbourg Cedex, France    | Fax:   +33 (0)3 68 85 01 25     



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: org-copy-visible does not work with x-select-enable-primary
  2018-09-10 12:15 Alain.Cochard
  2018-09-10 14:49 ` Eli Zaretskii
@ 2018-09-10 17:00 ` Stefan Monnier
  1 sibling, 0 replies; 9+ messages in thread
From: Stefan Monnier @ 2018-09-10 17:00 UTC (permalink / raw)
  To: emacs-devel; +Cc: Carsten Dominik

> (setq x-select-enable-primary t)
>
> In that case, for me, 'C-y' yanks both lines, instead of only
> 'foo...'. 

AFAICT there's also the problem that after `C-x C-c v` the region is
still active.  Those two problems are actually related and seem to be
fixed with the patch below.


        Stefan


diff --git a/lisp/org/org.el b/lisp/org/org.el
index 21d9cd8785..dbd81b0aeb 100644
--- a/lisp/org/org.el
+++ b/lisp/org/org.el
@@ -20666,6 +20666,7 @@ org-copy-visible
       (let ((next (next-single-char-property-change beg 'invisible nil end)))
 	(setq result (concat result (buffer-substring beg next)))
 	(setq beg next)))
+    (setq deactivate-mark t)
     (kill-new result)))
 
 (defun org-copy-special ()





^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: org-copy-visible does not work with x-select-enable-primary
  2018-09-10 15:20   ` Alain.Cochard
@ 2018-09-10 17:27     ` Eli Zaretskii
  0 siblings, 0 replies; 9+ messages in thread
From: Eli Zaretskii @ 2018-09-10 17:27 UTC (permalink / raw)
  To: alain.cochard; +Cc: emacs-devel

> Date: Mon, 10 Sep 2018 17:20:45 +0200
> From: Alain.Cochard@unistra.fr
> Cc: alain.cochard@unistra.fr,
>     emacs-devel@gnu.org
> 
>  > 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).
> 
> Are you sure??

Quite sure.  But it doesn't matter much: what matters is that the
offending string, "* foo\nbar", comes from the call to
gui-selection-value.  And once it gets into the kill-ring, you cannot
undo that.  org-copy-visible only handles what gets put into the kill
ring when you invoke the command, it doesn't do anything what happens
about invisible text when you yank.

> (NB: With x-select-enable-primary false --default--, it yanks "* foo"
> whether I remove the selection or not.)

Yes, because without that, yanking doesn't consult the primary
selection, it only consults the clipboard.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: org-copy-visible does not work with x-select-enable-primary
  2018-09-02 19:25 ` Nicolas Goaziou
@ 2018-09-11  7:05   ` Alain.Cochard
  2018-09-11 10:07     ` Nicolas Goaziou
  0 siblings, 1 reply; 9+ messages in thread
From: Alain.Cochard @ 2018-09-11  7:05 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

Nicolas Goaziou writes on Sun  2 Sep 2018 21:25:

 > You may want to report it to Emacs Devel instead. Since it works in
 > some cases, it may not be related to Org.

So I did report to Emacs Devel -- see thread
https://lists.gnu.org/archive/html/emacs-devel/2018-09/msg00476.html

Eli Zaretskii argues that the problem comes from Org.

Stefan Monnier provides a patch, which, for me, solves the problem.

Thank you very much and regards.

-- 
EOST (École et Observatoire des Sciences de la Terre) 
IPG (Institut de Physique du Globe) | alain.cochard@unistra.fr
5 rue René Descartes   [bureau 106] | Phone: +33 (0)3 68 85 50 44 
F-67084 Strasbourg Cedex, France    | Fax:   +33 (0)3 68 85 01 25     

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: org-copy-visible does not work with x-select-enable-primary
  2018-09-11  7:05   ` Alain.Cochard
@ 2018-09-11 10:07     ` Nicolas Goaziou
  0 siblings, 0 replies; 9+ messages in thread
From: Nicolas Goaziou @ 2018-09-11 10:07 UTC (permalink / raw)
  To: Alain.Cochard; +Cc: emacs-orgmode

Hello,

Alain.Cochard@unistra.fr writes:

> Nicolas Goaziou writes on Sun  2 Sep 2018 21:25:
>
>  > You may want to report it to Emacs Devel instead. Since it works in
>  > some cases, it may not be related to Org.
>
> So I did report to Emacs Devel -- see thread
> https://lists.gnu.org/archive/html/emacs-devel/2018-09/msg00476.html
>
> Eli Zaretskii argues that the problem comes from Org.
>
> Stefan Monnier provides a patch, which, for me, solves the problem.

Applied. Thank you.

Regards,

-- 
Nicolas Goaziou                                                0x80A93738

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-09-11 10:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-02 13:37 org-copy-visible does not work with x-select-enable-primary Alain.Cochard
2018-09-02 19:25 ` Nicolas Goaziou
2018-09-11  7:05   ` Alain.Cochard
2018-09-11 10:07     ` Nicolas Goaziou
  -- strict thread matches above, loose matches on Subject: below --
2018-09-10 12:15 Alain.Cochard
2018-09-10 14:49 ` Eli Zaretskii
2018-09-10 15:20   ` Alain.Cochard
2018-09-10 17:27     ` Eli Zaretskii
2018-09-10 17:00 ` Stefan Monnier

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.