From: WillForan Date: Sun, 16 Nov 2025 02:50:35 +0000 (-0500) Subject: emacstips: my/notmuch-unthreaded-show-recipient-if-sent X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=4ea234a84d23b6d410c54e774aa3b890ebf06e75;p=notmuch-wiki emacstips: my/notmuch-unthreaded-show-recipient-if-sent * use `user-mail-address` which hopefully already stores the email address to check against * if-is-author extra else component (duplicated true line?) removed * add note `notmuch-tree-clean-address` doesn't work well on To: * add doc string --- diff --git a/emacstips.mdwn b/emacstips.mdwn index 288690c..6400444 100644 --- a/emacstips.mdwn +++ b/emacstips.mdwn @@ -994,19 +994,28 @@ arbitrary address, whatever@mail.address.com in the example) is included in the From field. (defun my/notmuch-unthreaded-show-recipient-if-sent (format-string result) - (let* ((headers (plist-get result :headers)) - (to (plist-get headers :To)) - (author (plist-get headers :From)) - (face (if (plist-get result :match) - 'notmuch-tree-match-author-face - 'notmuch-tree-no-match-author-face))) - (propertize - (format format-string - (if (string-match "whatever@mail.address.com" author) - (concat "↦ " (notmuch-tree-clean-address to)) - (notmuch-tree-clean-address to) - author)) - 'face face))) + "Custom function for `notmuch-unthreaded-result-format' to use instead of \"authors\". + Show \"From:\" address from RESULT, unless we sent the message. Then show \"To:\". + Formatted with FORMAT-STRING. + Example on wiki https://notmuchmail.org/emacstips/" + + (let* ((headers (plist-get result :headers)) + (to (plist-get headers :To)) + (author (plist-get headers :From)) + ;; NOTE: `user-mail-address` has to be set correctly + (is-me? (string-match user-mail-address author)) + (face (if (plist-get result :match) + 'notmuch-tree-match-author-face + 'notmuch-tree-no-match-author-face))) + (propertize + (format format-string + (if is-me? + ;; NOTE: "To:" may have more than one address. + ;; `notmuch-tree-clean-address` will pull + ;; all but the last address combined as name + (concat "↪" (notmuch-tree-clean-address to)) + (notmuch-tree-clean-address author))) + 'face face))) (setq notmuch-unthreaded-result-format '(("date" . "%12s ")