From: Mark Walters Date: Wed, 4 Jul 2012 07:53:54 +0000 (+0100) Subject: Re: [PATCH 1/8] emacs: Clean up notmuch-search-show-result X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=7d2b36ac57cdf727f09a1ecf657e5c81e443574a;p=notmuch-archives.git Re: [PATCH 1/8] emacs: Clean up notmuch-search-show-result --- diff --git a/93/42ade888030d3dc515c62e06f84fdbb9753759 b/93/42ade888030d3dc515c62e06f84fdbb9753759 new file mode 100644 index 000000000..59997f2db --- /dev/null +++ b/93/42ade888030d3dc515c62e06f84fdbb9753759 @@ -0,0 +1,148 @@ +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 84386431FB6 + for ; Wed, 4 Jul 2012 00:54:06 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -1.098 +X-Spam-Level: +X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5 + tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, + NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 eoqze+88bPNl for ; + Wed, 4 Jul 2012 00:54:05 -0700 (PDT) +Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id E54FC431FAE + for ; Wed, 4 Jul 2012 00:54:04 -0700 (PDT) +Received: from smtp.qmul.ac.uk ([138.37.6.40]) + by mail2.qmul.ac.uk with esmtp (Exim 4.71) + (envelope-from ) + id 1SmKPN-0003Xf-JM; Wed, 04 Jul 2012 08:54:00 +0100 +Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223] + helo=localhost) + by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69) + (envelope-from ) + id 1SmKPN-0006jM-AA; Wed, 04 Jul 2012 08:53:57 +0100 +From: Mark Walters +To: Austin Clements , notmuch@notmuchmail.org +Subject: Re: [PATCH 1/8] emacs: Clean up notmuch-search-show-result +In-Reply-To: <1341354059-29396-2-git-send-email-amdragon@mit.edu> +References: <1341354059-29396-1-git-send-email-amdragon@mit.edu> + <1341354059-29396-2-git-send-email-amdragon@mit.edu> +User-Agent: Notmuch/0.13.2+70~gb6a56e7 (http://notmuchmail.org) Emacs/23.4.1 + (x86_64-pc-linux-gnu) +Date: Wed, 04 Jul 2012 08:53:54 +0100 +Message-ID: <87lij0gdwt.fsf@qmul.ac.uk> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Sender-Host-Address: 94.192.233.223 +X-QM-SPAM-Info: Sender has good ham record. :) +X-QM-Body-MD5: e7744b8facc79a4efc45a2d8fafea7ba (of first 20000 bytes) +X-SpamAssassin-Score: -1.8 +X-SpamAssassin-SpamBar: - +X-SpamAssassin-Report: The QM spam filters have analysed this message to + determine if it is + spam. We require at least 5.0 points to mark a message as spam. + This message scored -1.8 points. + Summary of the scoring: + * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, + * medium trust + * [138.37.6.40 listed in list.dnswl.org] + * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail + provider * (markwalters1009[at]gmail.com) + * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay + * domain + * 0.5 AWL AWL: From: address is in the auto white-list +X-QM-Scan-Virus: ClamAV says the message is clean +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: Wed, 04 Jul 2012 07:54:06 -0000 + +On Tue, 03 Jul 2012, Austin Clements wrote: +> This simplifies the code and makes it no longer cubic in the number of +> result fields. + +This looks good to me and all tests pass, and I agree that this patch +can be pushed independently of the later patches in the series. + +My one comment is that I, as a lisp beginner, found the use of "format" +as a function and a variable confusing (particularly as I had not come +across the dolist macro and that use really makes format look like a +function). + +Best wishes + +Mark + +> --- +> emacs/notmuch.el | 20 ++++++++++---------- +> 1 file changed, 10 insertions(+), 10 deletions(-) +> +> diff --git a/emacs/notmuch.el b/emacs/notmuch.el +> index c6236db..be217a2 100644 +> --- a/emacs/notmuch.el +> +++ b/emacs/notmuch.el +> @@ -707,29 +707,29 @@ 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 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 date) +> 'face 'notmuch-search-date))) +> ((string-equal field "count") +> - (insert (propertize (format (cdr (assoc field notmuch-search-result-format)) count) +> + (insert (propertize (format format count) +> 'face 'notmuch-search-count))) +> ((string-equal field "subject") +> - (insert (propertize (format (cdr (assoc field notmuch-search-result-format)) subject) +> + (insert (propertize (format format 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 authors)) +> +> ((string-equal field "tags") +> - (insert (concat "(" (propertize tags 'font-lock-face 'notmuch-tag-face) ")"))))) +> + (insert +> + (format format (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 (format notmuch-search-result-format) +> + (notmuch-search-insert-field (car format) (cdr format) +> + date count authors subject tags)) +> (insert "\n")) +> +> (defun notmuch-search-process-filter (proc string) +> -- +> 1.7.10 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch