Fix and export the "Browse URL" section

This commit is contained in:
Gerard Vermeulen 2025-01-26 13:48:32 +01:00
parent 75d4e70059
commit f78bc1f5f5

View File

@ -5405,10 +5405,9 @@ point movements visually.
:CUSTOM_ID: sec:hyperlinking-web-navigating
:END:
*** [[info:emacs#Browse-URL][Browse URL (info)]] :noexport:
*** [[info:emacs#Browse-URL][Browse URL (info)]]
:PROPERTIES:
:CUSTOM_ID: sec:browse-url
:header-args:emacs-lisp: :tangle no
:END:
Listing [[lst:configure-browse-url]] configures =browse-url=.
@ -5420,20 +5419,41 @@ Listing [[lst:configure-browse-url]] configures =browse-url=.
#+begin_src emacs-lisp -n :results silent
(with-eval-after-load 'browse-url
(defun browse-url-mpv (url &optional _)
;; My hardware is too old to fix mpv with HomeBrew.
(start-process "mpv" nil "mpv" url))
(defconst browse-url-mpv-regexp
;; My hardware is too old to fix mpv with HomeBrew.
(rx bos "http" (opt "s") "://"
(or (seq "youtu.be/")
(seq "www.youtube.com/" (or "embed/" "watch?"))
(seq (+? nonl) (or ".mp4" ".webm") eos)))
"Match hyperlinks to open with mpv.")
(setopt
browse-url-generic-program (or (when (eq system-type 'darwin) "open")
(executable-find "firefox"))
browse-url-handlers `((,browse-url-mpv-regexp . browse-url-mpv)
("." . eww-browse-url))))
(defconst browse-url-eww-regexp
(rx bos "https://" (opt "www.")
(or "ascii-code.com/ASCII"
"cnrtl.fr"
"counterpunch.org"
"courses.cs.northwestern.edu/325"
"git.savannah.gnu.org/cgit/auctex.git"
"git.savannah.gnu.org/cgit/emacs.git"
"git.savannah.gnu.org/cgit/emacs/elpa.git"
"git.savannah.gnu.org/cgit/emacs/nongnu.git"
"git.savannah.gnu.org/cgit/emacs/org-mode.git"
"git.savannah.gnu.org/cgit/emms.git"
"list.orgmode.org"
"lists.gnu.org/archive/html/emacs-devel/"
"lists.gnu.org/archive/html/help-gnu-emacs/"
"masteringemacs.org"
"nrc.nl"
"orgmode.org/worg"
"planet.emacslife.com"
"sachachua.com/blog/category/emacs-news"
"woorden.org"))
"Match hyperlinks to open with eww.")
(setopt browse-url-handlers `((,browse-url-eww-regexp . eww-browse-url))))
#+end_src
*** [[https://en.wikipedia.org/wiki/Eww_(web_browser)][Emacs Web Wowser]]