From 491ae21e1f2e105f119f15a387c0beb51698f238 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Fri, 6 Jul 2012 16:52:19 +2000 Subject: [PATCH] [PATCH v2 1/9] emacs: Clean up notmuch-search-show-result --- d5/171a722dcdecdb7f4339bd2a85faf8a75d711c | 127 ++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 d5/171a722dcdecdb7f4339bd2a85faf8a75d711c diff --git a/d5/171a722dcdecdb7f4339bd2a85faf8a75d711c b/d5/171a722dcdecdb7f4339bd2a85faf8a75d711c new file mode 100644 index 000000000..c42c731f9 --- /dev/null +++ b/d5/171a722dcdecdb7f4339bd2a85faf8a75d711c @@ -0,0 +1,127 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 0BC2E431FBF + for ; Thu, 5 Jul 2012 13:52:50 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id LZi13+giW8MX for ; + Thu, 5 Jul 2012 13:52:48 -0700 (PDT) +Received: from dmz-mailsec-scanner-8.mit.edu (DMZ-MAILSEC-SCANNER-8.MIT.EDU + [18.7.68.37]) + by olra.theworths.org (Postfix) with ESMTP id F310D431FC9 + for ; Thu, 5 Jul 2012 13:52:43 -0700 (PDT) +X-AuditID: 12074425-b7f9b6d0000008c4-89-4ff5fe9be8f0 +Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) + by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP + id 2E.07.02244.B9EF5FF4; Thu, 5 Jul 2012 16:52:43 -0400 (EDT) +Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) + by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id q65Kqgr8024133; + Thu, 5 Jul 2012 16:52:42 -0400 +Received: from drake.dyndns.org (26-4-182.dynamic.csail.mit.edu [18.26.4.182]) + (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q65KqbV7027234 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Thu, 5 Jul 2012 16:52:39 -0400 (EDT) +Received: from amthrax by drake.dyndns.org with local (Exim 4.77) + (envelope-from ) + id 1Smt2T-0004XU-Gh; Thu, 05 Jul 2012 16:52:37 -0400 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH v2 1/9] emacs: Clean up notmuch-search-show-result +Date: Thu, 5 Jul 2012 16:52:19 -0400 +Message-Id: <1341521547-15502-2-git-send-email-amdragon@mit.edu> +X-Mailer: git-send-email 1.7.10 +In-Reply-To: <1341521547-15502-1-git-send-email-amdragon@mit.edu> +References: <1341354059-29396-1-git-send-email-amdragon@mit.edu> + <1341521547-15502-1-git-send-email-amdragon@mit.edu> +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFjrOIsWRmVeSWpSXmKPExsUixCmqrDv731d/g2NXRC1Wz+WxuH5zJrPF + m5XzWB2YPXbOusvucfjrQhaPZ6tuMQcwR3HZpKTmZJalFunbJXBlPHx5mLXgoWDF0QnXmRoY + T/N1MXJySAiYSCyb/4oZwhaTuHBvPVsXIxeHkMA+RomOXVuZIZz1jBLTfm1nhHBOMkn0njoN + lZnLKPGkezobSD+bgIbEtv3LGUFsEQFpiZ13Z7OC2MwCcRJbpvwHiwsLOEk8/32HBcRmEVCV + uLxlLVicV8BB4kTbeVaIO+Qlnt7vA5vJKeAocWHiYrAaIYFyiT9L/rFMYORfwMiwilE2JbdK + NzcxM6c4NVm3ODkxLy+1SNdCLzezRC81pXQTIyi82F1UdzBOOKR0iFGAg1GJh9co94u/EGti + WXFl7iFGSQ4mJVHext9f/YX4kvJTKjMSizPii0pzUosPMUpwMCuJ8PZmAOV4UxIrq1KL8mFS + 0hwsSuK8N1Ju+gsJpCeWpGanphakFsFkZTg4lCR4n/4FahQsSk1PrUjLzClBSDNxcIIM5wEa + /gKkhre4IDG3ODMdIn+KUVFKnPc6SEIAJJFRmgfXC4v/V4ziQK8I834CqeIBpg647ldAg5mA + Buct/gQyuCQRISXVwDjB7OdEOTbxTS9FQyKDDh+y+r2qJ8N1aUCbmqL1fK+s6PyK1JSV/QYH + Jh/89PCTl3HSk7Q3SZ/dTP36MnXnF+Ra7FsRHM4meSdix/Lwh1WXGTn3vpjuuH7G0wdr1oUx + HzTb5//fsSxRz+RL1usrh1/lT2nre3Gv8GTz1JhaF81PGwuv8UgxmyuxFGckGmoxFxUnAgA0 + k3Do2gIAAA== +Cc: tomi.ollila@iki.fi +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Thu, 05 Jul 2012 20:52:50 -0000 + +This simplifies the code and makes it no longer cubic in the number of +result fields. +--- + emacs/notmuch.el | 19 ++++++++++--------- + 1 file changed, 10 insertions(+), 9 deletions(-) + +diff --git a/emacs/notmuch.el b/emacs/notmuch.el +index c6236db..8ad0b68 100644 +--- a/emacs/notmuch.el ++++ b/emacs/notmuch.el +@@ -707,29 +707,30 @@ non-authors is found, assume that all of the authors match." + (overlay-put overlay 'isearch-open-invisible #'delete-overlay))) + (insert padding)))) + +-(defun notmuch-search-insert-field (field date count authors subject tags) ++(defun notmuch-search-insert-field (field format-string date count authors subject tags) + (cond + ((string-equal field "date") +- (insert (propertize (format (cdr (assoc field notmuch-search-result-format)) date) ++ (insert (propertize (format format-string date) + 'face 'notmuch-search-date))) + ((string-equal field "count") +- (insert (propertize (format (cdr (assoc field notmuch-search-result-format)) count) ++ (insert (propertize (format format-string count) + 'face 'notmuch-search-count))) + ((string-equal field "subject") +- (insert (propertize (format (cdr (assoc field notmuch-search-result-format)) subject) ++ (insert (propertize (format format-string subject) + 'face 'notmuch-search-subject))) + + ((string-equal field "authors") +- (notmuch-search-insert-authors (cdr (assoc field notmuch-search-result-format)) authors)) ++ (notmuch-search-insert-authors format-string authors)) + + ((string-equal field "tags") ++ ;; Ignore format-string here because notmuch-search-set-tags ++ ;; depends on the format of this + (insert (concat "(" (propertize tags 'font-lock-face 'notmuch-tag-face) ")"))))) + + (defun notmuch-search-show-result (date count authors subject tags) +- (let ((fields) (field)) +- (setq fields (mapcar 'car notmuch-search-result-format)) +- (loop for field in fields +- do (notmuch-search-insert-field field date count authors subject tags))) ++ (dolist (spec notmuch-search-result-format) ++ (notmuch-search-insert-field (car spec) (cdr spec) ++ date count authors subject tags)) + (insert "\n")) + + (defun notmuch-search-process-filter (proc string) +-- +1.7.10 + -- 2.26.2