Fancify browse-url-set-handlers

This commit is contained in:
Case Duckworth 2021-08-28 23:09:15 -05:00
parent 58846be174
commit 66fde316d3
1 changed files with 25 additions and 9 deletions

34
init.el
View File

@ -81,15 +81,31 @@
browse-url-firefox-new-window-is-tab t)
(acdw/browse-url-set-handlers
`(("\\.jpe?g\\'" . ,(if (executable-find "feh")
#'browse-url-feh
#'eww-browse-url))
("youtube\\.com\\|youtu\\.be" . ,(if (executable-find "mpv")
#'browse-url-mpv
#'eww-browse-url))
("google\\.com" . browse-url-default-browser)
("\\(twitter\\.com\\|t\\.co\\)" . acdw/eww-browse-twitter-url)
("." . eww-browse-url)))
(list
(cons (rx (seq "." (or "jpeg" "jpg" ; images
"png")
eos))
(lambda (&rest args)
(apply (if (executable-find "feh")
#'browse-url-feh
#'eww-browse-url)
args)))
(cons (rx (or "youtube.com" ; videos
"youtu.be"
(seq "." (or "mp4"
"gif")
eos)))
(lambda (&rest args)
(apply (if (executable-find "mpv")
#'browse-url-mpv
browse-url-secondary-browser-function)
args)))
(cons (rx (or "google.com" ; websites that don't work with eww
"reddit.com"
"twitter.com"))
browse-url-secondary-browser-function)
(cons "." ; everything else
#'eww-browse-url)))
;; Buttonize gemini:// links.
(acdw/add-button-url-regexp-protocol "gemini"))