From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ingo Lohmar Subject: org-protocol: deal with broken links on windows Date: Wed, 23 Aug 2017 22:02:10 +0200 Message-ID: <87d17mm4sd.fsf@acer.localhost.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38405) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkbr0-0005GD-Di for emacs-orgmode@gnu.org; Wed, 23 Aug 2017 16:02:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dkbqx-0003dK-6a for emacs-orgmode@gnu.org; Wed, 23 Aug 2017 16:02:18 -0400 Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]:38140) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dkbqx-0003d9-02 for emacs-orgmode@gnu.org; Wed, 23 Aug 2017 16:02:15 -0400 Received: by mail-wm0-x232.google.com with SMTP id l19so6384627wmi.1 for ; Wed, 23 Aug 2017 13:02:13 -0700 (PDT) Received: from localhost (xdsl-78-35-232-180.netcologne.de. [78.35.232.180]) by smtp.gmail.com with ESMTPSA id a33sm1314305edd.67.2017.08.23.13.02.11 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 Aug 2017 13:02:11 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org 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