Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 9AC646DE1639 for ; Sun, 14 Jun 2015 16:50:00 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.719 X-Spam-Level: X-Spam-Status: No, score=-0.719 tagged_above=-999 required=5 tests=[AWL=0.101, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jUtH6iQPCB9T for ; Sun, 14 Jun 2015 16:49:58 -0700 (PDT) Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com [209.85.212.178]) by arlo.cworth.org (Postfix) with ESMTPS id 6914A6DE15E3 for ; Sun, 14 Jun 2015 16:49:58 -0700 (PDT) Received: by wicnd19 with SMTP id nd19so9676108wic.1 for ; Sun, 14 Jun 2015 16:49:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:subject:message-id:mail-followup-to:references :mime-version:content-type:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=SA94LCKxYF9hO//cGD2m1h2e51FcH4zSo61BLYzvLJE=; b=L8yRAMCpYeCg+1DSW7osrG0YVtQo8r+fYP1f2bjQURGuKaGbVJpFj4eSzZ+Rha8VcH xz3VDrmULu2ys0Lwz6zBme+AVwz66l0Gu/ULgNd5RZ3GtjpN5dtAUWHxDhoUcSFYlEls jZzAutXS05T5hcSqBbKBDaDYo9iErbXSGb96yXoTsxhHkSpyNfe/+OyBJnx9gtzzQVnh Kf8C9SOIyIuKWF5cg15hS8tmY7QDGwUKhqdyOlxZeDLvlkR9rugxjHn/s/Jp3OuFXBD9 rox9CjH8hGsrcRHSFtAtbP6FxfJs846Ckx7DvkF4apFyRJZd0d9QHb+5b6itgqMoOaid vWmw== X-Received: by 10.181.11.129 with SMTP id ei1mr25959048wid.90.1434325795112; Sun, 14 Jun 2015 16:49:55 -0700 (PDT) Received: from chitra.no-ip.org (ip82-139-115-46.lijbrandt.net. [82.139.115.46]) by mx.google.com with ESMTPSA id c3sm16322989wja.3.2015.06.14.16.49.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Jun 2015 16:49:54 -0700 (PDT) Sender: Suvayu Ali Date: Mon, 15 Jun 2015 01:49:52 +0200 From: Suvayu Ali To: notmuch@notmuchmail.org Subject: Re: search query "replytoid:" Message-ID: <20150614234952.GA4315@chitra.no-ip.org> Mail-Followup-To: notmuch@notmuchmail.org References: <20150613205552.GC17381@chitra.no-ip.org> <20150614082258.GD17381@chitra.no-ip.org> <20150614223057.GB21261@boo.workgroup> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20150614223057.GB21261@boo.workgroup> User-Agent: Mutt/1.5.23.1 (2014-03-12) X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Jun 2015 23:50:00 -0000 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.