unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Mark Walters <markwalters1009@gmail.com>
To: Austin Clements <amdragon@MIT.EDU>, Aaron Ecay <aaronecay@gmail.com>
Cc: notmuch@notmuchmail.org
Subject: Re: [PATCH] emacs: call "notmuch tag" only once when archiving a thread
Date: Mon, 09 Jan 2012 11:31:21 +0000	[thread overview]
Message-ID: <87wr91f6ye.fsf@qmul.ac.uk> (raw)
In-Reply-To: <20120109011259.GD20796@mit.edu>


> There's been quite a bit of discussion on fixing this properly.  See,
> for example
> id:"CAH-f9WsPj=1Eu=g3sOePJgCTBFs6HrLdLq18xMEnJ8aZ00yCEg@mail.gmail.com".
> The gist is that we need to include message IDs (or document IDs) in
> the search output and use these in tagging operations, rather than the
> unstable thread:XXX queries.  Unfortunately, actually fixing this got
> stalled since adding this information the text format is a fool's
> errand (having been the fool, I can say this!), so we need to switch
> Emacs over to using the JSON search format first.  However, once
> that's done, it's a relatively simple change.

I will just mention a different possible solution to this problem. I
think it is probably more hassle than its worth but just in case someone
sees how to do it nicely. 

The idea is to try and put the race-free solution into the command-line
notmuch rather than the emacs part.

I will just consider one race to start with: the race in notmuch
search/notmuch tag. notmuch search gives us just the thread-ids and what
is in that thread can change. So we could ask for a "cookie" (some short
unique identifier) and notmuch itself would store the state of its
output (i.e., the thread-ids together with the message-ids and the
matched message-ids).

Then notmuch tag could be called with this cookie to say "apply this tag
to the threads as they were at cookie.

example use
notmuch search --cookie <query>
prints a cookie followed by the output of the search

notmuch tag --cookie=cookievalue +sometag matched-thread:id .. \
                                 all-thread:id .. <other search terms>

and notmuch would replace the matched-thread:id by the (matching)
message-ids in thread it stored at time cookievalue and all-thread by
all the messages at time cookievalue.

The nice feature is that this makes it easy for all clients to be race
free (not just emacs). The backend has the information to hand: there is
no encoding and decoding (via text or JSON) so storing message-ids etc
is simpler.  It also means that if notmuch wants to use document-ids
internally it can: it does not become a public interface.

The downside is trying to do the argument parsing in c and we have do
some reference counting or something to delete the cookies state at some
point.

Anyway it's just a thought.

Best wishes

Mark

      parent reply	other threads:[~2012-01-09 11:31 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-03 18:29 [PATCH] emacs: call "notmuch tag" only once when archiving a thread Jani Nikula
2012-01-04 14:13 ` David Edmondson
2012-01-04 14:35 ` Tomi Ollila
2012-01-05 20:10 ` Aaron Ecay
2012-01-05 20:32   ` Jani Nikula
2012-01-05 20:38     ` Jameson Graef Rollins
2012-01-05 20:58       ` Jani Nikula
2012-01-06 21:31         ` Tomi Ollila
2012-01-09  0:56     ` Aaron Ecay
2012-01-09  1:12       ` Austin Clements
2012-01-09  8:15         ` David Edmondson
2012-01-09  8:41         ` Jani Nikula
2012-01-09 10:38           ` Tomi Ollila
2012-01-09 10:46             ` David Edmondson
2012-01-09 11:31         ` Mark Walters [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wr91f6ye.fsf@qmul.ac.uk \
    --to=markwalters1009@gmail.com \
    --cc=aaronecay@gmail.com \
    --cc=amdragon@MIT.EDU \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).