From 90ce86dc9cd1915c13adeb7e3ea4632f27fe3a5b Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 3 Jan 2022 15:18:05 -0600 Subject: Fix browse-url urls --- init.el | 9 +++++---- lisp/+browse-url.el | 9 +++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/init.el b/init.el index 0b1d8b0..261d8c7 100644 --- a/init.el +++ b/init.el @@ -96,6 +96,7 @@ (:require +browse-url) (:option browse-url-browser-function #'eww-browse-url + +browse-url-browser-function browse-url-browser-function browse-url-secondary-browser-function (if (executable-find "firefox") #'browse-url-firefox #'browse-url-default-browser) @@ -137,10 +138,10 @@ #'+browse-url-with-mpv browse-url-secondary-browser-function) args))) - (cons (lambda (url) ; non-eww-friendly websites - (cl-member url +browse-url-secondary-browser-regexps - :test 'string-match-p)) - #'browse-url-secondary-browser-function))) + (cons (+browse-url-secondary-browser-regexps-combine) ; non-text websites + browse-url-secondary-browser-function) + (cons "." ; everything else + browse-url-browser-function))) ;; Transform URLs before passing to `browse-url' (:option +browse-url-transformations `((,(rx "//" (or "youtube.com" "youtu.be")) diff --git a/lisp/+browse-url.el b/lisp/+browse-url.el index 83f43cf..89b21e4 100644 --- a/lisp/+browse-url.el +++ b/lisp/+browse-url.el @@ -74,6 +74,15 @@ named NAME, defaulting to \"+browse-url-with-VIEWER\", and the variable "List of URL regexps to open with `browse-url-secondary-browser-function'." :type '(repeat regexp)) +;; Because `browse-url-browser-function', when set to an alist, must be of the +;; form (REGEXP . FUNCTION), I need to convert +;; `+browse-url-secondary-browser-regexps' into a regexp. + +(defun +browse-url-secondary-browser-regexps-combine () + "Combine `+browse-url-secondary-browser-regexps'. +This combines a list of regexps into one regexp." + (mapconcat #'identity +browse-url-secondary-browser-regexps "\\\|")) + ;;; URL Transformation Functions ;; There's a lot of bad websites out there. Luckily we can easily redirect ;; requests to more privacy-respecting, or just less javascript-ridden, sites -- cgit 1.4.1-21-gabe81