summaryrefslogtreecommitdiffhomepage
path: root/custom
diff options
context:
space:
mode:
Diffstat (limited to 'custom')
-rw-r--r--custom/jao-custom-w3m.el28
1 files changed, 27 insertions, 1 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)))