Change browse-url advice for older releases
[elpher.git] / elpher.el
index 90f7672..f94b33f 100644 (file)
--- a/elpher.el
+++ b/elpher.el
 
 (defcustom elpher-open-urls-with-eww nil
   "If non-nil, open URL selectors using eww.
-Otherwise, use the system browser via the BROWSE-URL function."
+Otherwise, use the system browser via the `browse-url' function."
   :type '(boolean))
 
 (defcustom elpher-use-header t
@@ -1827,8 +1827,8 @@ of gemini, gopher or finger."
 (defun elpher-org-follow-link (link protocol)
   "Visit a LINK for the given PROTOCOL.
 
-PROTOCOL may be one of gemini, gopher or finger. This method also support old
-paramter elpher, where link is self-contained."
+PROTOCOL may be one of gemini, gopher or finger.  This method also
+supports the old protocol elpher, where the link is self-contained."
   (let ((url (if (equal protocol "elpher")
                  (string-remove-prefix "elpher:" link)
                (format "%s:%s" protocol link))))
@@ -1875,9 +1875,12 @@ paramter elpher, where 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