From 71290eea7350ddbc57f9ae0813dae6233d45b4d1 Mon Sep 17 00:00:00 2001 From: jao Date: Wed, 1 Sep 2021 02:04:32 +0100 Subject: notmuch: using the latest jao-notmuch thingies --- notmuch.org | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/notmuch.org b/notmuch.org index a0af9b5..3494938 100644 --- a/notmuch.org +++ b/notmuch.org @@ -295,20 +295,43 @@ * tree #+begin_src emacs-lisp (use-package notmuch-tree + :init + + (defun jao-notmuch--truncate (x) + (truncate-string-to-width (format "%-102s" x) 102 nil nil t)) + + (defun jao-notmuch--msg-ticks (msg) + (let ((headers (plist-get msg :headers))) + (cond ((string-match-p jao-mails-regexp (or (plist-get headers :To) "")) + (propertize " »" 'face 'notmuch-tree-match-tree-face)) + ((string-match-p jao-mails-regexp (or (plist-get headers :Cc) "")) + (propertize " ¬" 'face 'notmuch-tree-match-tree-face)) + (t " ")))) + + (defun jao-notmuch--tree-subject (msg) + (thread-first '(("tree" . " %s") ("subject" . " %s")) + (notmuch-tree-format-field-list msg) + (jao-notmuch--truncate))) + + (setq notmuch-tree-result-format + '(("date" . "%12s ") + ("authors" . "%-35s") + (jao-notmuch--msg-ticks) + (jao-notmuch--tree-subject) + ("tags" . " (%s)")) + notmuch-unthreaded-result-format notmuch-tree-result-format + notmuch-tree-thread-symbols + '((prefix . "─") (top . "─") (top-tee . "┬") + (vertical . "│") (vertical-tee . "├") (bottom . "╰") + (arrow . ""))) + :config + (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))) - (defun jao-notmuch--format-field (fun field fmt msg) - (let ((rs (funcall fun field fmt msg))) - (cond ((and (stringp field) (string= field "tree")) - (replace-regexp-in-string "►" "" rs)) ;; "→" - (t (truncate-string-to-width rs 102 nil nil t))))) - - (advice-add 'notmuch-tree-format-field :around #'jao-notmuch--format-field) - (jao-notmuch-tree-setup "T") :bind (:map notmuch-tree-mode-map -- cgit v1.2.3