From a5d0c182a514d567bebf99a3fc6a0470f9c06166 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Fri, 31 Dec 2021 15:45:31 -0600 Subject: Better setup secondary-browser urls --- init.el | 21 ++++----------------- lisp/+browse-url.el | 11 +++++++++++ 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/init.el b/init.el index 6aa375a..e5d113b 100644 --- a/init.el +++ b/init.el @@ -121,22 +121,10 @@ #'+browse-url-with-mpv browse-url-secondary-browser-function) args))) - (cons (rx ; non-eww-friendly websites - (or - "github.com" - "gitlab.com" - "google.com" - "imgur.com" - "pixelfed" "instagram.com" "bibliogram.art" - "reddit.com" "teddit.net" - "tildes.net" - "taskiq" - "twitter.com" "nitter.net" - "streamable.com" - )) - browse-url-secondary-browser-function) - (cons "." ; everything else - #'eww-browse-url))) + (cons (lambda (url) ; non-eww-friendly websites + (cl-member url +browse-url-secondary-browser-regexps + :test 'string-match-p)) + #'browse-url-secondary-browser-function))) ;; Transform URLs before passing to `browse-url' (:option +browse-url-transformations `((,(rx "//" (or "youtube.com" "youtu.be")) @@ -157,7 +145,6 @@ (:option calendar-location-name _location-name calendar-latitude _location-latitude calendar-longitude _location-longitude)) - (setup compile (:option compilation-always-kill t compilation-ask-about-save nil diff --git a/lisp/+browse-url.el b/lisp/+browse-url.el index d073d50..83f43cf 100644 --- a/lisp/+browse-url.el +++ b/lisp/+browse-url.el @@ -63,6 +63,17 @@ named NAME, defaulting to \"+browse-url-with-VIEWER\", and the variable "Image URL: " :name "+browse-image-with-mpv") +;;; Easily add extra domains to open in `browse-url-secondary-browser-function' +;; I like to open most websites in eww, but a lot of website on the modern web +;; just make that hard to do. Right now I have a list in `browse-url-handlers' +;; with domains in an (rx (or ...)) form, but that's not super easy to config. +;; With this custom setting, I'm making it a list that'll be way easier to +;; customize. + +(defcustom +browse-url-secondary-browser-regexps nil + "List of URL regexps to open with `browse-url-secondary-browser-function'." + :type '(repeat regexp)) + ;;; 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