From mboxrd@z Thu Jan 1 00:00:00 1970 From: Fabrice Popineau Subject: Org protocol, Windows 10 Date: Fri, 25 Aug 2017 22:51:23 +0200 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="f4030435c980d646a205579a1c54" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49803) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dlLZz-00058P-KQ for emacs-orgmode@gnu.org; Fri, 25 Aug 2017 16:51:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dlLZy-0003ZF-4L for emacs-orgmode@gnu.org; Fri, 25 Aug 2017 16:51:47 -0400 Received: from mail-qt0-x230.google.com ([2607:f8b0:400d:c0d::230]:35482) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dlLZx-0003Ya-V7 for emacs-orgmode@gnu.org; Fri, 25 Aug 2017 16:51:46 -0400 Received: by mail-qt0-x230.google.com with SMTP id x36so4620132qtx.2 for ; Fri, 25 Aug 2017 13:51:44 -0700 (PDT) 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: "emacs-orgmode@gnu.org" --f4030435c980d646a205579a1c54 Content-Type: text/plain; charset="UTF-8" Hi, I am using a recent build of Windows 10 (16251) and org protocol wasn't working for me for quite a long time now. So I decided to look at what went wrong. I found several annoyances. The first one is that Windows seems to rewrite itself the url which is sent to emacsclientw. Some url sent by Chrome as: org-protocol://capture?template=c&url=http%3A%2F% 2Fkitchingroup.cheme.cmu.edu %2Fblog%2F2014%2F07%2F17%2FPandoc-does-org-mode-now%2F&title=Pandoc%20does%20org-mode%20now&body=foobar is received on emacsclientw command line as: org-protocol://capture/?template=c&url=http%3A%2F% 2Fkitchingroup.cheme.cmu.edu %2Fblog%2F2014%2F07%2F17%2FPandoc-does-org-mode-now%2F&title=Pandoc%20does%20org-mode%20now&body=foobar" notice the capture? changed into capture/? This is weird and I wonder if I am alone to see this ? I have no idea when it started to behave this way. I patched org-protocol.el with this: diff --git a/lisp/org-protocol.el b/lisp/org-protocol.el index d37de1113..ccef9c301 100644 --- a/lisp/org-protocol.el +++ b/lisp/org-protocol.el @@ -649,7 +649,10 @@ to deal with new-style links.") (catch 'greedy (dolist (var flist) ;; `\' to `/' on windows. FIXME: could this be done any better? - (let ((fname (expand-file-name (car var)))) + (setcar var (replace-regexp-in-string "^\\(org-protocol://[^/\\?]*\\)/\\?" "\\1?" (car var))) + (let (;; (fname (expand-file-name (car var))) + (fname (car var)) + ) (setq fname (org-protocol-check-filename-for-protocol fname (member var flist) client)) (if (eq fname t) ;; greedy? We need the t return value. There are 2 other problems related to absolute pathnames under Windows. You don't want to pass an url to expand-file-name because the current directory will be prepended to the url, reason why I removed the expand-file-name call in the patch above. Finally, there is another place in lisp/server.el where you may not want to call expand-file-name: diff --git a/lisp/server.el b/lisp/server.el index 1ebefe2866..8ce85646e9 100644 --- a/lisp/server.el +++ b/lisp/server.el @@ -1175,7 +1175,8 @@ server-execute-continuation (when (and (fboundp 'cygwin-convert-file-name-from-windows) (string-match "\\`[A-Za-z]:" file)) (setq file (cygwin-convert-file-name-from-windows file))) - (setq file (expand-file-name file dir)) + (unless (string-match "^[^/]+:/" file) + (setq file (expand-file-name file dir))) (push (cons file filepos) files) (server-log (format "New file: %s %s" file (or filepos "")) With these small changes, org-protocol behaves as expected at least with my configuration. Curious to hear what you guys think about this ? Regards, Fabrice --f4030435c980d646a205579a1c54 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

I am using a recent buil= d of Windows 10 (16251) and =C2=A0org protocol wasn't working for me fo= r quite a long time now.
So I decided to look at what went wrong.=
I found several annoyances.

The first one is that = Windows seems to rewrite itself the url which is sent to emacsclientw.
Some url sent by Chrome as:

org-protocol://c= apture?template=3Dc&url=3Dhttp%3A%2F%2Fkitchingroup.cheme.cmu.edu%2Fblog%2F2014%2F07%2F17%2FPa= ndoc-does-org-mode-now%2F&title=3DPandoc%20does%20org-mode%20now&bo= dy=3Dfoobar

is received on emacsclientw c= ommand line as:

org-protocol://capture/?template= =3Dc&url=3Dhttp%3A%2F%2= Fkitchingroup.cheme.cmu.edu%2Fblog%2F2014%2F07%2F17%2FPandoc-does-org-m= ode-now%2F&title=3DPandoc%20does%20org-mode%20now&body=3Dfoobar&quo= t;

notice the capture? changed into capture/?<= /div>

This is weird and I wonder if I am alone to see th= is ? I have no idea when it started to behave this way.

I patched org-protocol.el with this:

di= ff --git a/lisp/org-protocol.el b/lisp/org-protocol.el
index d37d= e1113..ccef9c301 100644
--- a/lisp/org-protocol.el
+++ = b/lisp/org-protocol.el
@@ -649,7 +649,10 @@ to deal with new-styl= e links.")
=C2=A0 =C2=A0 =C2=A0(catch 'greedy
= =C2=A0 =C2=A0 =C2=A0 =C2=A0(dolist (var flist)
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 ;; `\' to `/' on windows.=C2=A0 FIXME: could this be don= e any better?
- =C2=A0 =C2=A0 =C2=A0 =C2=A0(let ((fname =C2=A0(ex= pand-file-name (car var))))
+ =C2=A0 =C2=A0 =C2=A0 (setcar var (r= eplace-regexp-in-string "^\\(org-protocol://[^/\\?]*\\)/\\?" &quo= t;\\1?" (car var)))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0(let (;; (f= name =C2=A0(expand-file-name (car var)))
+ =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 (fname (car var))
+ =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 )
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(set= q fname (org-protocol-check-filename-for-protocol
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fname = (member var flist) =C2=A0client))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0(if (eq fname t) ;; greedy? We need the t return value.


There are 2 other problems related to = absolute pathnames under Windows.

You don't wa= nt to pass an url to expand-file-name because the current directory will be= prepended to the url, reason why I removed the expand-file-name call in th= e patch above.

Finally, there is another place in = lisp/server.el where you may not want to call expand-file-name:
<= br>
diff --git a/lisp/server.el b/lisp/server.el
i= ndex 1ebefe2866..8ce85646e9 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -1175,7 +1175,8 @@ server-execute-contin= uation
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 (when (and (fboundp 'cygwin-convert-file-name-from-window= s)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(string-match "\\`[A-= Za-z]:" file))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq file (cygwin-convert-file-name-from-w= indows file)))
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 (setq file (expand-file-name file dir))
+ =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (unless (string-mat= ch "^[^/]+:/" file)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq file (expand-file-name file di= r)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 (push (cons file filepos) files)
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (server-log (format "= New file: %s %s"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 file (or filepos ""))
With these small changes, org-protocol behaves as expected at = least with my configuration.

Curious to hear what = you guys think about this ?

Regards,
Fabrice



=

--f4030435c980d646a205579a1c54--