From 989171268461a0069ecd53a49e6098ce08638102 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Fri, 5 May 2023 09:58:21 -0500 Subject: changes --- lisp/acdw-web.el | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'lisp/acdw-web.el') 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'." (cl-loop for regexp in ',regexps if (string-match-p regexp url) return regexp))) + ;;; External URL handlers (cl-defmacro +browse-url-make-external-viewer-handler @@ -93,9 +94,8 @@ for some reason." "--cache-pause-initial=yes") :prompt "Video URL: ") -(+browse-url-make-external-viewer-handler mpv-image - :program (executable-find "mpv") - :args '("--image-display-duration=inf") +(+browse-url-make-external-viewer-handler miv + :program (executable-find "miv") :prompt "Image URL: ") ;;; External domains @@ -187,6 +187,17 @@ This function will also save `custom-file' with the updated value." (message "Saved %s" file) file))) +;;; Unfucking the internet + +(defun eww-archiveis-url (url) + "Run URL through archive.is and browse the result." + (interactive (list (plist-get eww-data :url))) + (letrec ((nonce (lambda () + (unwind-protect (eww-readable) + (remove-hook 'eww-after-render-hook nonce))))) + (add-hook 'eww-after-render-hook nonce) + (eww (format "https://archive.is/submit/?url=%s" url)))) + ;;; Packages @@ -240,7 +251,8 @@ This function will also save `custom-file' with the updated value." (define-key eww-mode-map "b" #'bookmark-set) (define-key eww-mode-map "B" #'bookmark-jump) (define-key eww-mode-map (kbd "M-n") nil) - (define-key eww-mode-map (kbd "M-p") nil)) + (define-key eww-mode-map (kbd "M-p") nil) + (define-key eww-mode-map (kbd "*") #'eww-archiveis-url)) (use-package browse-url :demand t @@ -248,6 +260,9 @@ This function will also save `custom-file' with the updated value." (put 'browse-url-browser-function 'safe-local-variable '+browse-url-browser-function-safe-p) (setopt browse-url-browser-function #'eww-browse-url + browse-url-secondary-browser-function #'browse-url-firefox + browse-url-firefox-program (executable-find "firefox") + browse-url-firefox-arguments '("--new-tab") ;; Dispatch browser based on URL browse-url-handlers `(;; Videos @@ -266,7 +281,7 @@ This function will also save `custom-file' with the updated value." (rx "." (or "jpeg" "jpg" "png" "pn" "bmp" "webp") eos)) - . +browse-url-with-mpv-image) + . +browse-url-with-miv) ;; Blobs (,(+browse-url-matches (rx "." (or ".tar.gz" ".pdf") eos)) . +browse-url-download) @@ -294,7 +309,8 @@ This function will also save `custom-file' with the updated value." browse-url-firefox-arguments '("--new-tab") browse-url-generic-program firefox browse-url-generic-args browse-url-firefox-arguments)) - (when-let ((chromium (choose-executable "chromium"))) + (when-let ((chromium (choose-executable "chromium" + "chromium-browser"))) (setopt browse-url-chromium-program chromium browse-url-generic-program chromium)) (when-let ((chrome (choose-executable "chrome" @@ -304,7 +320,7 @@ This function will also save `custom-file' with the updated value." (use-package browse-url-transform :after browse-url - :load-path "~/src/emacs/browse-url-transform/" + :load-path "~/src/browse-url-transform.el/" :config (setopt browse-url-transform-alist `(;; Privacy-respecting alternatives -- cgit 1.4.1-21-gabe81