[PATCH 6/8] cli: add support for batch tagging operations to "notmuch tag"

Jani Nikula jani at nikula.org
Mon Apr 2 12:46:15 PDT 2012

Jameson Graef Rollins <jrollins at finestructure.net> writes:

> On Sat, Mar 31 2012, Jani Nikula <jani at nikula.org> wrote:
>> Add support for batch tagging operations through stdin to "notmuch
>> tag". This can be enabled with the new --stdin command line option to
>> "notmuch new". The input must consist of lines of the format:
>> T +<tag>|-<tag> [...] [--] <search-terms>
> Hey, Jani.  I can understand why you're going for this form, since it
> mimics the command line arguments for tag and you want to be able to tag
> for arbitrary searches, but I must say that I find it unappealing that
> this functionality is *so* similar to that of notmuch restore, but the
> file format is totally different.  Can't we unify all of this in a
> better way?

Hi Jameson -

Thanks for your comments. The intent is to converge notmuch tag and
restore file formats, and reuse the code between them. The above is the
proposed format for both, but I see that I failed to mention the future

This actually started from David's dump/restore rework [1]. I wanted to
have batch tagging, and realized his proposed format wouldn't work for
that. There was some discussion about this on IRC, and we settled on the
above format as a starting point. And now would be the time to comment
on the format, if you have any issues with it! ;)

> This patch series seems to beg that we actually just unify the tag and
> restore functions in to one thing.  They're really just doing the same
> thing.  If we extended restore to accept a search-term instead of a
> message id they would in fact be identical.
> The more I think about it the more it makes sense to me that we just
> merge tag and restore, and extend the input file format to be able to
> accept search terms.  It just doesn't make sense to have these two
> interfaces that do basically the exact same thing but in a slightly
> divergent way.

I totally agree on this goal. The dump/restore follow-up part is a
work-in-progress in my local tree. At least initially, the format would
be the same for tag and restore, but with the following subtle

1) notmuch restore will only accept an id:message-id style query to be
   able to warn about messages present in the dump file but missing in
   the database. This is because dump/restore is primarily a
   backup/restore style operation.

2) Partly because of the above, and partly because of notmuch restore
   --accumulate vs. not, the query/tagging optimizations will have to be

The rough idea is that both notmuch tag and restore would use the same
file parsing (tag_file() introduced in this series), but notmuch tag
would use tag_query() in notmuch-tag.c for tagging, and notmuch restore
would use tag_message() in notmuch-restore.c for tagging.

> and btw, according to comments in the code 'T' is supposed to stand for
> the action, "tag" in this case.  What other actions do you imagine?

This was actually David's idea. It allows extensibility in the format.

Thanks again for your interest, and sorry about not opening up the
future plans up front.


[1] id:"1324214111-32079-1-git-send-email-david at tethera.net"

More information about the notmuch mailing list