From 71b97e7871ed5eed8e03202daaf8124c3a2b7e1e Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Fri, 20 Jan 2023 13:14:49 -0600 Subject: Add link-hint --- lisp/acdw-web.el | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 72 insertions(+), 1 deletion(-) (limited to 'lisp/acdw-web.el') diff --git a/lisp/acdw-web.el b/lisp/acdw-web.el index 28fcd02..36a5ba4 100644 --- a/lisp/acdw-web.el +++ b/lisp/acdw-web.el @@ -2,6 +2,8 @@ ;;; Code: +(require 'cl-lib) + (defcustom +browse-url-other-safe-browser-functions nil "Other safe browser functions." :type '(repeat function)) @@ -162,6 +164,25 @@ This function only tests URL's domain." ;;; Packages +(use-package eww + :config + (setopt eww-use-browse-url ".") + (add-hook 'eww-mode-hook + (defun eww-mode@setup () + (add-hook 'visual-fill-column-mode-hook + (defun visual-fill-column@eww-reload () + (eww-reload :local)))) + nil :local) + (keymap-set eww-mode-map "&" + (defun eww-browse-url-external (&optional url) + (interactive nil eww-mode) + (condition-case e + (funcall + browse-url-secondary-browser-function + (or url (plist-get eww-data :url))) + (:success (when (null url) (quit-window))) ; Interactive use + (t (signal (car e) (cdr e))))))) + (use-package browse-url :demand t :config @@ -171,8 +192,9 @@ This function only tests URL's domain." ;; Dispatch browser based on URL browse-url-handlers `(;; Videos - (,(+browse-url-matches "youtube\\.com" "yoiutu\\.be" + (,(+browse-url-matches "youtube\\.com" "youtu\\.be" "invidious" "yewtu\\.be" + "twitch\\.tv" (rx "." (or "mp4" "gif" "mov" "MOV" "webm") eos)) . +browse-url-with-mpv) @@ -218,5 +240,54 @@ This function only tests URL's domain." (setopt browse-url-chrome-program chrome browse-url-generic-program chrome))) +(use-package browse-url-transform + :after browse-url + :load-path "~/src/emacs/browse-url-transform/" + :config + (setopt browse-url-transform-alist + `(;; Privacy-respecting alternatives + ("twitter\\.com" . "nitter.snopyta.org") + ("\\(?:\\(?:old\\.\\)?reddit\\.com\\)" . "libreddit.de") + ("medium\\.com" . "scribe.rip") + (".*substack\\.com.*" . ,substack-proxy) + ;; Text-mode of non-text-mode sites + ("www\\.npr\\.org" . "text.npr.org") + ;; Ask for raw versions of paste sites + ("^.*dpaste\\.com.*$" . "\\&.txt") + ("bpa\\.st/\\(.*\\)" . "bpa.st/raw/\\1") + ("\\(paste\\.debian\\.net\\)/\\(.*\\)" . "\\1/plain/\\2") + ("\\(pastebin\\.com\\)/\\\(.*\\)" . "\\1/raw/\\2") + ("\\(paste\\.centos\\.org/view\\)/\\(.*\\)" . "\\1/raw/\\2"))) + (browse-url-transform-mode)) + +;;; Link hint + +(use-package link-hint + :ensure t :demand t + :preface (keymap-global-unset "M-l") + :bind + (("M-l M-l" . +link-hint-open-link) + ("M-l l" . +link-hint-open-link) + ("M-l M-o" . +link-hint-open-secondary) + ("M-l o" . +link-hint-open-secondary) + ("M-l M-m" . +link-hint-open-multiple-links) + ("M-l m" . +link-hint-open-multiple-links) + ("M-l M-w" . link-hint-copy-link) + ("M-l w" . link-hint-copy-link) + ("M-l M-c" . +link-hint-open-chrome) + ("M-l c" . +link-hint-open-chrome)) + :config + (require '+link-hint) + (setopt link-hint-avy-style 'at-full + link-hint-avy-all-windows t) + ;; For some reason, `link-hint-completion-list-candidate' freezes Emacs. + ;; Removing it fixes the problem, so ... that's what I've done. It's quite + ;; possible this problem isn't caused by `link-hint' at all, but rather by + ;; another package's configuration, but I don't care enough to fix it. + (setq link-hint-types + (delq 'link-hint-completion-list-candidate link-hint-types)) + (+link-hint-open-secondary-setup) + (+link-hint-open-chrome-setup)) + (provide 'acdw-web) ;;; acdw-web.el ends here -- cgit 1.4.1-21-gabe81