From baee9ec14d0d22863b7244b7c8b3fc5f1048a673 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Wed, 21 Mar 2012 01:33:23 +0000 Subject: [PATCH] Re: [PATCH v2 4/6] emacs: add optional predicate arg to `notmuch-show-mapc' --- 0e/ad0f5c56a1babf7c76d3d5d43488703eee2f68 | 135 ++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 0e/ad0f5c56a1babf7c76d3d5d43488703eee2f68 diff --git a/0e/ad0f5c56a1babf7c76d3d5d43488703eee2f68 b/0e/ad0f5c56a1babf7c76d3d5d43488703eee2f68 new file mode 100644 index 000000000..4e3cf2fee --- /dev/null +++ b/0e/ad0f5c56a1babf7c76d3d5d43488703eee2f68 @@ -0,0 +1,135 @@ +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 C274C431FC0 + for ; Tue, 20 Mar 2012 18:33:15 -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 24H-d0Z9a8gS for ; + Tue, 20 Mar 2012 18:33:13 -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 56EBD431FAF + for ; Tue, 20 Mar 2012 18:33:13 -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 1SAAQJ-0007xD-DF; Wed, 21 Mar 2012 01:33:11 +0000 +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 1SAAQJ-0001h1-2n; Wed, 21 Mar 2012 01:33:11 +0000 +From: Mark Walters +To: Pieter Praet , David Bremner , + Dmitry Kurochkin +Subject: Re: [PATCH v2 4/6] emacs: add optional predicate arg to + `notmuch-show-mapc' +In-Reply-To: <1330122640-18895-5-git-send-email-pieter@praet.org> +References: <87wr7xqpuf.fsf@rocinante.cs.unb.ca> + <1330122640-18895-1-git-send-email-pieter@praet.org> + <1330122640-18895-5-git-send-email-pieter@praet.org> +User-Agent: Notmuch/0.12+67~g3bd579a (http://notmuchmail.org) Emacs/23.3.1 + (x86_64-pc-linux-gnu) +Date: Wed, 21 Mar 2012 01:33:23 +0000 +Message-ID: <87vclywxek.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: 6534a7ea8e0a3ce3bc264c37708c922b (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: Notmuch Mail +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, 21 Mar 2012 01:33:15 -0000 + +On Fri, 24 Feb 2012 23:30:38 +0100, Pieter Praet wrote: +> * emacs/notmuch-show.el (notmuch-show-mapc): +> +> If provided with optional argument PREDICATE, only call +> FUNCTION if calling PREDICATE returns non-nil. +> +> Also correct original docstring: 's/thread/buffer/'. +> --- +> emacs/notmuch-show.el | 14 ++++++++++---- +> 1 files changed, 10 insertions(+), 4 deletions(-) +> +> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +> index aa9ccee..6adbdc0 100644 +> --- a/emacs/notmuch-show.el +> +++ b/emacs/notmuch-show.el +> @@ -1272,13 +1272,19 @@ (defun notmuch-show-goto-message-previous () +> (notmuch-show-move-to-message-top) +> t)) +> +> -(defun notmuch-show-mapc (function) +> - "Iterate through all messages in the current thread with +> +(defun notmuch-show-mapc (function &optional predicate) +> + "Iterate through all messages in the current buffer with +> `notmuch-show-goto-message-next' and call FUNCTION for side +> -effects." +> +effects. +> + +> +If provided with optional argument PREDICATE, only call +> +FUNCTION if calling PREDICATE returns non-nil." +> (save-excursion +> (goto-char (point-min)) +> - (loop do (funcall function) +> + (loop do (if predicate +> + (if (funcall predicate) +> + (funcall function)) +> + (funcall function)) +> while (notmuch-show-goto-message-next)))) +> +> ;; Functions relating to the visibility of messages and their + +The change looks fine. + +The original function feels a little fragile to me as to what happens if +predicate or function move point. Eg what happens if function collapses +the message: where does point go, and so where does +notmuch-show-goto-message-next go. Is this just my naivete as a lisp +beginner? Is there someway of writing it so the user doesn't need to +worry about such things? + +Best wishes + +Mark + +(sorry for the duplicate mail: I sent the first message from the wrong address) + -- 2.26.2