From 869f2192bd9f3df0a67ae7ff73b39e93af1b273f Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 12 Apr 2022 13:18:08 -0500 Subject: Stop being compatible with Emacs < 28 --- init.el | 71 +++++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/init.el b/init.el index 77a6d1a..adb2bdb 100644 --- a/init.el +++ b/init.el @@ -189,41 +189,42 @@ (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 - "." (or "jpeg" "jpg" "png" "bmp") eos) - (lambda (&rest args) - (apply - (cond ((executable-find "mpv") #'+browse-image-with-mpv) - (t #'eww-browse-url)) - args))) - (cons (rx (or ;; videos - "youtube.com" "youtu.be" "invidious" "yewtu.be" - (seq "." (or "mp4" "gif" "mov" "MOV" "webm") eos) - ;; music - "soundcloud.com" "bandcamp.com" - (seq "." (or "ogg" "mp3" "opus" "m4a") eos))) - (lambda (&rest args) - (apply (if (executable-find "mpv") - #'+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 - (lambda (&rest args) - (apply browse-url-secondary-browser-function args))) - (cons "xkcd\\.com" - (lambda (&rest args) - (apply (if (fboundp #'xkcd-get) - (progn (require '+xkcd) - #'+xkcd-get-from-url) - +browse-url-browser-function) - args))) - (cons "." ; everything else - (lambda (&rest args) - (apply +browse-url-browser-function args))))) + (:option browse-url-handlers + (list + (cons (rx ; images + "." (or "jpeg" "jpg" "png" "bmp") eos) + (lambda (&rest args) + (apply + (cond ((executable-find "mpv") #'+browse-image-with-mpv) + (t #'eww-browse-url)) + args))) + (cons (rx (or ;; videos + "youtube.com" "youtu.be" "invidious" "yewtu.be" + (seq "." (or "mp4" "gif" "mov" "MOV" "webm") eos) + ;; music + "soundcloud.com" "bandcamp.com" + (seq "." (or "ogg" "mp3" "opus" "m4a") eos))) + (lambda (&rest args) + (apply (if (executable-find "mpv") + #'+browse-url-with-mpv + browse-url-secondary-browser-function) + args))) + (cons (+browse-url-secondary-browser-regexps-combine) ; non-text websites + (lambda (&rest args) + (apply browse-url-secondary-browser-function args))) + (cons "xkcd\\.com" + (lambda (&rest args) + (apply (if (fboundp #'xkcd-get) + (progn (require '+xkcd) + #'+xkcd-get-from-url) + +browse-url-browser-function) + args))) + (cons "." ; everything else + (lambda (&rest args) + (apply +browse-url-browser-function args))))) + (with-eval-after-load 'chd + (add-to-list 'browse-url-handlers + (cons chd/url-regexps #'browse-url-chrome))) ;; Transform URLs before passing to `browse-url' (:option +browse-url-transformations `((,(rx (or "youtube.com" "youtu.be")) -- cgit 1.4.1-21-gabe81