Let browse-url open more video hyperlinks with mpv and cleanup

This commit is contained in:
Gerard Vermeulen 2022-05-04 07:14:07 +02:00
parent f3b9f4a4fa
commit 0f176de30a

View File

@ -3580,21 +3580,27 @@ Listing [[lst:configure-browse-url]] configures =browse-url=.
(with-eval-after-load 'browse-url
(defun browse-url-mpv (url &optional _)
(start-process "mpv" nil "mpv" url))
(defconst browse-url-mpv-regexp
(rx bos
(or "http://" "https://")
(or (or "www.youtube.com/" "youtu.be/" "soundcloud.com/")
(seq (+? nonl) (or ".mp4" ".webm") eos)))
"Match hyperlinks to browse with mpv.")
(if (version< emacs-version "28.0")
(custom-set-variables
'(browse-url-browser-function
`((,(rx (or "https://www.youtube.com/" "https://youtu.be/")) . browse-url-mpv)
("https://soundcloud.com/" . browse-url-mpv)
("." . eww-browse-url)))
`(browse-url-generic-program ,(or (when (eq system-type 'darwin) "open")
(executable-find "firefox"))))
(custom-set-variables
'(browse-url-handlers
`((,(rx (or "https://www.youtube.com/" "https://youtu.be/")) . browse-url-mpv)
("https://soundcloud.com/" . browse-url-mpv)
("." . eww-browse-url)))
`(browse-url-generic-program ,(or (when (eq system-type 'darwin) "open")
(executable-find "firefox"))))))
`((,browse-url-mpv-regexp . browse-url-mpv)
("." . eww-browse-url))))
(custom-set-variables
'(browse-url-handlers
`((,browse-url-mpv-regexp . browse-url-mpv)
("." . eww-browse-url)))))
(custom-set-variables
`(browse-url-generic-program ,(or (when (eq system-type 'darwin) "open")
(executable-find "firefox")))))
#+end_src
*** [[https://en.wikipedia.org/wiki/Eww_(web_browser)][Emacs Web Wowser]]