about 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.el30
1 files changed, 23 insertions, 7 deletions
diff --git a/lisp/acdw-web.el b/lisp/acdw-web.el index 40e1a3d..3b78e4d 100644 --- a/lisp/acdw-web.el +++ b/lisp/acdw-web.el
@@ -30,6 +30,7 @@ This is a good function to use in key positions in `browse-url-handlers'."
30 (cl-loop for regexp in ',regexps 30 (cl-loop for regexp in ',regexps
31 if (string-match-p regexp url) 31 if (string-match-p regexp url)
32 return regexp))) 32 return regexp)))
33
33;;; External URL handlers 34;;; External URL handlers
34 35
35(cl-defmacro +browse-url-make-external-viewer-handler 36(cl-defmacro +browse-url-make-external-viewer-handler
@@ -93,9 +94,8 @@ for some reason."
93 "--cache-pause-initial=yes") 94 "--cache-pause-initial=yes")
94 :prompt "Video URL: ") 95 :prompt "Video URL: ")
95 96
96(+browse-url-make-external-viewer-handler mpv-image 97(+browse-url-make-external-viewer-handler miv
97 :program (executable-find "mpv") 98 :program (executable-find "miv")
98 :args '("--image-display-duration=inf")
99 :prompt "Image URL: ") 99 :prompt "Image URL: ")
100 100
101;;; External domains 101;;; External domains
@@ -187,6 +187,17 @@ This function will also save `custom-file' with the updated value."
187 (message "Saved %s" file) 187 (message "Saved %s" file)
188 file))) 188 file)))
189 189
190;;; Unfucking the internet
191
192(defun eww-archiveis-url (url)
193 "Run URL through archive.is and browse the result."
194 (interactive (list (plist-get eww-data :url)))
195 (letrec ((nonce (lambda ()
196 (unwind-protect (eww-readable)
197 (remove-hook 'eww-after-render-hook nonce)))))
198 (add-hook 'eww-after-render-hook nonce)
199 (eww (format "https://archive.is/submit/?url=%s" url))))
200
190 201
191;;; Packages 202;;; Packages
192 203
@@ -240,7 +251,8 @@ This function will also save `custom-file' with the updated value."
240 (define-key eww-mode-map "b" #'bookmark-set) 251 (define-key eww-mode-map "b" #'bookmark-set)
241 (define-key eww-mode-map "B" #'bookmark-jump) 252 (define-key eww-mode-map "B" #'bookmark-jump)
242 (define-key eww-mode-map (kbd "M-n") nil) 253 (define-key eww-mode-map (kbd "M-n") nil)
243 (define-key eww-mode-map (kbd "M-p") nil)) 254 (define-key eww-mode-map (kbd "M-p") nil)
255 (define-key eww-mode-map (kbd "*") #'eww-archiveis-url))
244 256
245(use-package browse-url 257(use-package browse-url
246 :demand t 258 :demand t
@@ -248,6 +260,9 @@ This function will also save `custom-file' with the updated value."
248 (put 'browse-url-browser-function 'safe-local-variable 260 (put 'browse-url-browser-function 'safe-local-variable
249 '+browse-url-browser-function-safe-p) 261 '+browse-url-browser-function-safe-p)
250 (setopt browse-url-browser-function #'eww-browse-url 262 (setopt browse-url-browser-function #'eww-browse-url
263 browse-url-secondary-browser-function #'browse-url-firefox
264 browse-url-firefox-program (executable-find "firefox")
265 browse-url-firefox-arguments '("--new-tab")
251 ;; Dispatch browser based on URL 266 ;; Dispatch browser based on URL
252 browse-url-handlers 267 browse-url-handlers
253 `(;; Videos 268 `(;; Videos
@@ -266,7 +281,7 @@ This function will also save `custom-file' with the updated value."
266 (rx "." (or "jpeg" "jpg" "png" "pn" 281 (rx "." (or "jpeg" "jpg" "png" "pn"
267 "bmp" "webp") 282 "bmp" "webp")
268 eos)) 283 eos))
269 . +browse-url-with-mpv-image) 284 . +browse-url-with-miv)
270 ;; Blobs 285 ;; Blobs
271 (,(+browse-url-matches (rx "." (or ".tar.gz" ".pdf") eos)) 286 (,(+browse-url-matches (rx "." (or ".tar.gz" ".pdf") eos))
272 . +browse-url-download) 287 . +browse-url-download)
@@ -294,7 +309,8 @@ This function will also save `custom-file' with the updated value."
294 browse-url-firefox-arguments '("--new-tab") 309 browse-url-firefox-arguments '("--new-tab")
295 browse-url-generic-program firefox 310 browse-url-generic-program firefox
296 browse-url-generic-args browse-url-firefox-arguments)) 311 browse-url-generic-args browse-url-firefox-arguments))
297 (when-let ((chromium (choose-executable "chromium"))) 312 (when-let ((chromium (choose-executable "chromium"
313 "chromium-browser")))
298 (setopt browse-url-chromium-program chromium 314 (setopt browse-url-chromium-program chromium
299 browse-url-generic-program chromium)) 315 browse-url-generic-program chromium))
300 (when-let ((chrome (choose-executable "chrome" 316 (when-let ((chrome (choose-executable "chrome"
@@ -304,7 +320,7 @@ This function will also save `custom-file' with the updated value."
304 320
305(use-package browse-url-transform 321(use-package browse-url-transform
306 :after browse-url 322 :after browse-url
307 :load-path "~/src/emacs/browse-url-transform/" 323 :load-path "~/src/browse-url-transform.el/"
308 :config 324 :config
309 (setopt browse-url-transform-alist 325 (setopt browse-url-transform-alist
310 `(;; Privacy-respecting alternatives 326 `(;; Privacy-respecting alternatives