From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jiegec Subject: Re: ox-clip.el Date: Thu, 30 Jun 2016 20:36:50 +0800 Message-ID: <90D197AC-A859-4201-9676-ED98A15F597A@qq.com> References: <43FD8784-D7FC-447E-809E-7DC36BB7D530@qq.com> Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Content-Type: multipart/alternative; boundary="Apple-Mail=_55932CDB-33D9-48A3-820A-D0C98F32F4EE" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34390) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIbDE-00052G-F9 for emacs-orgmode@gnu.org; Thu, 30 Jun 2016 08:36:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bIbD9-0000Y8-95 for emacs-orgmode@gnu.org; Thu, 30 Jun 2016 08:36:55 -0400 Received: from smtpbgsg2.qq.com ([54.254.200.128]:57813) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIbD5-0000W7-Fm for emacs-orgmode@gnu.org; Thu, 30 Jun 2016 08:36:51 -0400 In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: John Kitchin Cc: emacs-orgmode@gnu.org --Apple-Mail=_55932CDB-33D9-48A3-820A-D0C98F32F4EE Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 I=E2=80=99m quite confused with the difference between CLIPBOARD and = PRIMARY in X11 and in OS X.=20 Evil calls `x-select-text=E2=80=99 in = `evil-visual-{pre,post}-command=E2=80=99. And here is the document of `x-select-text=E2=80=99: x-select-text is an alias for =E2=80=98gui-select-text=E2=80=99 in = =E2=80=98select.el=E2=80=99. (x-select-text TEXT) This function is obsolete since 25.1; use =E2=80=98gui-select-text=E2=80=99 instead. Select TEXT, a string, according to the window system. if =E2=80=98select-enable-clipboard=E2=80=99 is non-nil, copy TEXT to = the system=E2=80=99s clipboard. If =E2=80=98select-enable-primary=E2=80=99 is non-nil, put TEXT in the = primary selection. MS-Windows does not have a "primary" selection. So I set select-enable-clipboard to nil and now it works as expected =E2=80= =94 `ox-clip' a region, when pasting in Libreoffice I get the formatted = version, when pasting in Emacs I get the original text. > On Jun 30, 2016, at 8:13 PM, John Kitchin = wrote: >=20 > Thanks for the feedback. >=20 > I noticed at the bottom of `gui-set-selection': Note that on = MS-Windows, > primary and secondary selections set by Emacs are not available to = other > programs. It looks like Emacs won't support this out of the box soon = ;) >>=20 >> But the text to be copied here is in RTF, but Emacs >> is hardcoded to copy texts. Damn. We have to use >> pbcopy or to change Emacs internal code. >=20 >>=20 >> Now things go back to finding the culprit of >> overwriting the clipboard. And I traced to >> `evil-visual-update-x-selection=E2=80=99 called in=20 >> `evil-visual-{pre,post}-command=E2=80=99. Oh I don=E2=80=99t = understand >> why evil does this. Disabling evil-mode works. >=20 > That sounds "evil". How do you ever copy anything? I still don't = really > understand why it is an issue for ox-clip unless what is really = happening > is evil messes up the active region which is exported by org-mode. The > ox-clip command doesn't touch the emacs clipboard at all I think. It > only uses system commands to put stuff on the system clipboards (which > are not directly visible to emacs in the first place). >=20 > The ox-clip commands don't currently copy anything you can paste back > into emacs. I have debated doing that, but it adds a noticeable lag = for > the copy command since an org-export is involved, and if you are = pasting > back to emacs that is not needed. >=20 > A solution would be a new copy command that just does a regular copy = all > the time, but with a prefix arg does a formatted copy for pasting > elsewhere. I just use two different key bindings now. M-w for copy, = and > H-k for formatted copy. >=20 >>=20 >> Then here comes another bug: >>=20 >> I=E2=80=99m testing on a Chinese org file. Here is the part: >>=20 >> *** Evil-Surround >>=20 >> [[https://github.com/timcharper/evil-surround][Evil-surround] = ] =E6=98=AF=E4= =B8=80=E4=B8=AA Vim = =E4=B8=8A=E9=9D=9E=E5=B8=B8=E5=B8=B8=E7=94=A8=E7=9A=84=E6=8F=92=E4=BB=B6=E6= =94=B9=E5=86=99=E7=9A=84=EF=BC=8C=E4=BD=BF=E7=94=A8=E5=AE=83=E5=8F=AF=E4=BB= =A5=E5=BF=AB=E9=80=9F=E7=9A=84=E5=B0=86=E9=80=89=E4=B8=AD=E5=8C=BA=E5=9F=9F= =E8=BF=9B=E8=A1=8C=E5=8C=B9=E9=85=8D=E7=9A=84=E6=93=8D=E4=BD=9C=EF=BC=8C=E4= =BE=8B=E5=A6=82=E9=80=89=E4=B8=AD=E5=8C=BA=E5=9F=9F=E4=B8=A4=E8=BE=B9=E5=90= =8C=E6=97=B6=E8=BF=9B=E8=A1=8C=E6=B7=BB=E5=8A=A0=E6=88=96=E4=BF=AE=E6=94=B9= =E6=8B=AC=E5=8F=B7=EF=BC=8C=E5=BC=95=E5=8F=B7=E7=AD=89=E6=93=8D=E4=BD=9C=E3= =80=82 >>=20 >> =E4=B8=8B=E8=BD=BD=E5=AE=89=E8=A3=85=E5=90=8E=E4=BD=BF=E7=94=A8=E4=B8=8B= =E9=9D=A2=E7=9A=84=E4=BB=A3=E7=A0=81=E5=B0=86=E5=85=B6=E6=BF=80=E6=B4=BB=EF= =BC=8C >>=20 >> #+BEGIN_SRC emacs-lisp >> (require 'evil-surround) >> (global-evil-surround-mode) >> #+END_SRC >>=20 >> =E7=AE=80=E5=8D=95=E7=9A=84=E4=BD=BF=E7=94=A8=E6=96=B9=E6=B3=95=E5=B0=B1= =E6=98=AF=E5=9C=A8=E9=80=89=E4=B8=AD=E6=89=80=E9=80=89=E5=8C=BA=E5=9F=9F=E5= =90=8E=EF=BC=8C=E4=BD=BF=E7=94=A8 =3DS(=3D = =E6=9D=A5=E5=B0=86=E9=80=89=E4=B8=AD=E5=8C=BA=E5=9F=9F=E5=8C=85=E6=8B=AC=E5= =9C=A8=E6=8B=AC=E5=8F=B7=E4=B9=8B=E4=B8=AD=E3=80=82=E5=A6=82=E6=9E=9C=E6=83= =B3=E5=B0=86=E6=8B=AC=E5=8F=B7=E6=94=B9=E5=8F=98=E6=88=90 =3D"=3D = =E5=8F=AF=E4=BB=A5=E5=9C=A8=E9=80=89=E4=B8=AD=E5=90=8E=E4=BD=BF=E7=94=A8 = =3Dcs("=3D >>=20 >> You can get the whole file in = https://github.com/emacs-china/Spacemacs-rocks/blob/master/README.org = >. >>=20 >> But pasting the formatted resulted this: >>=20 >>=20 >>=20 >> The encoding is wrong. Adding a =E2=80=98-inputencoding UTF-8=E2=80=99 = fixes it. >>=20 >=20 > I added this to the macOSX command. thanks for the solution! >=20 >>=20 >> Really cool! That=E2=80=99s what I want. >>=20 >> Any workaround for that unwanted evil behaviour? I rely on evil a = lot.=20 >>=20 >>=20 >>> On Jun 29, 2016, at 10:25 PM, John Kitchin > wrote: >>>=20 >>>=20 >>> Jiegec writes: >>>=20 >>>> I=E2=80=99m testing this in OS X. I can confirm this works though = it seems to conflict with >>>> some other packages here which constantly copy the selected region = and then >>>> overwrite the result of ox-clip. >>> What kind of package is that? None of the kill commands can use the >>> clipboard that ox-clip sends things too as far as I know. I don't = see >>> how this is possible. >>>=20 >>>> I have checked the output of textutil and use the=20 >>>> same command in shell and that works. One feedback: are there = internal functions >>>> to manipulate the system clipboard? I am in favour of those instead = of >>>> pbcopy. >>>=20 >>> There are none that I know of (or I would have used them ;). >>>=20 >>>> As in mentioned in = https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard = = > = >>, >>>> pbcopy sometimes does not work. The link above says =E2=80=98Under = Yosemite=20 >>>> (and later) pasteboard access seems to work fine without the = program from=20 >>>> this repository.=E2=80=99 but this is not true in my laptop in OS X = El Capitan >>>> 10.11.5. >>>=20 >>> That could be true. I don't have access to anything that modern yet.=20= >>>=20 >>>>=20 >>>>> On Jun 29, 2016, at 9:16 PM, John Kitchin = wrote: >>>>>=20 >>>>> its not there yet. I would like some people to test it out a = little >>>>> maybe? get some feedback on it. Then it will probably go to MELPA. >>>>>=20 >>>>> Jiege Chen writes: >>>>>=20 >>>>>> John Kitchin wrote: >>>>>>> Hi everyone, >>>>>>>=20 >>>>>>> I extended the work I did here >>>>>>> = http://kitchingroup.cheme.cmu.edu/blog/2016/06/16/Copy-formatted-org-mode-= text-from-Emacs-to-other-applications/ >>>>>>> on copying formatted org-mode to other applications so it is >>>>>>> approximately cross-platform now. There is one command >>>>>>> `ox-clip-formatted-copy' that should copy a region in an = org-file with >>>>>>> formatting to paste into other applications on Windows, Mac and = Linux. >>>>>>>=20 >>>>>>> https://github.com/jkitchin/scimax/blob/master/ox-clip.el >>>>>>>=20 >>>>>>> Try it out! >>>>>>>=20 >>>>>>=20 >>>>>> Impressive. I'd love ox-clip to be released in MELPA. Is that = already done? >>>>>=20 >>>>>=20 >>>>> --=20 >>>>> Professor John Kitchin >>>>> Doherty Hall A207F >>>>> Department of Chemical Engineering >>>>> Carnegie Mellon University >>>>> Pittsburgh, PA 15213 >>>>> 412-268-7803 >>>>> @johnkitchin >>>>> http://kitchingroup.cheme.cmu.edu >>>>>=20 >>>=20 >>>=20 >>> --=20 >>> Professor John Kitchin >>> Doherty Hall A207F >>> Department of Chemical Engineering >>> Carnegie Mellon University >>> Pittsburgh, PA 15213 >>> 412-268-7803 >>> @johnkitchin >>> http://kitchingroup.cheme.cmu.edu = > >=20 >=20 > --=20 > Professor John Kitchin > Doherty Hall A207F > Department of Chemical Engineering > Carnegie Mellon University > Pittsburgh, PA 15213 > 412-268-7803 > @johnkitchin > http://kitchingroup.cheme.cmu.edu --Apple-Mail=_55932CDB-33D9-48A3-820A-D0C98F32F4EE Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 I=E2=80=99m quite confused with the difference between = CLIPBOARD and PRIMARY
in X11 and in OS X. 

Evil calls = `x-select-text=E2=80=99 in `evil-visual-{pre,post}-command=E2=80=99.
=

And here is the = document of `x-select-text=E2=80=99:

x-select-text is an = alias for =E2=80=98gui-select-text=E2=80=99 in = =E2=80=98select.el=E2=80=99.

(x-select-text TEXT)

This function is = obsolete since 25.1;
use =E2=80=98gui-select-text=E2=80= =99 instead.

Select TEXT, a string, according to the window = system.
if =E2=80=98select-enable-clipboard=E2=80=99 = is non-nil, copy TEXT to the system=E2=80=99s clipboard.
If =E2=80=98select-enable-primary=E2=80=99 is non-nil, put = TEXT in the primary selection.

MS-Windows does not have a "primary" = selection.

So = I set select-enable-clipboard to nil and now it works as expected = =E2=80=94
`ox-clip' a region, when pasting in = Libreoffice I get the formatted version,
when = pasting in Emacs I get the original text.


On Jun 30, 2016, at 8:13 PM, = John Kitchin <jkitchin@andrew.cmu.edu> wrote:

Thanks for the feedback.

I noticed at the bottom of = `gui-set-selection': Note that on MS-Windows,
primary and = secondary selections set by Emacs are not available to other
programs. It looks = like Emacs won't support this out of the box soon ;)

But the text = to be copied here is in RTF, but Emacs
is hardcoded to = copy texts. Damn. We have to use
pbcopy or to change Emacs = internal code.


Now things go back to finding the = culprit of
overwriting the clipboard. And I traced to
`evil-visual-update-x-selection=E2=80=99 called in 
`evil-visual-{pre,post}-command=E2=80=99. Oh I don=E2=80=99t = understand
why evil does this. Disabling evil-mode = works.

That sounds "evil". How do you ever copy = anything? I still don't really
understand why it is an issue for ox-clip = unless what is really happening
is evil messes up the active region which = is exported by org-mode. The
ox-clip command doesn't touch the emacs = clipboard at all I think. It
only uses system commands to put stuff on = the system clipboards (which
are not directly visible to emacs in the = first place).

The ox-clip = commands don't currently copy anything you can paste back
into emacs. I have = debated doing that, but it adds a noticeable lag for
the copy command = since an org-export is involved, and if you are pasting
back to emacs that = is not needed.

A solution would be = a new copy command that just does a regular copy all
the time, but with = a prefix arg does a formatted copy for pasting
elsewhere. I just = use two different key bindings now. M-w for copy, and
H-k for formatted = copy.


Then here = comes another bug:

I=E2=80=99m testing on a = Chinese org file. Here is the part:

*** = Evil-Surround

[[https://github.com/timcharper/evil-surround][Evil-surround]= ] =E6=98=AF=E4=B8=80=E4=B8=AA Vim = =E4=B8=8A=E9=9D=9E=E5=B8=B8=E5=B8=B8=E7=94=A8=E7=9A=84=E6=8F=92=E4=BB=B6=E6= =94=B9=E5=86=99=E7=9A=84=EF=BC=8C=E4=BD=BF=E7=94=A8=E5=AE=83=E5=8F=AF=E4=BB= =A5=E5=BF=AB=E9=80=9F=E7=9A=84=E5=B0=86=E9=80=89=E4=B8=AD=E5=8C=BA=E5=9F=9F= =E8=BF=9B=E8=A1=8C=E5=8C=B9=E9=85=8D=E7=9A=84=E6=93=8D=E4=BD=9C=EF=BC=8C=E4= =BE=8B=E5=A6=82=E9=80=89=E4=B8=AD=E5=8C=BA=E5=9F=9F=E4=B8=A4=E8=BE=B9=E5=90= =8C=E6=97=B6=E8=BF=9B=E8=A1=8C=E6=B7=BB=E5=8A=A0=E6=88=96=E4=BF=AE=E6=94=B9= =E6=8B=AC=E5=8F=B7=EF=BC=8C=E5=BC=95=E5=8F=B7=E7=AD=89=E6=93=8D=E4=BD=9C=E3= =80=82

=E4=B8=8B=E8=BD=BD=E5=AE=89=E8=A3=85=E5=90=8E=E4=BD=BF=E7=94=A8= =E4=B8=8B=E9=9D=A2=E7=9A=84=E4=BB=A3=E7=A0=81=E5=B0=86=E5=85=B6=E6=BF=80=E6= =B4=BB=EF=BC=8C

#+BEGIN_SRC emacs-lisp
(require 'evil-surround)
(global-evil-surround-mode)
#+END_SRC

=E7=AE=80=E5=8D=95=E7=9A=84=E4=BD=BF=E7=94=A8=E6=96=B9=E6=B3=95= =E5=B0=B1=E6=98=AF=E5=9C=A8=E9=80=89=E4=B8=AD=E6=89=80=E9=80=89=E5=8C=BA=E5= =9F=9F=E5=90=8E=EF=BC=8C=E4=BD=BF=E7=94=A8  =3DS(=3D = =E6=9D=A5=E5=B0=86=E9=80=89=E4=B8=AD=E5=8C=BA=E5=9F=9F=E5=8C=85=E6=8B=AC=E5= =9C=A8=E6=8B=AC=E5=8F=B7=E4=B9=8B=E4=B8=AD=E3=80=82=E5=A6=82=E6=9E=9C=E6=83= =B3=E5=B0=86=E6=8B=AC=E5=8F=B7=E6=94=B9=E5=8F=98=E6=88=90 =3D"=3D = =E5=8F=AF=E4=BB=A5=E5=9C=A8=E9=80=89=E4=B8=AD=E5=90=8E=E4=BD=BF=E7=94=A8 = =3Dcs("=3D

You can get the whole file = in https://github.com/emacs-china/Spacemacs-rocks/blob/master/READ= ME.org<https://github.com/emacs-china/Spacemacs-rocks/blob/master/READ= ME.org>.

But pasting the formatted = resulted this:



The encoding is wrong. Adding a =E2=80=98-inputencoding = UTF-8=E2=80=99 fixes it.


I added this to the = macOSX command. thanks for the solution!


Really cool! That=E2=80=99s what I want.

Any workaround for that unwanted evil behaviour? I rely on = evil a lot. 


On Jun 29, 2016, at 10:25 PM, John Kitchin <jkitchin@andrew.cmu.edu> wrote:


Jiegec writes:

I=E2=80=99m testing this = in OS X. I can confirm this works though it seems to conflict with
some other packages here which constantly copy the selected = region and then
overwrite the result of ox-clip.
What kind of package is that? None of the kill = commands can use the
clipboard that ox-clip sends things = too as far as I know. I don't see
how this is possible.

I have = checked the output of textutil and use the 
same command = in shell and that works. One feedback: are there internal functions
to manipulate the system clipboard? I am in favour of those = instead of
pbcopy.

There are none that I know of (or I would have used them = ;).

As = in mentioned in https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard <https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard> = <https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard<<= a href=3D"https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard" = class=3D"">https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard>&= gt;,
pbcopy sometimes does not work. The link above says = =E2=80=98Under Yosemite 
(and later) = pasteboard access seems to work fine without the program from 
this = repository.=E2=80=99 but this is not true in my laptop in OS X El = Capitan
10.11.5.

That could be true. I don't have access to anything that = modern yet. 


On Jun 29, 2016, at 9:16 = PM, John Kitchin <jkitchin@andrew.cmu.edu> wrote:

its not there yet. I would like some people to test it out a = little
maybe? get some feedback on it. Then it will = probably go to MELPA.

Jiege Chen writes:

John = Kitchin <jkitchin@andrew.cmu.edu> wrote:
Hi everyone,

I extended the work I did here
http://kitchingroup.cheme.cmu.edu/blog/2016/06/16/Copy-formatte= d-org-mode-text-from-Emacs-to-other-applications/
on = copying formatted org-mode to other applications so it is
approximately cross-platform now. There is one command
`ox-clip-formatted-copy' that should copy a region in an = org-file with
formatting to paste into other applications = on Windows, Mac and Linux.

https://github.com/jkitchin/scimax/blob/master/ox-clip.el

Try it out!


Impressive. I'd love ox-clip to = be released in MELPA. Is that already done?

-- 
Professor = John Kitchin
Doherty Hall A207F
Department = of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu



-- 
Professor = John Kitchin
Doherty Hall A207F
Department = of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu <http://kitchingroup.cheme.cmu.edu/>


-- 
Professor John = Kitchin
Doherty Hall A207F
Department of Chemical = Engineering
Carnegie Mellon University
Pittsburgh, PA = 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu
<= br class=3D"">= --Apple-Mail=_55932CDB-33D9-48A3-820A-D0C98F32F4EE--