[PATCH v2 4/6] emacs: add optional predicate arg to `notmuch-show-mapc'
Ethan Glasser-Camp
ethan.glasser.camp at gmail.com
Mon Oct 15 19:18:12 PDT 2012
Pieter Praet <pieter at praet.org> writes:
> * 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/'.
> ---
This patch was marked stale, but isn'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))
I don't like the way this if-structure looks, since I have to squint to
see whether the "else" clause matches the inner or the outer "if". Maybe
change the inner "if" to a "when" or an "and"?
Ethan
More information about the notmuch
mailing list