[PATCH 8/6] emacs: use message ids instead of thread id in `notmuch-show-operate-all'

Dmitry Kurochkin dmitry.kurochkin at gmail.com
Sat Jan 28 01:42:06 PST 2012


Hi Jani.

On Sat, 28 Jan 2012 11:09:45 +0200, Jani Nikula <jani at nikula.org> wrote:
> I guess this now includes the optimization of doing the tagging in a single
> call to notmuch tag. (As opposed to calling it once per msg like it used to
> be a while back.)

This patch changes the code which was added few patches earlier in the
series.  And rational for it is not an optimization but a bug fix as
described in the preamble.

> There was some discussion about the cmdline length for
> large threads potentially growing too big when I sent such an optimization
> patch, shall we just ignore that and hope for the best?

Sorry, I think I did not read that discussion in details.  I have never
hit this issue.  So, for now, I do not care about it.

Notmuch-search range tagging works in a similar way, constructing search
string of OR'ed thread ids.  So the patch is consistent with the
existing code.

> I guess an idea was
> to limit to, say, a few hundred msg ids per command. (Again, sorry I can't
> look up the earlier thread now.)
> 

That may be a solution.  Though, I think it should rely on system's
command line limit instead of magic constants.

Anyway, this problem is out of scope of this patch series.  Currently,
neither notmuch-search region tagging code nor the proposed patch try to
solve the issue.  If and when a proper solution is found, we should
implement it for both (or probably more) cases (provided this patch gets
accepted).

Regards,
  Dmitry

> On Jan 28, 2012 8:00 AM, "Dmitry Kurochkin" <dmitry.kurochkin at gmail.com>
> wrote:
> >
> > Before the change, `notmuch-show-operate-all' used thread id for
> > "notmuch tag" search.  This could result in tagging unexpected
> > messages that were added to the thread after the notmuch-show buffer
> > was created.  The patch changes `notmuch-show-operate-all' to use ids
> > of shown messages to fix this.
> > ---
> >  emacs/notmuch-show.el |   23 ++++++++++++++++++++++-
> >  1 files changed, 22 insertions(+), 1 deletions(-)
> >
> > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> > index 2ca4d92..e606224 100644
> > --- a/emacs/notmuch-show.el
> > +++ b/emacs/notmuch-show.el
> > @@ -1170,6 +1170,15 @@ All currently available key bindings:
> >     (notmuch-show-move-to-message-top)
> >     t))
> >
> > +(defun notmuch-show-mapc (function)
> > +  "Iterate through all messages with
> > +`notmuch-show-goto-message-next' and call `function' for side
> > +effects."
> > +  (save-excursion
> > +    (goto-char (point-min))
> > +    (loop do (funcall function)
> > +         while (notmuch-show-goto-message-next))))
> > +
> >  ;; Functions relating to the visibility of messages and their
> >  ;; components.
> >
> > @@ -1222,6 +1231,18 @@ Some useful entries are:
> >   "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 currently shown messages."
> > +  (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 currently shown
> > +messages."
> > +  (mapconcat 'identity (notmuch-show-get-messages-ids) " or "))
> > +
> >  ;; dme: Would it make sense to use a macro for many of these?
> >
> >  (defun notmuch-show-get-filename ()
> > @@ -1496,7 +1517,7 @@ i.e. a list of tags to change with '+' and '-'
> prefixes."
> >  `Changed-tags' is a list of tag operations for \"notmuch tag\",
> >  i.e. a list of tags to change with '+' and '-' prefixes."
> >   (interactive (notmuch-select-tags-with-completion nil
> notmuch-show-thread-id))
> > -  (apply 'notmuch-tag notmuch-show-thread-id changed-tags)
> > +  (apply 'notmuch-tag (notmuch-show-get-messages-ids-search)
> changed-tags)
> >   (save-excursion
> >     (goto-char (point-min))
> >     (loop do (let* ((current-tags (notmuch-show-get-tags))
> > --
> > 1.7.8.3
> >
> > _______________________________________________
> > notmuch mailing list
> > notmuch at notmuchmail.org
> > http://notmuchmail.org/mailman/listinfo/notmuch
Non-text part: text/html


More information about the notmuch mailing list