unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Bremner <david@tethera.net>
To: notmuch@notmuchmail.org
Subject: [PATCH 3/6] emacs: update defcustom for notmuch-search-result-format.
Date: Sat, 16 Jul 2022 17:22:25 -0400	[thread overview]
Message-ID: <20220716212228.56432-4-david@tethera.net> (raw)
In-Reply-To: <20220716212228.56432-1-david@tethera.net>

It seems redundant to have the previous example, since the default
value is always show by describe variable.

Enforce more restrictions on the keys in the alist, since arbitrary
strings don't work as field names.

Document that functions can be used in lieu of field names.
---
 emacs/notmuch-tree.el | 29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 8b246a2e..68614623 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -97,6 +97,15 @@ different kind of arrow point."
   :type '(alist :key-type symbol :value-type string)
   :group 'notmuch-tree)
 
+(defconst notmuch-tree--field-names
+  '(choice :tag "Field"
+	   (const :tag "Date" "date")
+	   (const :tag "Authors" "authors")
+	   (const :tag "Subject" "subject")
+	   (const :tag "Tree" "tree")
+	   (const :tag "Tags" "tags")
+	   (function)))
+
 (defcustom notmuch-tree-result-format
   `(("date" . "%12s  ")
     ("authors" . "%-20s")
@@ -106,7 +115,11 @@ different kind of arrow point."
     ("tags" . "(%s)"))
   "Result formatting for tree view.
 
-Supported fields are: date, authors, subject, tree, tags.
+List of pairs of (field . format-string).  Supported field
+strings are: \"date\", \"authors\", \"subject\", \"tree\",
+\"tags\".  It is also supported to pass a function in place of a
+field-name. In this case the function is passed the thread
+object (plist) and format string.
 
 Tree means the thread tree box graphics. The field may
 also be a list in which case the formatting rules are
@@ -114,14 +127,12 @@ applied recursively and then the output of all the fields
 in the list is inserted according to format-string.
 
 Note that 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 (choice string
-				  (alist :key-type string
-					 :value-type string))
-		:value-type string)
+\(put it in the neighbouring fields instead)."
+
+  :type `(alist :key-type (choice ,notmuch-tree--field-names
+				  (alist :key-type ,notmuch-tree--field-names
+					 :value-type (string :tag "Format")))
+		:value-type (string :tag "Format"))
   :group 'notmuch-tree)
 
 (defcustom notmuch-unthreaded-result-format
-- 
2.35.1

  parent reply	other threads:[~2022-07-16 21:23 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-16 21:22 update documentation for notmuch-*-result-format David Bremner
2022-07-16 21:22 ` [PATCH 1/6] emacs: update defcustom for notmuch-search-result-format David Bremner
2022-07-16 21:22 ` [PATCH 2/6] doc/emacs: add docstring and example for n-search-result-format David Bremner
2022-07-16 21:22 ` David Bremner [this message]
2022-07-16 21:22 ` [PATCH 4/6] doc/emacs: add docstring and example for n-tree-result-format David Bremner
2022-07-16 21:22 ` [PATCH 5/6] emacs: update defcustom for notmuch-unthreaded-result-format David Bremner
2022-07-16 21:22 ` [PATCH 6/6] doc/emacs: add docstring " David Bremner
2022-07-30 12:15   ` David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220716212228.56432-4-david@tethera.net \
    --to=david@tethera.net \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).