[PATCH 6/6] emacs: `notmuch-show-tag-all' sans prefix arg only tags open messages

Pieter Praet pieter at praet.org
Fri Feb 24 14:37:10 PST 2012


On Fri, 24 Feb 2012 14:47:30 +0400, Dmitry Kurochkin <dmitry.kurochkin at gmail.com> wrote:
> On Fri, 24 Feb 2012 00:09:14 +0100, Pieter Praet <pieter at praet.org> wrote:
> > * emacs/notmuch-show.el
> > 
> >   (notmuch-show-get-messages-ids):
> >     New optional argument ONLY-OPEN.  If non-nil, only return
> >     Message-Id's for messages which are currently visible.
> > 
> >   (notmuch-show-tag-all):
> >     New optional argument IGNORE-VISIBILITY, of which the inverse is
> >     passed as ONLY-OPEN argument to `notmuch-show-get-messages-ids':
> >     If called with a prefix arg, affect *all* messages in the current
> >     buffer.  Otherwise, only change tags of visible messages.
> > 
> >   (notmuch-show-archive-thread):
> >     Update wrt changes to `notmuch-show-tag-all'.
> > 
> > * test/emacs
> > 
> >   - Subtest "notmuch-show: change tags of open messages in current buffer"
> >     is no longer broken.
> > ---
> >  emacs/notmuch-show.el |   28 ++++++++++++++++++++--------
> >  test/emacs            |    1 -
> >  2 files changed, 20 insertions(+), 9 deletions(-)
> > 
> > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> > index 4b37c77..4499fcd 100644
> > --- a/emacs/notmuch-show.el
> > +++ b/emacs/notmuch-show.el
> > @@ -1334,13 +1334,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 (&optional separator)
> > +(defun notmuch-show-get-messages-ids (&optional only-open separator)
> >    "Return a list of Message-Id's of all messages in the current buffer.
> >  
> > +If optional argument ONLY-OPEN is non-nil, only return
> > +Message-Id's for messages which are currently visible.
> > +
> >  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 t
> > +    (notmuch-show-mapc
> > +     `(if only-open (notmuch-show-message-visible-p) t)
> 
> How about changing ONLY-OPEN to a general optional PREDICATE argument
> and pass it as is to `notmuch-show-mapc'?  Please make it the last
> argument.
>

Done.


> Regards,
>   Dmitry
> 
> >       (lambda () (push (notmuch-show-get-message-id) message-ids)))
> >      (if separator
> >  	(mapconcat 'identity message-ids separator)
> > @@ -1628,13 +1632,21 @@ (defun notmuch-show-tag (&optional initial-input)
> >  		      initial-input (notmuch-show-get-message-id))))
> >      (apply 'notmuch-show-tag-message tag-changes)))
> >  
> > -(defun notmuch-show-tag-all (&rest tag-changes)
> > -  "Change tags for all messages in the current thread.
> > +(defun notmuch-show-tag-all (&optional ignore-visibility &rest tag-changes)
> > +  "Change tags of all open messages in the current buffer.
> > +
> > +If optional arg IGNORE-VISIBILITY is non-nil, change tags of
> > +*all* messages in the current buffer, independent of their
> > +visibility.
> >  
> >  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 " or ") tag-changes)
> > -  (notmuch-show-mapc t
> > +  (interactive (cons current-prefix-arg
> > +		     (notmuch-read-tag-changes nil notmuch-show-thread-id)))
> > +  (apply 'notmuch-tag
> > +	 (notmuch-show-get-messages-ids (not ignore-visibility) " or ")
> > +	 tag-changes)
> > +  (notmuch-show-mapc
> > +   `(if ignore-visibility t (notmuch-show-message-visible-p))
> >     (lambda ()
> >       (let* ((current-tags (notmuch-show-get-tags))
> >  	    (new-tags (notmuch-update-tags current-tags tag-changes)))
> > @@ -1719,7 +1731,7 @@ (defun notmuch-show-archive-thread (&optional unarchive)
> >  buffer."
> >    (interactive "P")
> >    (let ((op (if unarchive "+" "-")))
> > -    (notmuch-show-tag-all (concat op "inbox"))))
> > +    (notmuch-show-tag-all t (concat op "inbox"))))
> >  
> >  (defun notmuch-show-archive-thread-then-next ()
> >    "Archive each message in thread, then show next thread from search."
> > diff --git a/test/emacs b/test/emacs
> > index 644ef59..c286ff5 100755
> > --- a/test/emacs
> > +++ b/test/emacs
> > @@ -152,7 +152,6 @@ notmuch tag +"$del_tag" -"$add_tag" -- "$query" # revert tag changes
> >  test_expect_equal "$count_changed" "$count_total" # assert that CHANGED == TOTAL
> >  
> >  test_begin_subtest "notmuch-show: change tags of open messages in current buffer"
> > -test_subtest_known_broken
> >  query="$os_x_darwin_thread"
> >  filter="from:Jiang"
> >  add_tag="notmuch-show-tag-all"
> > -- 
> > 1.7.8.1
> > 


Peace

-- 
Pieter


More information about the notmuch mailing list