From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id KH52EDos02JtJgEAbAwnHQ (envelope-from ) for ; Sat, 16 Jul 2022 23:23:06 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id kEN2EDos02KefQAAauVa8A (envelope-from ) for ; Sat, 16 Jul 2022 23:23:06 +0200 Received: from mail.notmuchmail.org (yantan.tethera.net [IPv6:2a01:4f9:c011:7a79::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 0AC043C019 for ; Sat, 16 Jul 2022 23:23:06 +0200 (CEST) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 2B0E46082B; Sat, 16 Jul 2022 21:22:48 +0000 (UTC) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id A4F2C5E53F for ; Sat, 16 Jul 2022 21:22:45 +0000 (UTC) Received: by fethera.tethera.net (Postfix, from userid 1001) id E08725FBD0; Sat, 16 Jul 2022 17:22:44 -0400 (EDT) Received: (nullmailer pid 56485 invoked by uid 1000); Sat, 16 Jul 2022 21:22:37 -0000 From: David Bremner 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 Message-Id: <20220716212228.56432-4-david@tethera.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220716212228.56432-1-david@tethera.net> References: <20220716212228.56432-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: TSHJA4ELNLUFLKDP4DHBAJMEOCB22ORN X-Message-ID-Hash: TSHJA4ELNLUFLKDP4DHBAJMEOCB22ORN X-MailFrom: bremner@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: DE ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1658006586; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post; bh=SD/mAAdLOSPFPx5noZygL52Nn4UioFjPxz7Jmscuts8=; b=tetrlJmIxLg00Wg7K4f28VcopXXWSUK1SAcOuR5E9aewLBPQpNmAeFiFZRJIlPa+UObGxh plcWZMVXbmkZgELjv3npVkZ6ZxAMBVCXcSv1EbWBU8qtGNJ1aVEks7+xwpuUyDW5pW3m2O vQOb1uwy3+S1igBqB1dK6kUgawlzTmHZbeecYiJMwGryCAv7GdJfwuj1MOGVC/i2jmzCVs KiPeC0IDta7Ff7Pb9XzHpDmI10D2hmlmGscR49pbQDWqCg73Zmt9IO91vmZI+9Jde5FN1s hDyseBnOrTgYFkuXUjePo4FVBfwvNL5Ie8fRzldeUhw4lLv8FY8eiDzCFjbaCQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1658006586; a=rsa-sha256; cv=none; b=fCvZRZ/45Uau6gObNbEpKit28hJgMwSZcm29dNHIxwJ7XbT0qbvmy1pTjXlxhPUPIcD1lc Po+MPPijF3BRlL4cbAnsY6LBq7C+i2ppiVlp68pBr2YwR+9a2Wx3QRH3qDBQsXtzQKtVCp gOUNq9QGW+dnRtdxb0e1c/vwLVMeHT0HBYeMiSQ1XkCnMUGeTON2XnPkUiZPIZKzjzOkaQ C1mG/8974pBOjwIi7SB6NFf97bm8SBloRXEG9kPZiN0bYragqOPWRA73+KfU/OmMa9LOu4 UYlPpVafP0cYUH0rxH78sk7DEjCHT3RzkhzLL1SjpDJDXYAIyq4FrUMO4EA93g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.40 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 0AC043C019 X-Spam-Score: -1.40 X-Migadu-Scanner: scn1.migadu.com X-TUID: tSwfbX93ftKt 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