diff options
-rw-r--r-- | lib/net/jao-notmuch.el | 52 | ||||
-rw-r--r-- | notmuch.org | 25 |
2 files changed, 46 insertions, 31 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) diff --git a/notmuch.org b/notmuch.org index 81b2270..9a87a08 100644 --- a/notmuch.org +++ b/notmuch.org @@ -71,9 +71,11 @@ (jao-notmuch--sec (jao-notmuch--qn (or d0 "feeds") (or d1 tag) k (list (concat "tag:" tag))))) - (defvar jao-notmuch--feeds - '("clojure" "elixir" "erlang" "gnus" "haskell" "idris" - "lobsters" "mailutils" "notmuch" "papers" "scheme" "xmobar")) + (defun jao-notmuch--feed-tags (w) + (let* ((cmd (concat "notmuch search --output=tags tag:" w)) + (ts (split-string (shell-command-to-string cmd)))) + (seq-difference ts '("new" "unread" "flagged" "signed" "attachment" + "feeds" "rss" "mce" "trove" "prog" "emacs")))) (setq notmuch-saved-searches `(,(jao-notmuch--q "bigml" "inbox" "bi") @@ -87,13 +89,14 @@ ,(jao-notmuch--sq "emacs-devel" "ed" "emacs" "devel") ,(jao-notmuch--sq "emacs-bugs" "eb" "emacs" "bugs") ,(jao-notmuch--sq "emacs-diffs" "ec" "emacs" "diffs") - ,@(mapcar #'jao-notmuch--sq jao-notmuch--feeds) + ,@(mapcar #'jao-notmuch--sq (jao-notmuch--feed-tags "feeds")) + ,@(mapcar #'jao-notmuch--sq '("scheme" "notmuch" "erlang")) ,(jao-notmuch--sec (jao-notmuch--qn "feeds" "prog" "fp" - '("tag:prog" - "not tag:\"/(lobsters|clojure|erlang|xmobar|gmane)/\""))) - ,@(mapcar #'jao-notmuch--sec - (jao-notmuch--mboxes-search "feeds" "emacs" "prog")))) + (cons "tag:prog" + (mapcar (lambda (tag) + (format "not tag:%s" tag)) + (jao-notmuch--feed-tags "feeds"))))))) (defvar jao-notmuch-dynamic-searches `(,(jao-notmuch--q "jao" "draft" "d" '("tag:draft")) @@ -369,7 +372,7 @@ (let ((fg (face-attribute 'jao-themes-dimm :foreground))) (dolist (f '(notmuch-tree-match-tree-face notmuch-tree-no-match-tree-face)) - (set-face-attribute f nil :family "Fira Code" :foreground fg))) + (set-face-attribute f nil :family "Source Code Pro" :foreground fg))) (jao-notmuch-tree-setup "T") @@ -504,6 +507,10 @@ (org-capture nil "X")))) #+end_src +* html render + #+begin_src emacs-lisp + (when jao-notmuch-enabled-p (setq mm-text-html-renderer 'shr)) + #+end_src * consult #+begin_src emacs-lisp (jao-load-path "consult-notmuch") |