unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* search query "replytoid:<blah>"
@ 2015-06-13 18:47 Xu Wang
  2015-06-13 20:55 ` Suvayu Ali
  2015-06-13 21:14 ` David Bremner
  0 siblings, 2 replies; 9+ messages in thread
From: Xu Wang @ 2015-06-13 18:47 UTC (permalink / raw)
  To: notmuch

Dear all,

Is it possible to search based on which message ID a message
*responds* to? For example, suppose message id is MESSAGEID. I want to
find all emails that responded to MESSAGEID. How to enter such a query
into notmuch?

Kind regards,

Xu

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: search query "replytoid:<blah>"
  2015-06-13 18:47 search query "replytoid:<blah>" Xu Wang
@ 2015-06-13 20:55 ` Suvayu Ali
  2015-06-14  8:22   ` Suvayu Ali
  2015-06-13 21:14 ` David Bremner
  1 sibling, 1 reply; 9+ messages in thread
From: Suvayu Ali @ 2015-06-13 20:55 UTC (permalink / raw)
  To: notmuch

Hi,

On Sat, Jun 13, 2015 at 02:47:00PM -0400, Xu Wang wrote:
> 
> Is it possible to search based on which message ID a message
> *responds* to? For example, suppose message id is MESSAGEID. I want to
> find all emails that responded to MESSAGEID. How to enter such a query
> into notmuch?

AFAIK, this is not possible.  Notmuch does not allow searching special
headers.  You could probably write a script using the threads output
format to get the thread, and then use formail to find the responses.

I however think you are probably approaching the problem incorrectly,
but that's just a guess.  More information about what is your goal and
why, would help.  Maybe there is another way to achieve what you want to
achieve.

Hope this helps,

-- 
Suvayu

Open source is the future. It sets us free.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: search query "replytoid:<blah>"
  2015-06-13 18:47 search query "replytoid:<blah>" Xu Wang
  2015-06-13 20:55 ` Suvayu Ali
@ 2015-06-13 21:14 ` David Bremner
  2015-06-14  3:56   ` Xu Wang
  1 sibling, 1 reply; 9+ messages in thread
From: David Bremner @ 2015-06-13 21:14 UTC (permalink / raw)
  To: Xu Wang, notmuch

Xu Wang <xuwang762@gmail.com> writes:

> Dear all,
>
> Is it possible to search based on which message ID a message
> *responds* to? For example, suppose message id is MESSAGEID. I want to
> find all emails that responded to MESSAGEID. How to enter such a query
> into notmuch?

Threads aren't exactly the concept you ask for, because the include the
messages before the message-id in question as well. Nonetheless, maybe
the following helps:


% notmuch show $(notmuch search --output=threads $MESAGEID)

or

% notmuch search --output=messages $(notmuch search --output=threads $MESAGEID)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: search query "replytoid:<blah>"
  2015-06-13 21:14 ` David Bremner
@ 2015-06-14  3:56   ` Xu Wang
  2015-06-14  5:43     ` David Bremner
  0 siblings, 1 reply; 9+ messages in thread
From: Xu Wang @ 2015-06-14  3:56 UTC (permalink / raw)
  To: notmuch

On Sat, Jun 13, 2015 at 5:14 PM, David Bremner <david@tethera.net> wrote:
> Xu Wang <xuwang762@gmail.com> writes:
>
>> Dear all,
>>
>> Is it possible to search based on which message ID a message
>> *responds* to? For example, suppose message id is MESSAGEID. I want to
>> find all emails that responded to MESSAGEID. How to enter such a query
>> into notmuch?
>
> Threads aren't exactly the concept you ask for, because the include the
> messages before the message-id in question as well. Nonetheless, maybe
> the following helps:
>
>
> % notmuch show $(notmuch search --output=threads $MESAGEID)
>
> or
>
> % notmuch search --output=messages $(notmuch search --output=threads $MESAGEID)

Dear David and Suvayu,

Thank you for your ideas. My goal is to do something like the following:
notmuch search tag:reply-required and not tag:replied

which was discussed here:
http://notmuchmail.org/pipermail/notmuch/2010/002558.html

However, instead of conditioning on tag:reply-required, I would like
to look at this for a specific message. For example, if I write an
important message, I can do the following:
save the message id, and then in 5 days set a cron script to check
whether my message was responded to. If it was not responded to I will
take some action to notify myself (haven't decided what yet).
It is the "If it was not responded to" part that this email thread is
about. I am now realizing that I cannot use mutt's tag "replied"
because I often send and read email from gmail or other IMap clients
(e.g. phone). Because of this (I believe), the reply tag does not get
set when it should (well not "should" but rather "when I want it to").
For example, I often have

abc
->def
  -> ghi

where the message def does not have the "replied" tag, even though it
was replied to (ghi replied to it). I think the reason is what I
suggested above.

Because I cannot use the "replied" tag (unless I have misunderstood),
I thought I could just check using the message id with 'notmuch search
repliedto:<messageid>', but Suvayu points out that searching for this
is not supported.

Kind regards,

Xu

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: search query "replytoid:<blah>"
  2015-06-14  3:56   ` Xu Wang
