summary refs log tree commit diff stats
path: root/lisp/acdw-web.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/acdw-web.el')
-rw-r--r--lisp/acdw-web.el73
1 files changed, 72 insertions, 1 deletions
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 @@
2 2
3;;; Code: 3;;; Code:
4 4
5(require 'cl-lib)
6
5(defcustom +browse-url-other-safe-browser-functions nil 7(defcustom +browse-url-other-safe-browser-functions nil
6 "Other safe browser functions." 8 "Other safe browser functions."
7 :type '(repeat function)) 9 :type '(repeat function))
@@ -162,6 +164,25 @@ This function only tests URL's domain."
162 164
163;;; Packages 165;;; Packages
164 166
167(use-package eww
168 :config
169 (setopt eww-use-browse-url ".")
170 (add-hook 'eww-mode-hook
171 (defun eww-mode@setup ()
172 (add-hook 'visual-fill-column-mode-hook
173 (defun visual-fill-column@eww-reload ()
174 (eww-reload :local))))
175 nil :local)
176 (keymap-set eww-mode-map "&"
177 (defun eww-browse-url-external (&optional url)
178 (interactive nil eww-mode)
179 (condition-case e
180 (funcall
181 browse-url-secondary-browser-function
182 (or url (plist-get eww-data :url)))
183 (:success (when (null url) (quit-window))) ; Interactive use
184 (t (signal (car e) (cdr e)))))))
185
165(use-package browse-url 186(use-package browse-url
166 :demand t 187 :demand t
167 :config 188 :config
@@ -171,8 +192,9 @@ This function only tests URL's domain."
171 ;; Dispatch browser based on URL 192 ;; Dispatch browser based on URL
172 browse-url-handlers 193 browse-url-handlers
173 `(;; Videos 194 `(;; Videos
174 (,(+browse-url-matches "youtube\\.com" "yoiutu\\.be" 195 (,(+browse-url-matches "youtube\\.com" "youtu\\.be"
175 "invidious" "yewtu\\.be" 196 "invidious" "yewtu\\.be"
197 "twitch\\.tv"
176 (rx "." (or "mp4" "gif" "mov" "MOV" "webm") 198 (rx "." (or "mp4" "gif" "mov" "MOV" "webm")
177 eos)) 199 eos))
178 . +browse-url-with-mpv) 200 . +browse-url-with-mpv)
@@ -218,5 +240,54 @@ This function only tests URL's domain."
218 (setopt browse-url-chrome-program chrome 240 (setopt browse-url-chrome-program chrome
219 browse-url-generic-program chrome))) 241 browse-url-generic-program chrome)))
220 242
243(use-package browse-url-transform
244 :after browse-url
245 :load-path "~/src/emacs/browse-url-transform/"
246 :config
247 (setopt browse-url-transform-alist
248 `(;; Privacy-respecting alternatives
249 ("twitter\\.com" . "nitter.snopyta.org")
250 ("\\(?:\\(?:old\\.\\)?reddit\\.com\\)" . "libreddit.de")
251 ("medium\\.com" . "scribe.rip")
252 (".*substack\\.com.*" . ,substack-proxy)
253 ;; Text-mode of non-text-mode sites
254 ("www\\.npr\\.org" . "text.npr.org")
255 ;; Ask for raw versions of paste sites
256 ("^.*dpaste\\.com.*$" . "\\&.txt")
257 ("bpa\\.st/\\(.*\\)" . "bpa.st/raw/\\1")
258 ("\\(paste\\.debian\\.net\\)/\\(.*\\)" . "\\1/plain/\\2")
259 ("\\(pastebin\\.com\\)/\\\(.*\\)" . "\\1/raw/\\2")
260 ("\\(paste\\.centos\\.org/view\\)/\\(.*\\)" . "\\1/raw/\\2")))
261 (browse-url-transform-mode))
262
263;;; Link hint
264
265(use-package link-hint
266 :ensure t :demand t
267 :preface (keymap-global-unset "M-l")
268 :bind
269 (("M-l M-l" . +link-hint-open-link)
270 ("M-l l" . +link-hint-open-link)
271 ("M-l M-o" . +link-hint-open-secondary)
272 ("M-l o" . +link-hint-open-secondary)
273 ("M-l M-m" . +link-hint-open-multiple-links)
274 ("M-l m" . +link-hint-open-multiple-links)
275 ("M-l M-w" . link-hint-copy-link)
276 ("M-l w" . link-hint-copy-link)
277 ("M-l M-c" . +link-hint-open-chrome)
278 ("M-l c" . +link-hint-open-chrome))
279 :config
280 (require '+link-hint)
281 (setopt link-hint-avy-style 'at-full
282 link-hint-avy-all-windows t)
283 ;; For some reason, `link-hint-completion-list-candidate' freezes Emacs.
284 ;; Removing it fixes the problem, so ... that's what I've done. It's quite
285 ;; possible this problem isn't caused by `link-hint' at all, but rather by
286 ;; another package's configuration, but I don't care enough to fix it.
287 (setq link-hint-types
288 (delq 'link-hint-completion-list-candidate link-hint-types))
289 (+link-hint-open-secondary-setup)
290 (+link-hint-open-chrome-setup))
291
221(provide 'acdw-web) 292(provide 'acdw-web)
222;;; acdw-web.el ends here 293;;; acdw-web.el ends here