emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-protocol: deal with broken links on windows
@ 2017-08-23 20:02 Ingo Lohmar
  2017-08-23 20:59 ` Nikolay Kudryavtsev
  0 siblings, 1 reply; 4+ messages in thread
From: Ingo Lohmar @ 2017-08-23 20:02 UTC (permalink / raw)
  To: emacs-orgmode

Dear all,

It appears that org-capture (with the no-frills, no-extensions method of
adding a registry entry for org-protocol) using new-style links is not
working correctly on Windows (tested with recent Firefoxes as well as
the Chromium derivative Iridium).

What happens is that the browser binary with full path is prepended to
the protocol, and an extra "/" is added before the URL query string.
That is, what *should* read

  org-protocol:/capture?template=y&url=http%3A%2F%2Fjira%2Fbrowse%2FSDST-705&title=SOMETHING

is actually passed as 

  c:/Program Files/Iridium/58.0.0.0/org-protocol:/capture/?template=y&url=http%3A%2F%2Fjira%2Fbrowse%2FSDST-705&title=SOMETHING

as the FNAME argument to `org-protocol-check-filename-for-protocol'.  I
have no idea what brought about this crazy change, but I've long ago
stopped trying to understand Windows' ways --- nowadays I just lobby
against using it.

Anyway, I've successfully (regular use for several weeks) patched this
with an advice:

>------------------------------------------------------------------------------<

(defun adv/sanitize-broken-windows-link (args)
  (let ((fname (car args)))
    (cons
     (if (string-match "^[a-z]:/[-a-zA-Z0-9 /._]+/\\(org-protocol:/[^/\\?]*\\)/\\(\\?.*\\)$" fname)
         (concat (match-string 1 fname) (match-string 2 fname))
       fname)
     (cdr args))))
(advice-add #'org-protocol-check-filename-for-protocol :filter-args #'adv/sanitize-broken-windows-link)

>------------------------------------------------------------------------------<

I only use this on the Windows machine, where FNAME reliably has the
above form for me (probably better ONLY use it when (eq system-type
'windows-nt)).  Also, the regexp is probably too unspecific even on
Windows.  Could we still add this or an improved transformation of FNAME
to `org-protocol-check-filename-for-protocol' (assuming there's no
better way)?

Thank you!

Ingo

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

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

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-23 20:02 org-protocol: deal with broken links on windows Ingo Lohmar
2017-08-23 20:59 ` Nikolay Kudryavtsev
2017-08-24 17:00   ` Ingo Lohmar
2017-08-25 19:38     ` Nikolay Kudryavtsev

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).