summaryrefslogtreecommitdiffhomepage
path: root/custom
diff options
context:
space:
mode:
Diffstat (limited to 'custom')
-rw-r--r--custom/jao-custom-eww.el44
1 files changed, 39 insertions, 5 deletions
diff --git a/custom/jao-custom-eww.el b/custom/jao-custom-eww.el
index 81dcd6e..6aeeada 100644
--- a/custom/jao-custom-eww.el
+++ b/custom/jao-custom-eww.el
@@ -50,11 +50,11 @@
(jao-eww-browse t))
(defun jao-eww-reload (images)
- (interactive "P" eww-mode)
- (if images
- (let ((shr-blocked-images nil))
- (eww-reload t))
- (call-interactively 'eww-reload)))
+ (interactive "P" eww-mode)
+ (if images
+ (let ((shr-blocked-images nil))
+ (eww-reload t))
+ (call-interactively 'eww-reload)))
;;; consult narrowing
(with-eval-after-load "consult"
@@ -156,6 +156,33 @@
(pop-to-buffer buff)
(goto-char (point-min))))
+;;; rdrview
+;; https://jiewawa.me/2024/04/another-way-of-integrating-mozilla-readability-in-emacs-eww/
+(define-minor-mode eww-rdrview-mode
+ "Toggle whether to use `rdrview' to make eww buffers more readable."
+ :lighter " R"
+ (if eww-rdrview-mode
+ (progn
+ (setq eww-retrieve-command '("rdrview" "-T" "title,sitename,body" "-H"))
+ (add-hook 'eww-after-render-hook #'eww-rdrview-update-title))
+ (progn
+ (setq eww-retrieve-command nil)
+ (remove-hook 'eww-after-render-hook #'eww-rdrview-update-title))))
+
+(defun eww-rdrview-update-title ()
+ "Change title key in `eww-data' with first line of buffer.
+It should be the title of the web page as returned by `rdrview'"
+ (save-excursion
+ (goto-char (point-min))
+ (plist-put eww-data :title (string-trim (thing-at-point 'line t))))
+ (eww--after-page-change))
+
+(defun eww-rdrview-toggle-and-reload ()
+ "Toggle `eww-rdrview-mode' and reload page in current eww buffer."
+ (interactive)
+ (if eww-rdrview-mode (eww-rdrview-mode -1)
+ (eww-rdrview-mode 1))
+ (eww-reload))
;;; package
(use-package shr
:custom ((shr-width nil)
@@ -188,6 +215,12 @@
(when (not (string-blank-p s)) (format "%s" s))))
(setq eww-auto-rename-buffer #'jao-eww-buffer-name)
+ (defun jao-eww-readable (rdrview)
+ (interactive "P" eww-mode)
+ (if rdrview
+ (eww-rdrview-toggle-and-reload)
+ (eww-readable)))
+
:bind (:map eww-mode-map (("b" . eww-back-url)
("B" . eww-forward-url)
("d" . jao-download)
@@ -198,6 +231,7 @@
("o" . jao-eww-browse)
("O" . jao-eww-browse-new)
("r" . jao-eww-reload)
+ ("R" . jao-eww-readable)
("s" . eww-search-words)
("S" . jao-eww-browse-new)
("T" . jao-mastodon-toot-url)