Add more domains to browse-url

Honestly, this could be ... bettered.
This commit is contained in:
Case Duckworth 2022-02-16 23:14:52 -06:00
parent 82869c1f4f
commit 4219f9702b
1 changed files with 16 additions and 11 deletions

27
init.el
View File

@ -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"))