Re: [O] Org protocol, Windows 10

2017-08-26 Thread Fabrice Popineau
2017-08-26 10:31 GMT+02:00 Nikolay Kudryavtsev <
nikolay.kudryavt...@gmail.com>:

> Hello Fabrice.
>
> If you set your protocol bookmarklet with a single slash like
> "org-protocol:/capture" everything would work.
>

You are right: using this syntax, emacslientw gets the right url without
the superflous / after capture.
This seems strange to me, because I always thought that urls would always
start with protocol:// .

Maybe this should be advertised more loudly.

Thanks a lot.

Fabrice


> I asked before for someone from the dev team to weight in on it, because
> org test seem to use both.
>
> --
> Best Regards,
> Nikolay Kudryavtsev
>
>


Re: [O] Org protocol, Windows 10

2017-08-26 Thread Nikolay Kudryavtsev

Hello Fabrice.

If you set your protocol bookmarklet with a single slash like 
"org-protocol:/capture" everything would work.


I asked before for someone from the dev team to weight in on it, because 
org test seem to use both.


--
Best Regards,
Nikolay Kudryavtsev




[O] Org protocol, Windows 10

2017-08-25 Thread Fabrice Popineau
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=http%3A%2F%
2Fkitchingroup.cheme.cmu.edu
%2Fblog%2F2014%2F07%2F17%2FPandoc-does-org-mode-now%2F=Pandoc%20does%20org-mode%20now=foobar

is received on emacsclientw command line as:

org-protocol://capture/?template=c=http%3A%2F%
2Fkitchingroup.cheme.cmu.edu
%2Fblog%2F2014%2F07%2F17%2FPandoc-does-org-mode-now%2F=Pandoc%20does%20org-mode%20now=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