summaryrefslogtreecommitdiff
path: root/emacs/notmuch-tree.el
diff options
context:
space:
mode:
Diffstat (limited to 'emacs/notmuch-tree.el')
-rw-r--r--emacs/notmuch-tree.el75
1 files changed, 59 insertions, 16 deletions
diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index a1dfa7b1..d6c67df2 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -93,41 +93,78 @@ empty string or to a different kind of arrow point."
(defcustom notmuch-tree-result-format
`(("date" . "%12s ")
("authors" . "%-20s")
- ((("tree" . "%s")("subject" . "%s")) ." %-54s ")
+ ((("tree" . "%s") ("subject" . "%s")) . " %-54s ")
("tags" . "(%s)"))
- "Result formatting for tree view. Supported fields are: date,
-authors, subject, tree, tags. Tree means the thread tree
-box graphics. The field may also be a list in which case
-the formatting rules are applied recursively and then the
-output of all the fields in the list is inserted
-according to format-string.
+ "Result formatting for tree view.
+
+Supported fields are: date, authors, subject, tree, tags or a
+symbol denoting an elisp function. Tree means the thread tree
+box graphics. The format can be either a format string or a
+function name, which is called with the string resulting from
+evaluating the field with format \"%s\".
+
+For example, the spec:
+
+ (\"subject\" . downcase)
+
+will print the subject in lower case (i.e., as returned by `downcase').
+
+When the field is a function instead of a string, the function is
+called with the current message properties as its first argument.
+For instance, if we define:
+
+ (defun downcase-subject (msg)
+ (downcase (plist-get msg :subject)))
+
+the spec
+
+ (downcase-subject)
+
+will print the subject in downcase (i.e., the result of calling
+`downcase-subject' with a plist of message properties).
+
+The field may also be a list in which case the formatting rules
+are applied recursively and then the output of all the fields in
+the list is inserted according to format-string.
Note the author string should not contain
whitespace (put it in the neighbouring fields instead).
For example:
(setq notmuch-tree-result-format \(\(\"authors\" . \"%-40s\"\)
\(\"subject\" . \"%s\"\)\)\)"
- :type '(alist :key-type (string) :value-type (string))
+ :type '(alist :key-type (choice (string :tag "Field name")
+ (symbol :tag "Function name"))
+ :value-type (choice (string :tag "Format string")
+ (const :tag "Message properties" nil)
+ (symbol :tag "Formatting function")))
:group 'notmuch-tree)
(defcustom notmuch-unthreaded-result-format
`(("date" . "%12s ")
("authors" . "%-20s")
- ((("subject" . "%s")) ." %-54s ")
+ ("subject" . " %-54s ")
("tags" . "(%s)"))
- "Result formatting for unthreaded tree view. Supported fields are: date,
-authors, subject, tree, tags. Tree means the thread tree
-box graphics. The field may also be a list in which case
-the formatting rules are applied recursively and then the
-output of all the fields in the list is inserted
-according to format-string.
+ "Result formatting for unthreaded tree view.
+
+Supported fields are: date, authors, subject, tree, tags or a
+symbol denoting an elisp function. The format can be either a
+format string or a function taking the field's value and
+formatting it. The field may also be a list of other field
+specifications.
+
+Please see the docstring of `notmuch-tree-result-format' for more
+details and examples.
Note the author string should not contain
whitespace (put it in the neighbouring fields instead).
For example:
(setq notmuch-tree-result-format \(\(\"authors\" . \"%-40s\"\)
\(\"subject\" . \"%s\"\)\)\)"
- :type '(alist :key-type (string) :value-type (string))
+ :type '(alist :key-type (choice (string :tag "Field name")
+ (symbol :tag "Function name"))
+ :value-type (choice (string :tag "Format string")
+ (const :tag "Message properties" nil)
+ (symbol :tag "Formatting function")))
:group 'notmuch-tree)
(defun notmuch-tree-result-format ()
@@ -886,6 +923,12 @@ unchanged ADDRESS if parsing fails."
(let* ((headers (plist-get msg :headers))
(match (plist-get msg :match)))
(cond
+ ((symbolp field)
+ (apply field msg format-string))
+
+ ((symbolp format-string)
+ (funcall format-string (notmuch-tree-format-field field "%s" msg)))
+
((listp field)
(format format-string (notmuch-tree-format-field-list field msg)))