summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--custom/jao-custom-w3m.el28
-rw-r--r--lib/net/jao-notmuch.el6
2 files changed, 30 insertions, 4 deletions
diff --git a/custom/jao-custom-w3m.el b/custom/jao-custom-w3m.el
index 51272ca..0ccd37c 100644
--- a/custom/jao-custom-w3m.el
+++ b/custom/jao-custom-w3m.el
@@ -26,7 +26,8 @@
(defun jao-w3m-html-renderer (handle)
(let ((w3m-message-silent t)
(w3m-fill-column 120)
- (mm-w3m-safe-url-regexp nil))
+ (mm-w3m-safe-url-regexp nil)
+ (mm-inline-text-html-with-w3m-keymap t))
(condition-case e
(mm-inline-text-html-render-with-w3m handle)
(error (message "Error rendering page with w3m: %s" e)
@@ -36,6 +37,31 @@
(setq mm-text-html-renderer 'jao-w3m-html-renderer)
+;;; notmuch integration
+(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))))
+
+(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)))))
+
+(add-hook 'notmuch-show-mode-hook #'jao-notmuch--setup-w3m-images)
+
;;; org integration
(defun jao-w3m-get-link ()
(let ((wb (w3m-alive-p)))
diff --git a/lib/net/jao-notmuch.el b/lib/net/jao-notmuch.el
index edffade..f2e87fc 100644
--- a/lib/net/jao-notmuch.el
+++ b/lib/net/jao-notmuch.el
@@ -207,9 +207,9 @@
(defun jao-notmuch-toggle-images ()
(interactive)
- (cond ((eq mm-text-html-renderer 'w3m)
- (when (fboundp 'jao-notmuch--w3m-toggle-images)
- (jao-notmuch--w3m-toggle-images)))
+ (cond ((memq mm-text-html-renderer '(w3m jao-w3m-html-renderer))
+ (when (fboundp 'jao-notmuch--w3m-toggle-images)
+ (jao-notmuch--w3m-toggle-images)))
(window-system (jao-notmuch--shr-toggle-images))
(notmuch-tree-message-buffer
(if nil ;;(fboundp 'jao-open-in-x-frame)