fix(org): org-protocol not triggering for its uris

A more elegant solution will have to wait until the CLI rewrite (where
modules can supply patches for its packages, then I could hoist
org-protocol-check-filename-for-protocol into the autoloads file using
autoload cookie magic).

Fix: #6481
Fix: #5997
This commit is contained in:
Henrik Lissner 2022-06-21 03:02:27 +02:00
parent b0b727824a
commit d6d1e600c0
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -1302,8 +1302,24 @@ between the two."
(defadvice! +org--server-visit-files-a (fn files &rest args) (defadvice! +org--server-visit-files-a (fn files &rest args)
"Advise `server-visit-files' to load `org-protocol' lazily." "Advise `server-visit-files' to load `org-protocol' lazily."
:around #'server-visit-files :around #'server-visit-files
(if (not (cl-loop for var in files (if (not (cl-loop with protocol =
if (string-match-p "://" (car var)) (if IS-WINDOWS
;; On Windows, the file arguments for `emacsclient'
;; get funnelled through `expand-file-path' by
;; `server-process-filter'. This substitutes
;; backslashes with forward slashes and converts each
;; path to an absolute one. However, *all* absolute
;; paths on Windows will match the regexp ":/+", so we
;; need a more discerning regexp.
(regexp-quote
(or (bound-and-true-p org-protocol-the-protocol)
"org-protocol"))
;; ...but since there is a miniscule possibility users
;; have changed `org-protocol-the-protocol' I don't want
;; this behavior for macOS/Linux users.
"")
for var in files
if (string-match-p (format "%s:/+" protocol) (car var))
return t)) return t))
(apply fn files args) (apply fn files args)
(require 'org-protocol) (require 'org-protocol)