From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id D9DC5429E31 for ; Fri, 24 Feb 2012 02:41:07 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.799 X-Spam-Level: X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, 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 Gie4own1SiLi for ; Fri, 24 Feb 2012 02:41:07 -0800 (PST) Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 0C9C4431FAE for ; Fri, 24 Feb 2012 02:41:06 -0800 (PST) Received: by bkcit16 with SMTP id it16so2020859bkc.26 for ; Fri, 24 Feb 2012 02:41:05 -0800 (PST) Received-SPF: pass (google.com: domain of dmitry.kurochkin@gmail.com designates 10.204.10.91 as permitted sender) client-ip=10.204.10.91; Authentication-Results: mr.google.com; spf=pass (google.com: domain of dmitry.kurochkin@gmail.com designates 10.204.10.91 as permitted sender) smtp.mail=dmitry.kurochkin@gmail.com; dkim=pass header.i=dmitry.kurochkin@gmail.com Received: from mr.google.com ([10.204.10.91]) by 10.204.10.91 with SMTP id o27mr818767bko.17.1330080065749 (num_hops = 1); Fri, 24 Feb 2012 02:41:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version:content-type; bh=BQIiErY7N98r2FbpN1yiO3UsjlHldJkZFxpGYmr3OpU=; b=iDGX56JBqKU8GiSZdPd4ihz5QwfwCfjPoFSjW3i9bw4+J3UPxLb1bW5nEHxTVHo2Hu lhopfjqIMM5/oz99xGGnS1c5Lg/g1+Cj2JH/mGlBusxtNw+N66RNxe650aKC+WDNR9wL BxyGpadfseuvRM2k294jFa9GPMHfct6RlyTGg= Received: by 10.204.10.91 with SMTP id o27mr681097bko.17.1330080065681; Fri, 24 Feb 2012 02:41:05 -0800 (PST) Received: from localhost ([91.144.186.21]) by mx.google.com with ESMTPS id w15sm7893400bku.0.2012.02.24.02.41.04 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 24 Feb 2012 02:41:04 -0800 (PST) From: Dmitry Kurochkin To: Pieter Praet , David Bremner Subject: Re: [PATCH 4/6] emacs: add predicate arg to `notmuch-show-mapc' In-Reply-To: <1330038554-10347-4-git-send-email-pieter@praet.org> References: <878vjtqhcg.fsf@praet.org> <1330038554-10347-4-git-send-email-pieter@praet.org> User-Agent: Notmuch/0.11.1+188~ga5674c2 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu) Date: Fri, 24 Feb 2012 14:39:41 +0400 Message-ID: <87fwe0jz0y.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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 10:41:08 -0000 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. I would expect PREDICATE to be a function, but perhaps the way you implemented it is common in Emacs. 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 >