]> git.notmuchmail.org Git - notmuch/commit - emacs/notmuch.el
emacs: Allow functions in notmuch-search-result-format
authorDavid Edmondson <dme@dme.org>
Sun, 21 Feb 2021 15:19:01 +0000 (15:19 +0000)
committerDavid Bremner <david@tethera.net>
Thu, 9 Sep 2021 01:59:48 +0000 (22:59 -0300)
commit4f4ec48df25c8d2963e7124d2781b13e5a7f6a78
tree0e56b5d9ab78e7add0ced059f94e9936fa2ed0a3
parent071fb57a35fa330785f75c26734133732560414e
emacs: Allow functions in notmuch-search-result-format

If the car of an element in notmuch-search-result-format is a
function, insert the result of calling the function into the buffer.

This allows a user to generate custom fields in the output of a search
result. For example, with:

(defun -notmuch-result-flags (format-string result)
  (let ((tags-to-letters '(("flagged" . "!")
   ("unread" . "u")
   ("mine" . "m")
   ("sent" . "s")
   ("replied" . "r")))
(tags (plist-get result :tags)))

    (format format-string
    (mapconcat (lambda (t2l)
 (if (member (car t2l) tags)
     (cdr t2l)
   " "))
       tags-to-letters ""))))

(setq notmuch-search-result-format '((-notmuch-result-flags . "%s ")
     ("date" . "%12s ")
     ("count" . "%9s ")
     ("authors" . "%-30s ")
     ("subject" . "%s ")
     ("tags" . "(%s)")))

The first few characters on each line of the search result are used to
show information about some significant tags associated with the
thread.
emacs/notmuch.el