summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2021-12-09 16:02:06 +0800
committerJSDurand <mmemmew@gmail.com>2021-12-09 16:02:06 +0800
commit8416e814e4426aa688af8be7d4be3150be33ea66 (patch)
tree95073f1269533f3aae0e46c6cba91ab69f94dfdc
parent5aae910f1061dc279ff15ca5843b8e05f31de753 (diff)
eww-conf: record the readability status as well
* eww-conf.el (durand-eww-readable-p): a variable that records if the current buffer is in the readable mode. (eww-non-readable-h, eww-readable-h): set the buffer to the correct readable mode. (eww-after-render-hook): add a hook to set the buffer to non-readable mode. (#'eww-readable): add an advice to set the buffer to readable mode. (durand-eww-bookmark-make-record): record the readability status of the buffer. (durand-eww-bookmark-jump): if the bookmark records a readable buffer, enter readable mode when opening it. * org-conf.el (durand-org-publish-sitemap): fix a small typo
-rw-r--r--eww-conf.el34
-rw-r--r--org-conf.el4
2 files changed, 34 insertions, 4 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)
diff --git a/org-conf.el b/org-conf.el
index f964d3c..cec2d41 100644
--- a/org-conf.el
+++ b/org-conf.el
@@ -736,8 +736,8 @@ TITLE is the title of the sitemap.
REP is a representation of the files and directories in the
project. Use such functions as `org-list-to-org' or
`org-list-to-subtree' to transform it."
- (format "#+TITLE: %s\n#+AUTHOR: JSDurand\n%s#+DATE: <%s>\n\n%s\n\n\
-#+ATTR_HTML: :border nil :rules nil :frame nil\n\
+ (format "#+TITLE: %s\n#+AUTHOR: JSDurand\n%s\n#+DATE: <%s>\n\n%s\n\
+\n#+ATTR_HTML: :border nil :rules nil :frame nil\n\
%s\n\n\
[[https://jsdurand.xyz/%s][Web feed]]"
title