summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWillForan <willforan@gmail.com>2025-11-15 21:50:35 -0500
committerWillForan <willforan@gmail.com>2025-11-15 21:50:35 -0500
commit4ea234a84d23b6d410c54e774aa3b890ebf06e75 (patch)
tree207bee2dc23ffb76d5630010591a7d07c0220203
parent4b5295ceba64a430c7984ec4aa163b343e3ed084 (diff)
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
-rw-r--r--emacstips.mdwn35
1 files changed, 22 insertions, 13 deletions
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 ")