emacs-orgmode
[Top][All Lists]
Advanced

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

[O] Org protocol, Windows 10


From: Fabrice Popineau
Subject: [O] Org protocol, Windows 10
Date: Fri, 25 Aug 2017 22:51:23 +0200

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="" href="http://2Fkitchingroup.cheme.cmu.edu">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="" href="http://2Fkitchingroup.cheme.cmu.edu">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






reply via email to

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