diff options
author | jao <jao@gnu.org> | 2022-08-16 22:52:55 +0100 |
---|---|---|
committer | jao <jao@gnu.org> | 2022-08-16 22:53:56 +0100 |
commit | 52bb6f2d832e6a2bfb851a1b53edee14c4049b3d (patch) | |
tree | 4e2519ef45a80175c0e81ef70b77143f58c75c7b /custom | |
parent | 48318f342bd8a6db7c1561c139982c658428cacd (diff) | |
download | elibs-52bb6f2d832e6a2bfb851a1b53edee14c4049b3d.tar.gz elibs-52bb6f2d832e6a2bfb851a1b53edee14c4049b3d.tar.bz2 |
w3m/notmuch: toggle images
Diffstat (limited to 'custom')
-rw-r--r-- | custom/jao-custom-w3m.el | 28 |
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))) |