@ 2015-06-14  5:43     ` David Bremner
  0 siblings, 0 replies; 9+ messages in thread
From: David Bremner @ 2015-06-14  5:43 UTC (permalink / raw)
  To: Xu Wang, notmuch

Xu Wang <xuwang762@gmail.com> writes:

> Dear David and Suvayu,
>
> Thank you for your ideas. My goal is to do something like the following:
> notmuch search tag:reply-required and not tag:replied
>
> which was discussed here:
> http://notmuchmail.org/pipermail/notmuch/2010/002558.html
>

This recent blog report looks related to your goal:

https://tomasz.buchert.pl/blog/2015/06/14/notmuch-response/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: search query "replytoid:<blah>"
  2015-06-13 20:55 ` Suvayu Ali
@ 2015-06-14  8:22   ` Suvayu Ali
  2015-06-14 18:32     ` Xu Wang
  2015-06-14 22:30     ` Gregor Zattler
  0 siblings, 2 replies; 9+ messages in thread
From: Suvayu Ali @ 2015-06-14  8:22 UTC (permalink / raw)
  To: notmuch

[-- Attachment #1: Type: text/plain, Size: 998 bytes --]

On Sat, Jun 13, 2015 at 10:55:52PM +0200, Suvayu Ali wrote:
> On Sat, Jun 13, 2015 at 02:47:00PM -0400, Xu Wang wrote:
> > 
> > Is it possible to search based on which message ID a message
> > *responds* to? For example, suppose message id is MESSAGEID. I want to
> > find all emails that responded to MESSAGEID. How to enter such a query
> > into notmuch?
> 
> AFAIK, this is not possible.  Notmuch does not allow searching special
> headers.  You could probably write a script using the threads output
> format to get the thread, and then use formail to find the responses.

Try the attached script.  It accepts notmuch queries by message id.
E.g. to get the responses to your OP, you can do:

  $ ./nm-ack id:CAJhTkNhYew6H-bptACTew3gN3DLWg6agTYu8hAkdwFS=z4VFWg@mail.gmail.com
  id:877fr79upd.fsf@maritornes.cs.unb.ca id:20150613205552.GC17381@chitra.no-ip.org

The first one is David's response, the second one is mine.

Hope this helps,

-- 
Suvayu

Open source is the future. It sets us free.

[-- Attachment #2: nm-ack --]
[-- Type: text/plain, Size: 583 bytes --]

#!/bin/bash

# Return responses to message id query
#
# $ nm-ack id:msgid@domain
# id:response1@domain1 id:response2@domain2 ...
#
# Author: Suvayu Ali

# debug
# set -o xtrace

declare query="$1" thread=$(notmuch search --output=threads -- "$1")
declare -a msgs=$(notmuch search --output=messages -- "$thread") responses

function strip_mid() {
    sed -e 's/[<> ]//g'
}

for m in ${msgs[@]}; do
    [[ $query == $m ]] && continue
    r=id:$(notmuch show --format=raw -- $m | formail -x In-Reply-To: | strip_mid)
    [[ $query == $r ]] && responses+=($m)
done

echo ${responses[@]}

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: search query "replytoid:<blah>"
  2015-06-14  8:22   ` Suvayu Ali
@ 2015-06-14 18:32     ` Xu Wang
  2015-06-14 22:30     ` Gregor Zattler
  1 sibling, 0 replies; 9+ messages in thread
From: Xu Wang @ 2015-06-14 18:32 UTC (permalink / raw)
  To: notmuch

On Sun, Jun 14, 2015 at 4:22 AM, Suvayu Ali <fatkasuvayu+linux@gmail.com> wrote:
> On Sat, Jun 13, 2015 at 10:55:52PM +0200, Suvayu Ali wrote:
>> On Sat, Jun 13, 2015 at 02:47:00PM -0400, Xu Wang wrote:
>> >
>> > Is it possible to search based on which message ID a message
>> > *responds* to? For example, suppose message id is MESSAGEID. I want to
>> > find all emails that responded to MESSAGEID. How to enter such a query
>> > into notmuch?
>>
>> AFAIK, this is not possible.  Notmuch does not allow searching special
>> headers.  You could probably write a script using the threads output
>> format to get the thread, and then use formail to find the responses.
>
> Try the attached script.  It accepts notmuch queries by message id.
> E.g. to get the responses to your OP, you can do:
>
>   $ ./nm-ack id:CAJhTkNhYew6H-bptACTew3gN3DLWg6agTYu8hAkdwFS=z4VFWg@mail.gmail.com
>   id:877fr79upd.fsf@maritornes.cs.unb.ca id:20150613205552.GC17381@chitra.no-ip.org
>
> The first one is David's response, the second one is mine.
>
> Hope this helps,
>
> --
> Suvayu

