emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Org protocol, Windows 10
@ 2017-08-25 20:51 Fabrice Popineau
  2017-08-26  8:31 ` Nikolay Kudryavtsev
  0 siblings, 1 reply; 3+ messages in thread
From: Fabrice Popineau @ 2017-08-25 20:51 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org

[-- Attachment #1: Type: text/plain, Size: 2954 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 4208 bytes --]

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

* Re: Org protocol, Windows 10
  2017-08-25 20:51 Org protocol, Windows 10 Fabrice Popineau
@ 2017-08-26  8:31 ` Nikolay Kudryavtsev
  2017-08-26 19:23   ` Fabrice Popineau
  0 siblings, 1 reply; 3+ messages in thread
From: Nikolay Kudryavtsev @ 2017-08-26  8:31 UTC (permalink / raw)
  To: Fabrice Popineau, emacs-orgmode@gnu.org

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

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

* Re: Org protocol, Windows 10
  2017-08-26  8:31 ` Nikolay Kudryavtsev
@ 2017-08-26 19:23   ` Fabrice Popineau
  0 siblings, 0 replies; 3+ messages in thread
From: Fabrice Popineau @ 2017-08-26 19:23 UTC (permalink / raw)
  To: Nikolay Kudryavtsev; +Cc: emacs-orgmode@gnu.org

[-- Attachment #1: Type: text/plain, Size: 646 bytes --]

2017-08-26 10:31 GMT+02:00 Nikolay Kudryavtsev <
nikolay.kudryavtsev@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
>
>

[-- Attachment #2: Type: text/html, Size: 1285 bytes --]

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

end of thread, other threads:[~2017-08-26 19:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-25 20:51 Org protocol, Windows 10 Fabrice Popineau
2017-08-26  8:31 ` Nikolay Kudryavtsev
2017-08-26 19:23   ` Fabrice Popineau

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).