summaryrefslogtreecommitdiffhomepage
path: root/custom/jao-custom-eww.el
diff options
context:
space:
mode:
Diffstat (limited to 'custom/jao-custom-eww.el')
-rw-r--r--custom/jao-custom-eww.el63
1 files changed, 16 insertions, 47 deletions
diff --git a/custom/jao-custom-eww.el b/custom/jao-custom-eww.el
index 1b766c9..221f442 100644
--- a/custom/jao-custom-eww.el
+++ b/custom/jao-custom-eww.el
@@ -1,5 +1,7 @@
;; -*- lexical-binding: t -*-
+(require 'jao-r2e)
+
;;; integration with browse-url and afio
(defun jao-eww-browse-url (url &rest _r)
"Browse URL using eww."
@@ -22,9 +24,10 @@
;;; multipart html renderer
(defun jao-shr-html-renderer (handle)
- (let ((fill-column nil)
- (shr-width 150)
- (shr-max-width 150))
+ (let* ((w (min 120 (- (window-width) 10)))
+ (fill-column nil)
+ (shr-width w)
+ (shr-max-width w))
(mm-shr handle)))
(setq mm-text-html-renderer #'jao-shr-html-renderer)
@@ -157,42 +160,19 @@
(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))
;;; auto-readable
(defvar jao-eww-auto-readable-urls
- (regexp-opt '("guardian.co.uk" "theguardian.com" "github.com" "eldiario.es")))
+ (regexp-opt '("guardian.co.uk"
+ "theguardian.com"
+ "github.com"
+ "eldiario.es")))
(defun jao-eww-autoread ()
(when (string-match-p jao-eww-auto-readable-urls (or (eww-current-url)))
(eww-readable)))
(add-hook 'eww-after-render-hook #'jao-eww-autoread)
+
;;; package
(use-package shr
:custom ((shr-width nil)
@@ -210,12 +190,7 @@ It should be the title of the web page as returned by `rdrview'"
(eww-download-directory jao-sink-dir)
(eww-header-line-format " %u")
(eww-form-checkbox-selected-symbol "☒")
- (eww-buffer-name-length 180)
- ;; (eww-readable-urls '("guardian\\.co\\.uk"
- ;; "theguardian\\.com"
- ;; "eldiario\\.es"
- ;; "theconversation"))
- )
+ (eww-buffer-name-length 180))
:config
(with-eval-after-load "org" (require 'ol-eww nil t))
@@ -226,12 +201,6 @@ It should be the title of the web page as returned by `rdrview'"
(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)
@@ -242,7 +211,7 @@ It should be the title of the web page as returned by `rdrview'"
("o" . jao-eww-browse)
("O" . jao-eww-browse-new)
("r" . jao-eww-reload)
- ("R" . jao-eww-readable)
+ ("R" . eww-readable)
("s" . eww-search-words)
("S" . jao-eww-browse-new)
("T" . jao-mastodon-toot-url)
@@ -250,7 +219,7 @@ It should be the title of the web page as returned by `rdrview'"
("U" . jao-eww-reopen-new)
("w" . jao-eww-to-org)
("q" . jao-eww-close)
- ("x" . jao-rss-subscribe)
+ ("x" . jao-r2e-subscribe)
("y" . jao-eww-copy-link)
("\\" . eww-view-source)
("C-c C-w" . jao-eww-close)
@@ -276,8 +245,8 @@ It should be the title of the web page as returned by `rdrview'"
(prog1 (apply fn args)
(when (and p (> (point) p)) (jao-shr--kill-nl p)))))
-(advice-add 'shr-tag-img :around #'jao-shr-tag-img)
-(advice-add 'shr-insert :around #'jao-shr-insert)
+;; (advice-add 'shr-tag-img :around #'jao-shr-tag-img)
+;; (advice-add 'shr-insert :around #'jao-shr-insert)
;; (advice-remove 'shr-tag-img #'jao-shr-tag-img)
;; (advice-remove 'shr-insert #'jao-shr-insert)