mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-28 05:34:11 +01:00
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.
This commit is contained in:
parent
071fb57a35
commit
4f4ec48df2
1 changed files with 2 additions and 0 deletions
|
@ -834,6 +834,8 @@ non-authors is found, assume that all of the authors match."
|
||||||
|
|
||||||
(defun notmuch-search-insert-field (field format-string result)
|
(defun notmuch-search-insert-field (field format-string result)
|
||||||
(pcase field
|
(pcase field
|
||||||
|
((pred functionp)
|
||||||
|
(insert (funcall field format-string result)))
|
||||||
("date"
|
("date"
|
||||||
(insert (propertize (format format-string (plist-get result :date_relative))
|
(insert (propertize (format format-string (plist-get result :date_relative))
|
||||||
'face 'notmuch-search-date)))
|
'face 'notmuch-search-date)))
|
||||||
|
|
Loading…
Reference in a new issue