From 66fde316d31605bcd5dad42c0c7caa6c355f1a56 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 28 Aug 2021 23:09:15 -0500 Subject: Fancify browse-url-set-handlers --- init.el | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/init.el b/init.el index 5ab1559..4de92d4 100644 --- a/init.el +++ b/init.el @@ -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")) -- cgit 1.4.1-21-gabe81