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 82C10415E4A for ; Fri, 24 Feb 2012 14:37:47 -0800 (PST) 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 B0iQdi6cWHGp for ; Fri, 24 Feb 2012 14:37:46 -0800 (PST) Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id B0649415E49 for ; Fri, 24 Feb 2012 14:37:46 -0800 (PST) Received: by wibhi8 with SMTP id hi8so2010781wib.26 for ; Fri, 24 Feb 2012 14:37:45 -0800 (PST) Received-SPF: pass (google.com: domain of pieter@praet.org designates 10.180.97.130 as permitted sender) client-ip=10.180.97.130; Authentication-Results: mr.google.com; spf=pass (google.com: domain of pieter@praet.org designates 10.180.97.130 as permitted sender) smtp.mail=pieter@praet.org Received: from mr.google.com ([10.180.97.130]) by 10.180.97.130 with SMTP id ea2mr8787045wib.20.1330123065583 (num_hops = 1); Fri, 24 Feb 2012 14:37:45 -0800 (PST) Received: by 10.180.97.130 with SMTP id ea2mr7087381wib.20.1330123065508; Fri, 24 Feb 2012 14:37:45 -0800 (PST) Received: from localhost ([109.131.181.26]) by mx.google.com with ESMTPS id bg3sm6293527wib.10.2012.02.24.14.37.44 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 24 Feb 2012 14:37:45 -0800 (PST) From: Pieter Praet To: Dmitry Kurochkin , David Bremner Subject: Re: [PATCH 4/6] emacs: add predicate arg to `notmuch-show-mapc' In-Reply-To: <87fwe0jz0y.fsf@gmail.com> References: <878vjtqhcg.fsf@praet.org> <1330038554-10347-4-git-send-email-pieter@praet.org> <87fwe0jz0y.fsf@gmail.com> User-Agent: Notmuch/0.11.1+210~g6afc43e (http://notmuchmail.org) Emacs/23.3.1 (x86_64-unknown-linux-gnu) Date: Fri, 24 Feb 2012 23:35:26 +0100 Message-ID: <877gzbeu6p.fsf@praet.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Gm-Message-State: ALoCoQk4Ikp37f5TAcI+he1a7VaRWUhEkvtpAA9c5pwCnsxKAr+cxbZ30ZbJoOs382dQBtQIU3HS 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: Fri, 24 Feb 2012 22:37:47 -0000 On Fri, 24 Feb 2012 14:39:41 +0400, Dmitry Kurochkin wrote: > On Fri, 24 Feb 2012 00:09:12 +0100, Pieter Praet wrote: > > * emacs/notmuch-show.el > > > > (notmuch-show-mapc): > > Only call FUNCTION if new argument PREDICATE is satisfied. > > Also correct original docstring: 's/thread/buffer/'. > > > > (notmuch-show-get-messages-ids): > > Update wrt changes to `notmuch-show-mapc'. > > > > (notmuch-show-tag-all): > > Update wrt changes to `notmuch-show-mapc'. > > --- > > emacs/notmuch-show.el | 15 ++++++++------- > > 1 files changed, 8 insertions(+), 7 deletions(-) > > > > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el > > index aa9ccee..5fc0e43 100644 > > --- a/emacs/notmuch-show.el > > +++ b/emacs/notmuch-show.el > > @@ -1272,13 +1272,14 @@ (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 > > -`notmuch-show-goto-message-next' and call FUNCTION for side > > -effects." > > +(defun notmuch-show-mapc (predicate function) > > Please make PREDICATE optional to avoid giving t when it is not needed. > Done. > I would expect PREDICATE to be a function, [...] Well, it *can* be a function actually (see later usage in e.g. `notmuch-show-get-messages-ids' [1]), but should be provided as a form instead of as a quoted symbol. > [...] but perhaps the way you > implemented it is common in Emacs. > Far from it, apparently. I did it that way to prevent `funcall' from choking on t/nil, which -in retrospect- was rather shortsighted... I've used a more sensible approach in v2 [2]. > Regards, > Dmitry > > > + "Iterate through all messages in the current buffer with > > +`notmuch-show-goto-message-next'. If PREDICATE is satisfied, > > +call FUNCTION for side effects." > > (save-excursion > > (goto-char (point-min)) > > - (loop do (funcall function) > > + (loop do (if (eval predicate) > > + (funcall function)) > > while (notmuch-show-goto-message-next)))) > > > > ;; Functions relating to the visibility of messages and their > > @@ -1336,7 +1337,7 @@ (defun notmuch-show-get-message-id () > > (defun notmuch-show-get-messages-ids () > > "Return all message ids of messages in the current thread." > > (let ((message-ids)) > > - (notmuch-show-mapc > > + (notmuch-show-mapc t > > (lambda () (push (notmuch-show-get-message-id) message-ids))) > > message-ids)) > > > > @@ -1633,7 +1634,7 @@ (defun notmuch-show-tag-all (&rest tag-changes) > > TAG-CHANGES is a list of tag operations for `notmuch-tag'." > > (interactive (notmuch-read-tag-changes nil notmuch-show-thread-id)) > > (apply 'notmuch-tag (notmuch-show-get-messages-ids-search) tag-changes) > > - (notmuch-show-mapc > > + (notmuch-show-mapc t > > (lambda () > > (let* ((current-tags (notmuch-show-get-tags)) > > (new-tags (notmuch-update-tags current-tags tag-changes))) > > -- > > 1.7.8.1 > > Peace -- Pieter [1] id:"1330038554-10347-6-git-send-email-pieter@praet.org" [2] id:"1330122640-18895-5-git-send-email-pieter@praet.org"