From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:c151::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id OC3EMAB6MmB7UgAA0tVLHw (envelope-from ) for ; Sun, 21 Feb 2021 15:19:28 +0000 Received: from aspmx2.migadu.com ([2001:41d0:2:c151::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id EHKhLAB6MmBVJQAAB5/wlQ (envelope-from ) for ; Sun, 21 Feb 2021 15:19:28 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [IPv6:2607:5300:201:3100::1657]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx2.migadu.com (Postfix) with ESMTPS id 85F8F1EE3F for ; Sun, 21 Feb 2021 16:19:28 +0100 (CET) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id CC9B226BE4; Sun, 21 Feb 2021 10:19:13 -0500 (EST) Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by mail.notmuchmail.org (Postfix) with ESMTPS id 1D69626ACE for ; Sun, 21 Feb 2021 10:19:09 -0500 (EST) Received: by mail-wm1-x32a.google.com with SMTP id v62so12101000wmg.4 for ; Sun, 21 Feb 2021 07:19:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dme-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0q7I1zlH2RK3NT8y1WMLzW5iHSmyawE4uOyyQ7BMj4M=; b=Ogj4wWTXRrJq6BVQGmClk5PTYezUHyxBjPUmR3r2/XemU3VYNF89X6eyMh2t0pBfux sLq1dDn+o6lUQcdxggZ5XN1bntCz9KFIKVJr8r9JuxUcezT27yYtsNGbZYWcKZNNjbT8 a9Li0quQYU3uuAJ1Q9HMxmIbTFpjI68gmxGA4TxdzPllktq/ZVcym2I2z1Nh8ULAo1/r e/gc4ynA7tNAXRHzhraVqEBwMjoKf2jnb7QiqGomPtca/5b1le9BrPFVOcYFwD4rWXXI KNrwJt9sXsnOT+vT7TcFEuesPhlQQsquO+ybYKdbrWHckEh0OJx5yA5nqX17yPhoIXiw qyeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0q7I1zlH2RK3NT8y1WMLzW5iHSmyawE4uOyyQ7BMj4M=; b=scdbMvts1RPAxpltm6Bgdq6Od5YdfOe+u8YjjUnxhwe+QsFu1UrkSm5m2Nlvqa9580 S0pN6hnpggcKY+/GSyC28Lu0PAFGj9SxLHK47ZYJ4BaYoGXz0gKqZ2+vq7+tWXSYLpB/ yN1alvZqgDXr+tg242P9sSXf9Xs5EZm+DlXf/BlvPVFOzsWAE6L0jOxAJj/m73X4IicP rChr95EH/KTSAJr7GohAJYZulO9pfoWh7cScEBBNoDMDC1cnh+Fz5br/NrqqJDxaZtPy 1nL27LbQIGeYo1W/hzemBJzpB0cQFLj9IrvK50PiSzeMHyT7yaK83g7BI9FGRbkY9vG+ VuCw== X-Gm-Message-State: AOAM531z23nWT/jOhzyC/xOFz5l3hhIqikP4qcxXCX8P5IlcU64tPBCK oUKMw72IPWGgDGP9WOhoRmYVaWckWfc4QOKN X-Google-Smtp-Source: ABdhPJyjJDTymK/Hj4a3C5jg1iQYG1RKXWMKBUJgGhdOU9ztim4N1qTFGTIgUoNGRFWQBj4IPvmvxg== X-Received: by 2002:a05:600c:410e:: with SMTP id j14mr5770189wmi.36.1613920744857; Sun, 21 Feb 2021 07:19:04 -0800 (PST) Received: from disaster-area.hh.sledj.net (disaster-area.hh.sledj.net. [2001:8b0:bb71:7140:64::1]) by smtp.gmail.com with ESMTPSA id c62sm23204974wme.16.2021.02.21.07.19.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Feb 2021 07:19:04 -0800 (PST) Received: from localhost (disaster-area.hh.sledj.net [local]) by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id adf162a7; Sun, 21 Feb 2021 15:19:02 +0000 (UTC) From: David Edmondson To: notmuch@notmuchmail.org Subject: [PATCH v3 2/3] emacs: Allow functions in notmuch-search-result-format Date: Sun, 21 Feb 2021 15:19:01 +0000 Message-Id: <20210221151902.2301690-3-dme@dme.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210221151902.2301690-1-dme@dme.org> References: <20210221151902.2301690-1-dme@dme.org> MIME-Version: 1.0 Message-ID-Hash: HSBOVYALUZHPSPSAZU6SCMJQ35IKUE4L X-Message-ID-Hash: HSBOVYALUZHPSPSAZU6SCMJQ35IKUE4L X-MailFrom: dme@dme.org X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0 CC: David Edmondson X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: 1.56 Authentication-Results: aspmx2.migadu.com; dkim=fail ("body hash did not verify") header.d=dme-org.20150623.gappssmtp.com header.s=20150623 header.b=Ogj4wWTX; dmarc=none; spf=pass (aspmx2.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 85F8F1EE3F X-Spam-Score: 1.56 X-Migadu-Scanner: scn1.migadu.com X-TUID: ofMMyyCf46U/ 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 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/emacs/notmuch.el b/emacs/notmuch.el index b9cee19c..6ba535d1 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -831,6 +831,8 @@ non-authors is found, assume that all of the authors match." (defun notmuch-search-insert-field (field format-string result) (pcase field + ((pred functionp) + (insert (funcall field format-string result))) ("date" (insert (propertize (format format-string (plist-get result :date_relative)) 'face 'notmuch-search-date))) -- 2.30.0