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

Dmitry Kurochkin dmitry.kurochkin at gmail.com
Fri Feb 24 02:39:41 PST 2012


On Fri, 24 Feb 2012 00:09:12 +0100, Pieter Praet <pieter at praet.org> 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
> 


More information about the notmuch mailing list