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

Pieter Praet pieter at praet.org
Fri Feb 24 14:30:38 PST 2012


* 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



More information about the notmuch mailing list