diff options
-rw-r--r-- | attic/misc.org | 12 | ||||
-rw-r--r-- | attic/w3m.org | 27 | ||||
-rw-r--r-- | lib/net/jao-notmuch.el | 40 | ||||
-rw-r--r-- | notmuch.org | 1 |
4 files changed, 43 insertions, 37 deletions
diff --git a/attic/misc.org b/attic/misc.org index 39b1cc8..3aac8c7 100644 --- a/attic/misc.org +++ b/attic/misc.org @@ -891,3 +891,15 @@ ("C-c B" . bookmark-set))) #+end_src +* notmuch + #+begin_src emacs-lisp + (defun jao-notmuch--show-hidden-html () + (when (save-excursion + (goto-char (point-min)) + (re-search-forward "^\\[ text/html (hidden) \\]" nil t)) + (jao-notmuch--toggle-mime))) + + (defun jao-notmuch-show-prefer-html () + (add-hook 'notmuch-show-hook #'jao-notmuch--show-hidden-html)) + + #+end_src diff --git a/attic/w3m.org b/attic/w3m.org index 6bfbaca..3689c8e 100644 --- a/attic/w3m.org +++ b/attic/w3m.org @@ -43,6 +43,33 @@ (require 'ol-w3m nil t) (define-key org-mode-map "\C-cW" 'jao-insert-w3m-link)) #+end_src +* notmuch integration + #+begin_src emacs-lisp + (defvar-local jao-notmuch--showing-images nil) + + (defun jao-notmuch--setup-w3m-images (&optional activate) + (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))))) + + (add-hook 'notmuch-show-mode-hook #'jao-notmuch--setup-w3m-images) + #+end_src * Capture page #+begin_src emacs-lisp (defun jao-w3m-capture-page () diff --git a/lib/net/jao-notmuch.el b/lib/net/jao-notmuch.el index fa33b37..8ff6053 100644 --- a/lib/net/jao-notmuch.el +++ b/lib/net/jao-notmuch.el @@ -167,15 +167,6 @@ (button-at (point))) (notmuch-show-toggle-part-invisibility)))) -(defun jao-notmuch--show-hidden-html () - (when (save-excursion - (goto-char (point-min)) - (re-search-forward "^\\[ text/html (hidden) \\]" nil t)) - (jao-notmuch--toggle-mime))) - -(defun jao-notmuch-show-prefer-html () - (add-hook 'notmuch-show-hook #'jao-notmuch--show-hidden-html)) - (defun jao-notmuch-toggle-mime-parts () (interactive) (when (jao-notmuch-goto-message-buffer nil t) @@ -183,45 +174,22 @@ (jao-notmuch--toggle-mime) (jao-notmuch-goto-tree-buffer t))) -(defvar-local jao-notmuch--showing-images nil) - -(defun jao-notmuch--setup-w3m-images (&optional activate) - (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-show-text/html-blocked-images nil) + (notmuch-multipart/alternative-discouraged '("text/plain"))) (notmuch-tree-show-message nil))) (defun jao-notmuch-show-images () (interactive) (if (eq mm-text-html-renderer 'w3m) - (jao-notmuch--w3m-toggle-images) + (when (fboundp 'jao-notmuch--w3m-toggle-images) + (jao-notmuch--w3m-toggle-images)) (jao-notmuch--shr-toggle-images))) -(add-hook 'notmuch-show-mode-hook #'jao-notmuch--setup-w3m-images) - ;;;; Keeping track of unread messages in current tree view diff --git a/notmuch.org b/notmuch.org index 381460f..ab5a740 100644 --- a/notmuch.org +++ b/notmuch.org @@ -378,7 +378,6 @@ :config (advice-add 'notmuch-clean-address :filter-args #'jao-mail-clean-address) - (jao-notmuch-show-prefer-html) :bind (:map notmuch-show-mode-map |