]> git.cworth.org Git - notmuch/commitdiff
doc/emacs: add docstring and example for n-tree-result-format
authorDavid Bremner <david@tethera.net>
Sat, 16 Jul 2022 21:22:26 +0000 (17:22 -0400)
committerDavid Bremner <david@tethera.net>
Sat, 30 Jul 2022 11:53:07 +0000 (08:53 -0300)
This example is based on one originally by Jon Hurst.

doc/notmuch-emacs.rst

index 49111d2896881e5d207a48427d6444e991fc30ac..44dca384ec1de374c8f8a0565991eeede0611c7b 100644 (file)
@@ -253,6 +253,8 @@ variables.
                                            ("subject" . "%s ")
                                            ("tags" . "(%s)")))
 
+   See also :emacsvar:`notmuch-tree-result-format`.
+
 .. emacsvar:: notmuch-search-oldest-first
 
     Display the oldest threads at the top of the buffer
@@ -475,6 +477,39 @@ tags.
 As is the case with :ref:`notmuch-search`, the presentation of results
 can be controlled by the variable ``notmuch-search-oldest-first``.
 
+.. emacsvar:: notmuch-tree-result-format
+
+   |docstring::notmuch-tree-result-format|
+
+   The following example shows how to optionally display recipients instead
+   of authors for sent mail (assuming the user is named Mustermann).
+
+   .. code:: lisp
+
+      (defun -notmuch-authors-or-to (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 "Mustermann" author)
+                       (concat "To:" (notmuch-tree-clean-address to))
+                     author))
+           'face face)))
+
+      (setq notmuch-tree-result-format
+            '(("date" . "%12s  ")
+              (-notmuch-authors-or-to . "%-20.20s")
+              ((("tree" . "%s")
+                ("subject" . "%s"))
+               . " %-54s ")
+              ("tags" . "(%s)")))
+
+   See also :emacsvar:`notmuch-search-result-format`.
+
 .. _notmuch-unthreaded:
 
 notmuch-unthreaded