emacs-orgmode
[Top][All Lists]
Advanced

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

[O] org-protocol: deal with broken links on windows


From: Ingo Lohmar
Subject: [O] org-protocol: deal with broken links on windows
Date: Wed, 23 Aug 2017 22:02:10 +0200

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



reply via email to

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