These are exactly what I was looking for! I tried Suvayu's script with
success, and although I did not try the script referenced by David's
email, the goal is exactly my goal and thus it seems it should do as I
would like as well.

Thank you so very much to you for persisting in helping me, even
despite the lack of clarity in my messages. I highly appreciate you
and your time.

Happy regards,

Xu

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: search query "replytoid:<blah>"
  2015-06-14  8:22   ` Suvayu Ali
  2015-06-14 18:32     ` Xu Wang
@ 2015-06-14 22:30     ` Gregor Zattler
  2015-06-14 23:49       ` Suvayu Ali
  1 sibling, 1 reply; 9+ messages in thread
From: Gregor Zattler @ 2015-06-14 22:30 UTC (permalink / raw)
  To: notmuch

Hi Suvayu, notmuch users and developers,
* Suvayu Ali <fatkasuvayu+linux@gmail.com> [14. Jun. 2015]:
> Try the attached script.  It accepts notmuch queries by message id.
> E.g. to get the responses to your OP, you can do:
> 
>   $ ./nm-ack id:CAJhTkNhYew6H-bptACTew3gN3DLWg6agTYu8hAkdwFS=z4VFWg@mail.gmail.com
>   id:877fr79upd.fsf@maritornes.cs.unb.ca id:20150613205552.GC17381@chitra.no-ip.org
> 
> The first one is David's response, the second one is mine.

This is a nice script.  The very first Message(-Id:) I tried was
replied to by a message with this In-Reply-To: header:

        In-Reply-To: <7e093509.51e.14ddb300091.Coremail.chxp_moon@163.com> (windy’s
               message of „Wed, 10 Jun 2015 09:57:45 +0800 (CST)“)

Since the script extracts Message-Id:s from In-Reply-To; headers via

> function strip_mid() {
>     sed -e 's/[<> ]//g'
> }

the Message-Id:s did not match.  I therefore changed this to

function strip_mid() {
    egrep  -a -o "<[^[:space:]<>]+@[^@[:space:]<>]+>"|sed -e 's/[<> ]//g'
}

this did the trick.


Thanx, Gregor
-- 
 -... --- .-. . -.. ..--.. ...-.-

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: search query "replytoid:<blah>"
  2015-06-14 22:30     ` Gregor Zattler
@ 2015-06-14 23:49       ` Suvayu Ali
  0 siblings, 0 replies; 9+ messages in thread
From: Suvayu Ali @ 2015-06-14 23:49 UTC (permalink / raw)
  To: notmuch

Hi,

On Mon, Jun 15, 2015 at 12:30:57AM +0200, Gregor Zattler wrote:
> 
> This is a nice script.  The very first Message(-Id:) I tried was
> replied to by a message with this In-Reply-To: header:
> 
>         In-Reply-To: <7e093509.51e.14ddb300091.Coremail.chxp_moon@163.com> (windy’s
>                message of „Wed, 10 Jun 2015 09:57:45 +0800 (CST)“)
> 
> Since the script extracts Message-Id:s from In-Reply-To; headers via
> 
> > function strip_mid() {
> >     sed -e 's/[<> ]//g'
> > }
> 
> the Message-Id:s did not match.  I therefore changed this to
> 
> function strip_mid() {
>     egrep  -a -o "<[^[:space:]<>]+@[^@[:space:]<>]+>"|sed -e 's/[<> ]//g'
> }

It was a quick hack.  In fact, there is another limitation.  IIRC, I
think the In-Reply-To header can have multiple Message-Id-s.  That is
not handled at all!  

The correct logic to get the ids should probably be something that picks
out the content inside angular brackets, but non-greedily.  Note that,
the allowance of characters inside Message-ID-s is rather liberal.  I
think it can be anything other than whitespace or angular brackets.
What you do above is probably very close, but still not general enough.
In fact, I think the foo@domain structure you require is not mandatory!
In my opinion, one should use an email handling library, or better yet
use the python bindings.

For the sake of completeness, here is a pure sed solution:

  function strip_mid() {
      sed -e 's/ \+//g' -e 's/<\([^ <>]\+\)>/\1/g'
  }

;)

-- 
Suvayu

Open source is the future. It sets us free.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-06-14 23:50 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-13 18:47 search query "replytoid:<blah>" Xu Wang
2015-06-13 20:55 ` Suvayu Ali
2015-06-14  8:22   ` Suvayu Ali
2015-06-14 18:32     ` Xu Wang
2015-06-14 22:30     ` Gregor Zattler
2015-06-14 23:49       ` Suvayu Ali
2015-06-13 21:14 ` David Bremner
2015-06-14  3:56   ` Xu Wang
2015-06-14  5:43     ` David Bremner

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).