[PATCH v2 5/6] emacs: simplify `notmuch-show-get-messages-ids{, -search}'

Mark Walters markwalters1009 at gmail.com
Tue Mar 20 18:36:44 PDT 2012


On Fri, 24 Feb 2012 23:30:39 +0100, Pieter Praet <pieter at praet.org> wrote:
> * emacs/notmuch-show.el
> 
>   (notmuch-show-get-messages-ids):
>     If provided with optional arg SEPARATOR, return a string consisting
>     of all Message-Id's, separated by SEPARATOR.  Also improve original
>     docstring wrt default return value.
> 
>   (notmuch-show-get-messages-ids-search):
>     Removed, as its functionality is now in `notmuch-show-get-messages-ids'.
> 
>   (notmuch-show-tag-all):
>     Call `notmuch-show-get-messages-ids' with SEPARATOR arg instead of
>     `notmuch-show-get-messages-ids-search'.
> ---
>  emacs/notmuch-show.el |   18 +++++++++---------
>  1 files changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 6adbdc0..05606fc 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -1339,17 +1339,17 @@ (defun notmuch-show-get-message-id ()
>    "Return the message id of the current message."
>    (concat "id:\"" (notmuch-show-get-prop :id) "\""))
>  
> -(defun notmuch-show-get-messages-ids ()
> -  "Return all message ids of messages in the current thread."
> +(defun notmuch-show-get-messages-ids (&optional separator)
> +  "Return a list of Message-Id's of all messages in the current buffer.
> +
> +If provided with optional argument SEPARATOR, return a string
> +instead, consisting of all Message-Id's separated by SEPARATOR."
>    (let ((message-ids))
>      (notmuch-show-mapc
>       (lambda () (push (notmuch-show-get-message-id) message-ids)))
> -    message-ids))
> -
> -(defun notmuch-show-get-messages-ids-search ()
> -  "Return a search string for all message ids of messages in the
> -current thread."
> -  (mapconcat 'identity (notmuch-show-get-messages-ids) " or "))
> +    (if separator
> +	(mapconcat 'identity message-ids separator)
> +      message-ids)))
>  
>  ;; dme: Would it make sense to use a macro for many of these?
>  
> @@ -1638,7 +1638,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)
> +  (apply 'notmuch-tag (notmuch-show-get-messages-ids " or ") tag-changes)
>    (notmuch-show-mapc
>     (lambda ()
>       (let* ((current-tags (notmuch-show-get-tags))

I like the use of separator rather than hard-wiring " or ". My personal
preference would be to make that change but keep the two functions
separate (my "C"ness makes me like functions that have clear return
types!) But I am happy with the change too.

Best wishes

Mark




More information about the notmuch mailing list