[PATCH 4/6] emacs: add predicate arg to `notmuch-show-mapc'

Subject: [PATCH 4/6] emacs: add predicate arg to `notmuch-show-mapc'

Date: Fri, 24 Feb 2012 00:09:12 +0100

To: David Bremner, Dmitry Kurochkin

Cc: Notmuch Mail

From: Pieter Praet

* emacs/notmuch-show.el

    Only call FUNCTION if new argument PREDICATE is satisfied.
    Also correct original docstring: 's/thread/buffer/'.

    Update wrt changes to `notmuch-show-mapc'.

    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 ()
-(defun notmuch-show-mapc (function)
-  "Iterate through all messages in the current thread with
-`notmuch-show-goto-message-next' and call FUNCTION for side
+(defun notmuch-show-mapc (predicate function)
+  "Iterate through all messages in the current buffer with
+`notmuch-show-goto-message-next'.  If PREDICATE is satisfied,
+call FUNCTION for side effects."
     (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)))
@@ -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)))