summaryrefslogtreecommitdiff
path: root/eww-conf.el
diff options
context:
space:
mode:
Diffstat (limited to 'eww-conf.el')
-rw-r--r--eww-conf.el34
1 files changed, 32 insertions, 2 deletions
diff --git a/eww-conf.el b/eww-conf.el
index 3faa82d..1f6ff46 100644
--- a/eww-conf.el
+++ b/eww-conf.el
@@ -396,11 +396,34 @@ For the meanings of NAME and DIR, see the documentation of
;;; Bookmark integration
-;; This section defines functions to make bookmarks for EWW buffers
-;; and to jump to those bookmarks.
+;;;; Readbable mode distinction
+
+;; This section modifies the behaviour of `eww-readable' so that when
+;; we are viewing readable parts of the webpage, there is a variable
+;; saying so.
+
+(defvar durand-eww-readable-p nil
+ "If non-nil, we are viewing the readable parts of a webpage.")
+
+(make-variable-buffer-local 'durand-eww-readable-p)
+
+(defun eww-non-readable-h ()
+ "Set `durand-eww-readable-p' to nil."
+ (setq-local durand-eww-readable-p nil))
+
+(defun eww-readable-h ()
+ "Set `durand-eww-readable-p' to t."
+ (setq-local durand-eww-readable-p t))
+
+(add-hook 'eww-after-render-hook #'eww-non-readable-h)
+
+(advice-add #'eww-readable :after #'eww-readable-h)
;;;; Making records
+;; This section defines functions to make bookmarks for EWW buffers
+;; and to jump to those bookmarks.
+
(defun durand-eww-bookmark-make-record ()
"Return a bookmark record for the current page."
(cond
@@ -409,6 +432,7 @@ For the meanings of NAME and DIR, see the documentation of
(let* ((url (plist-get eww-data :url))
(title (format "(EWW) %s" (plist-get eww-data :title)))
(position (point))
+ (readablep durand-eww-readable-p)
(defaults (delq nil (list 'defaults title url))))
(cond
((null url) (user-error "No link for the current page")))
@@ -417,6 +441,7 @@ For the meanings of NAME and DIR, see the documentation of
title
(cons 'location url)
(cons 'handler #'durand-eww-bookmark-jump)
+ (cons 'readablep readablep)
defaults)
(bookmark-make-record-default 'no-file nil position))))
@@ -526,6 +551,11 @@ Otherwise, fetch URL and afterwards try to restore the point."
(lambda ()
(remove-hook
'eww-after-render-hook function-symbol)
+ ;; if the bookmark records a readable webpage,
+ ;; enter readable mode again.
+ (cond
+ ((bookmark-prop-get bookmark 'readablep)
+ (eww-readable)))
(bookmark-default-handler
(list
"" (cons 'buffer buffer)