From c1e67960f78c7ecd3f18cd240f06545eb2b897ad Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Tue, 10 Jul 2012 17:42:34 +2000 Subject: [PATCH] [PATCH v3 1/9] emacs: Clean up notmuch-search-show-result --- dc/25efde5c405026a27f9f7591c24184a4606308 | 127 ++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 dc/25efde5c405026a27f9f7591c24184a4606308 diff --git a/dc/25efde5c405026a27f9f7591c24184a4606308 b/dc/25efde5c405026a27f9f7591c24184a4606308 new file mode 100644 index 000000000..c3201e15e --- /dev/null +++ b/dc/25efde5c405026a27f9f7591c24184a4606308 @@ -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 4A6F4429E30 + for ; Mon, 9 Jul 2012 14:42: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 FhmWRwzvvsTq for ; + Mon, 9 Jul 2012 14:42:49 -0700 (PDT) +Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU + [18.9.25.15]) + by olra.theworths.org (Postfix) with ESMTP id 61D9F431FBF + for ; Mon, 9 Jul 2012 14:42:49 -0700 (PDT) +X-AuditID: 1209190f-b7f306d0000008b4-17-4ffb50588fe4 +Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) + by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP + id 0A.0F.02228.8505BFF4; Mon, 9 Jul 2012 17:42:48 -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 q69LglVQ011259; + Mon, 9 Jul 2012 17:42:47 -0400 +Received: from drake.dyndns.org (26-4-176.dynamic.csail.mit.edu [18.26.4.176]) + (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q69LgiYZ022682 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Mon, 9 Jul 2012 17:42:45 -0400 (EDT) +Received: from amthrax by drake.dyndns.org with local (Exim 4.77) + (envelope-from ) + id 1SoLj9-0004fo-Vs; Mon, 09 Jul 2012 17:42:43 -0400 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH v3 1/9] emacs: Clean up notmuch-search-show-result +Date: Mon, 9 Jul 2012 17:42:34 -0400 +Message-Id: <1341870162-17782-2-git-send-email-amdragon@mit.edu> +X-Mailer: git-send-email 1.7.10 +In-Reply-To: <1341870162-17782-1-git-send-email-amdragon@mit.edu> +References: <1341354059-29396-1-git-send-email-amdragon@mit.edu> + <1341870162-17782-1-git-send-email-amdragon@mit.edu> +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFjrGIsWRmVeSWpSXmKPExsUixCmqrBsR8Nvf4OEaTYvVc3ksrt+cyWzx + ZuU8Vgdmj52z7rJ7HP66kMXj2apbzAHMUVw2Kak5mWWpRfp2CVwZD18eZi14KFhxdMJ1pgbG + 03xdjJwcEgImEo9e3WOEsMUkLtxbz9bFyMUhJLCPUeL57MlMEM56RondbV9YIZyTTBJ3T35l + hnDmMkrc/ruFDaSfTUBDYtv+5WCzRASkJXbenc0KYjMLxElsmfIfKM7BISzgJPF1dTZImEVA + VWLphBtMIDavgIPEp9YWJogz5CWe3u8DG8kp4Cgx5+YOsJFCAuUSn2/8Y57AyL+AkWEVo2xK + bpVubmJmTnFqsm5xcmJeXmqRrolebmaJXmpK6SZGcHBJ8u9g/HZQ6RCjAAejEg/vJpbf/kKs + iWXFlbmHGCU5mJREefM8gUJ8SfkplRmJxRnxRaU5qcWHGCU4mJVEeG+5AuV4UxIrq1KL8mFS + 0hwsSuK8V1Nu+gsJpCeWpGanphakFsFkZTg4lCR4p/kDNQoWpaanVqRl5pQgpJk4OEGG8wAN + nwBSw1tckJhbnJkOkT/FqCglzjsZJCEAksgozYPrhUX/K0ZxoFeEeYtAqniAiQOu+xXQYCag + we09v0AGlyQipKQaGLOPvfh+5Zp+a9Fcr5+idrOm3q44YjanzVmYrfUE31TxjRoBx5jL/QKv + CT54G/jupDSH3LXKuj012VczwtLenV854fIUwVbpuCM30hisX0w54LPa34Mr1ub4/7feM16c + Dn3c/kipc2fFd7GYFrZr7XnmwVJrPVhPbzxq83BOb8yzV4HuQZ/eP1ViKc5INNRiLipOBACj + OpOa2QIAAA== +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: Mon, 09 Jul 2012 21:42: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