search query "replytoid:<blah>"

Suvayu Ali fatkasuvayu+linux at gmail.com
Sun Jun 14 16:49:52 PDT 2015


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


More information about the notmuch mailing list