From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 9FB186DE0314 for ; Sun, 3 Sep 2017 04:14:04 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.001 X-Spam-Level: X-Spam-Status: No, score=-0.001 tagged_above=-999 required=5 tests=[AWL=0.010, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] 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 K_4LMVMBqWfx for ; Sun, 3 Sep 2017 04:14:00 -0700 (PDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id D18976DE0164 for ; Sun, 3 Sep 2017 04:13:59 -0700 (PDT) Received: from remotemail by fethera.tethera.net with local (Exim 4.89) (envelope-from ) id 1doSn8-0006aB-7F; Sun, 03 Sep 2017 07:10:14 -0400 Received: (nullmailer pid 28508 invoked by uid 1000); Sun, 03 Sep 2017 11:13:50 -0000 From: David Bremner To: Tomi Ollila , Vladimir Panteleev , notmuch@notmuchmail.org Subject: Re: [PATCH] test/crypto: remove headers more robustly In-Reply-To: References: <20170817175145.3204-7-notmuch@thecybershadow.net> <20170902001119.15318-1-david@tethera.net> Date: Sun, 03 Sep 2017 08:13:50 -0300 Message-ID: <87a82cyqz5.fsf@tethera.net> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.23 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, 03 Sep 2017 11:14:04 -0000 Tomi Ollila writes: > On Fri, Sep 01 2017, David Bremner wrote: > >> In [1], Vladimir Panteleev observed that the In-Reply-To and >> References headers could be wrapped in the 'default' output format of >> notmuch-reply, depending on the version of Emacs creating the >> message. In my own experiments notmuch-reply sometimes wraps headers >> with only one message-id if that message-id is long enough. However it >> happens, this causes the previous approach using grep to fail. > > we could (also) make emacs think it has wider than 80 characters to fit on > one line... > >> Since I found the proposed unwrapping shell fragment in [1] a bit hard >> to follow, I decided to write a little python script instead. > > There was nothing hard in that shell construct ;), but I also thought some > alternative solutions (one in awk and one in perl) > > How 'bout > > drop_email_headers () > { > $NOTMUCH_PYTHON -c 'import email, sys > msg = email.message_from_file(sys.stdin) > for hdr in sys.argv: msg.pop(hdr, None) > print(msg.as_string(False))' > } > > and then ... | drop_email_headers In-Reply-To References I pushed something like this. 'pop' doesn't seem to exist? Also I needed to pass $* in to the python script. Maybe that should be "${@}", but there really should not be spaces in header names. d