emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ingo Lohmar <i.lohmar@gmail.com>
To: emacs-orgmode@gnu.org
Subject: org-protocol: deal with broken links on windows
Date: Wed, 23 Aug 2017 22:02:10 +0200	[thread overview]
Message-ID: <87d17mm4sd.fsf@acer.localhost.com> (raw)

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	other threads:[~2017-08-23 20:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-23 20:02 Ingo Lohmar [this message]
2017-08-23 20:59 ` org-protocol: deal with broken links on windows Nikolay Kudryavtsev
2017-08-24 17:00   ` Ingo Lohmar
2017-08-25 19:38     ` Nikolay Kudryavtsev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87d17mm4sd.fsf@acer.localhost.com \
    --to=i.lohmar@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).