Hi, You should include a reference to the original message, not everyone will remember the thread. id:20150614082258.GD17381@chitra.no-ip.org or <http://mid.gmane.org/20150614082258.GD17381@chitra.no-ip.org> On Sun, Sep 13, 2015 at 12:03:20AM -0400, Xu Wang wrote: > > Sometimes I need to do: > > $ notmuch search --output=threads "id:MYMSGID" > thread:000000000000a125 > $ notmuch search --output=messages "thread:000000000000a125" Looking at the script again, I see I assumed a message will belong to a single thread. You can remove that assumption by applying the following change. -----8<--------------------8<----- diff -u nm-ack nm-ack --- nm-ack 2015-06-15 01:30:40.327556510 +0200 +++ nm-ack 2015-09-13 07:58:30.734096931 +0200 @@ -10,8 +10,9 @@ # debug # set -o xtrace -declare query="$1" thread=$(notmuch search --output=threads -- "$1") -declare -a msgs=$(notmuch search --output=messages -- "$thread") responses +declare query="$1" +declare -a thread=$(notmuch search --output=threads -- "$1") +declare -a msgs=$(notmuch search --output=messages -- "${thread[@]}") responses function strip_mid() { sed -e 's/ \+//g' -e 's/<\([^ <>]\+\)>/\1/g' ----->8-------------------->8----- > In theory, this should output the message that responded to message ID > "MYMSGID". Sometimes it works. But sometimes it does not work. That > is, there exists an email where I am sure (I checked the raw email) > that there is a header > In-Reply-To: <MYMSGID> > but that email does not show when I do the two commands above. > Indeed, that mail belongs to a different thread ID. > > I am just curious if the above is due to: > > 1. My missing of understanding of how notmuch deals with threads > 2. A bug or missing feature in notmuch causes some threads to be incomplete Interesting issue. I can think of a case, say a message is cross-posted to multiple lists, it might then give you more than one thread ids. Is this the case for your message? If you are up for it, look in lib/thread.cc. I think the relevant methods are: _resolve_thread_relationships and _notmuch_thread_create, but I could be wrong. I'm not familiar with the notmuch source. As I recall, you are using mutt-kz; does <entire-thread> work from mutt-kz? I would expect that to fail too. It gets the thread id like this: id = notmuch_message_get_thread_id(msg); Hope this helps, -- Suvayu Open source is the future. It sets us free.