Function: browse-url-select-handler

browse-url-select-handler is an autoloaded and byte-compiled function defined in browse-url.el.gz.

Signature

(browse-url-select-handler URL &optional KIND)

Documentation

Return a handler of suitable for browsing URL.

This searches browse-url-handlers, and browse-url-default-handlers for a matching handler. Return nil if no handler is found.

If KIND is given, the search is restricted to handlers whose function symbol has the symbol-property browse-url-browser-kind set to KIND.

Currently, it also consults browse-url-browser-function first if it is set to an alist, although this usage is deprecated since Emacs 28.1 and will be removed in a future release.

Source Code

;; Defined in /usr/src/emacs/lisp/net/browse-url.el.gz
;;;###autoload
(defun browse-url-select-handler (url &optional kind)
  "Return a handler of suitable for browsing URL.
This searches `browse-url-handlers', and
`browse-url-default-handlers' for a matching handler.  Return nil
if no handler is found.

If KIND is given, the search is restricted to handlers whose
function symbol has the symbol-property `browse-url-browser-kind'
set to KIND.

Currently, it also consults `browse-url-browser-function' first
if it is set to an alist, although this usage is deprecated since
Emacs 28.1 and will be removed in a future release."
  (catch 'custom-url-handler
    (dolist (rxpred-handler
             (append
              ;; The alist choice of browse-url-browser-function
              ;; is deprecated since 28.1, so the (unless ...)
              ;; can be removed at some point in time.
              (when (and (consp browse-url-browser-function)
                         (not (functionp browse-url-browser-function)))
                (lwarn 'browse-url :warning
                       "Having `browse-url-browser-function' set to an
alist is deprecated.  Use `browse-url-handlers' instead.")
                browse-url-browser-function)
              browse-url-handlers
              browse-url-default-handlers))
      (let ((rx-or-pred (car rxpred-handler))
            (handler (cdr rxpred-handler)))
        (when (and (or (null kind)
                       (eq kind (browse-url--browser-kind
                                 handler url)))
                   (if (functionp rx-or-pred)
                       (funcall rx-or-pred url)
                     (string-match-p rx-or-pred url)))
          (throw 'custom-url-handler handler))))))