From 4219f9702bcb33ec6d724e52282af4826cabb4bd Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 16 Feb 2022 23:14:52 -0600 Subject: Add more domains to browse-url Honestly, this could be ... bettered. --- init.el | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/init.el b/init.el index af6daeb..75228cc 100644 --- a/init.el +++ b/init.el @@ -178,19 +178,18 @@ ;; Set up external browsing URLs. (add-to-list '+custom-variable-allowlist '+browse-url-secondary-browser-regexps) - (dolist (domain '("github.com" "twitch.tv" - "gitlab.com" - "google.com" - "imgur.com" + (dolist (domain '("github.com" "gitlab.com" "google.com" + "imgur.com" "twitch.tv" "pixelfed" "instagram.com" "bibliogram.art" "reddit.com" "teddit.net" - "taskiq" "twitter.com" "nitter.net" "t.co" "streamable.com" "spotify.com" - "hetzner.cloud")) + "hetzner.cloud" + "melpa.org")) (add-to-list '+browse-url-secondary-browser-regexps (replace-regexp-in-string "\\." "\\\\." domain))) ;; Set up URL handlers. + (require 'chd) (+browse-url-set-handlers (list (cons (rx ; images @@ -211,14 +210,20 @@ #'+browse-url-with-mpv browse-url-secondary-browser-function) args))) + (cons chd/url-regexps #'browse-url-chrome) (cons (+browse-url-secondary-browser-regexps-combine) ; non-text websites - browse-url-secondary-browser-function) + (lambda (&rest args) + (apply browse-url-secondary-browser-function args))) (cons "xkcd\\.com" - (if (fboundp 'xkcd-get) - #'+xkcd-get-from-url - +browse-url-browser-function)) + (lambda (&rest args) + (apply (if (fboundp #'xkcd-get) + (progn (require '+xkcd) + #'+xkcd-get-from-url) + +browse-url-browser-function) + args))) (cons "." ; everything else - +browse-url-browser-function))) + (lambda (&rest args) + (apply +browse-url-browser-function args))))) ;; Transform URLs before passing to `browse-url' (:option +browse-url-transformations `((,(rx (or "youtube.com" "youtu.be")) -- cgit 1.4.1-21-gabe81