summaryrefslogtreecommitdiffhomepage
path: root/lib/net
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-12-31 13:15:40 +0000
committerjao <jao@gnu.org>2021-12-31 13:16:36 +0000
commitfb3a9c806f4e76059094d333dfb57f7026abec77 (patch)
treed00ffe706935260840a73b4149b6ca170aab52f9 /lib/net
parent67a451d13145fcb99039d35474957fb12f237a64 (diff)
downloadelibs-fb3a9c806f4e76059094d333dfb57f7026abec77.tar.gz
elibs-fb3a9c806f4e76059094d333dfb57f7026abec77.tar.bz2
otmuch nits and better eww image activation
Diffstat (limited to 'lib/net')
-rw-r--r--lib/net/jao-notmuch.el52
1 files changed, 30 insertions, 22 deletions
diff --git a/lib/net/jao-notmuch.el b/lib/net/jao-notmuch.el
index fd5df2c..320dac7 100644
--- a/lib/net/jao-notmuch.el
+++ b/lib/net/jao-notmuch.el
@@ -189,31 +189,39 @@
(defvar-local jao-notmuch--showing-images nil)
(defun jao-notmuch--setup-w3m-images (&optional activate)
- (setq-local w3m-ignored-image-url-regexp
- (unless jao-notmuch--showing-images
- notmuch-show-text/html-blocked-images))
- (when activate
- (setq-local scroll-margin 0)
- (w3m-toggle-inline-images (if jao-notmuch--showing-images t 'turnoff))))
+ (when (eq mm-text-html-renderer 'w3m)
+ (setq-local w3m-ignored-image-url-regexp
+ (unless jao-notmuch--showing-images
+ notmuch-show-text/html-blocked-images))
+ (when activate
+ (setq-local scroll-margin 0)
+ (w3m-toggle-inline-images (if jao-notmuch--showing-images t 'turnoff)))))
+
+(defun jao-notmuch--w3m-toggle-images ()
+ (save-window-excursion
+ (when (or (derived-mode-p 'notmuch-show-mode)
+ (jao-notmuch-goto-message-buffer nil t))
+ (goto-char (point-min))
+ (when (re-search-forward "^\\[ text/html " nil t)
+ (when (looking-at-p "(hidden)")
+ (notmuch-show-toggle-part-invisibility))
+ (forward-line 1)
+ (setq jao-notmuch--showing-images (not jao-notmuch--showing-images))
+ (jao-notmuch--setup-w3m-images t)))))
+
+(defun jao-notmuch--shr-toggle-images ()
+ (notmuch-tree-close-message-window)
+ (let ((mm-text-html-renderer 'shr)
+ (shr-blocked-images nil)
+ (shr-inhibit-images nil)
+ (notmuch-show-text/html-blocked-images nil))
+ (notmuch-tree-show-message nil)))
(defun jao-notmuch-show-images ()
(interactive)
- (if (eq mm-text-html-renderer 'shr)
- (let ((shr-blocked-images nil)
- (shr-inhibit-images nil)
- (notmuch-show-text/html-blocked-images nil))
- (notmuch-tree-close-message-window)
- (notmuch-tree-show-message nil))
- (save-window-excursion
- (when (or (derived-mode-p 'notmuch-show-mode)
- (jao-notmuch-goto-message-buffer nil t))
- (goto-char (point-min))
- (when (re-search-forward "^\\[ text/html " nil t)
- (when (looking-at-p "(hidden)")
- (notmuch-show-toggle-part-invisibility))
- (forward-line 1)
- (setq jao-notmuch--showing-images (not jao-notmuch--showing-images))
- (jao-notmuch--setup-w3m-images t))))))
+ (if (eq mm-text-html-renderer 'w3m)
+ (jao-notmuch--w3m-toggle-images)
+ (jao-notmuch--shr-toggle-images)))
(add-hook 'notmuch-show-mode-hook #'jao-notmuch--setup-w3m-images)