[PATCH] test/crypto: remove headers more robustly

David Bremner david at tethera.net
Sun Sep 3 04:13:50 PDT 2017


Tomi Ollila <tomi.ollila at iki.fi> 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


More information about the notmuch mailing list