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 89357416017 for ; Fri, 24 Feb 2012 14:33:32 -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 WGIxG7V3Gd4X for ; Fri, 24 Feb 2012 14:33:31 -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 321D9415D32 for ; Fri, 24 Feb 2012 14:33:30 -0800 (PST) Received: by wibhi8 with SMTP id hi8so2008668wib.26 for ; Fri, 24 Feb 2012 14:33:28 -0800 (PST) Received-SPF: pass (google.com: domain of pieter@praet.org designates 10.180.86.134 as permitted sender) client-ip=10.180.86.134; Authentication-Results: mr.google.com; spf=pass (google.com: domain of pieter@praet.org designates 10.180.86.134 as permitted sender) smtp.mail=pieter@praet.org Received: from mr.google.com ([10.180.86.134]) by 10.180.86.134 with SMTP id p6mr8878423wiz.0.1330122808960 (num_hops = 1); Fri, 24 Feb 2012 14:33:28 -0800 (PST) MIME-Version: 1.0 Received: by 10.180.86.134 with SMTP id p6mr7172366wiz.0.1330122808879; Fri, 24 Feb 2012 14:33:28 -0800 (PST) Received: from localhost ([109.131.181.26]) by mx.google.com with ESMTPS id cs4sm14678582wib.8.2012.02.24.14.33.28 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 24 Feb 2012 14:33:28 -0800 (PST) From: Pieter Praet To: David Bremner , Dmitry Kurochkin Subject: [PATCH v2 4/6] emacs: add optional predicate arg to `notmuch-show-mapc' Date: Fri, 24 Feb 2012 23:30:38 +0100 Message-Id: <1330122640-18895-5-git-send-email-pieter@praet.org> X-Mailer: git-send-email 1.7.8.1 In-Reply-To: <1330122640-18895-1-git-send-email-pieter@praet.org> References: <87wr7xqpuf.fsf@rocinante.cs.unb.ca> <1330122640-18895-1-git-send-email-pieter@praet.org> X-Gm-Message-State: ALoCoQnkNJMxbNjmSVpFTNz2xGhCnfMyK3XRwvEGsz9WKbZ1B8M20ULZ52MsgHXyg+ZEaYt+YtlT 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:33:32 -0000 * 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 -- 1.7.8.1