From: Alex Schroeder Date: Fri, 2 Jul 2021 07:31:33 +0000 (+0200) Subject: Change browse-url advice for older releases X-Git-Tag: v3.0.0~22^2~6 X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=commitdiff_plain;h=e3fca3512d458c4a78ef9b3d87b66e952f2b5f94;p=elpher.git Change browse-url advice for older releases package does not offer browse-url-default-handlers, but if you set The code used to advise browse-url-default-browser if your browse-url browse-url-browser-function to something else, like eww-browse-url, then that advice did not apply. The code now advises the function set in the browse-url-browser-function variable, meaning that it should advise the right function. Also added a small doc string to the lambda used as advice. --- diff --git a/elpher.el b/elpher.el index 75c9a7b..f94b33f 100644 --- a/elpher.el +++ b/elpher.el @@ -1875,9 +1875,12 @@ supports the old protocol elpher, where the link is self-contained." (add-to-list 'browse-url-default-handlers '("^\\(gopher\\|finger\\|gemini\\)://" . elpher-browse-url-elpher)) - ;; Patch browse-url-default-browser for older ones - (advice-add 'browse-url-default-browser :before-while + ;; Patch `browse-url-browser-function' for older ones. The value of + ;; that variable is `browse-url-default-browser' by default, so + ;; that's the function that gets advised. + (advice-add browse-url-browser-function :before-while (lambda (url &rest _args) + "Handle gemini, gopher, and finger schemes using Elpher." (let ((scheme (downcase (car (split-string url ":" t))))) (if (member scheme '("gemini" "gopher" "finger")) ;; `elpher-go' always returns nil, which will stop the