also sprach Kyle Wheeler <kyle-mutt@xxxxxxxxxxxxxx> [2007.08.28.2158 +0200]:
> you just got really lucky). The way mutt determines whether a file is
> modified is by comparing the mtime of the temp file it created to the
> mtime of the temp file once the editor is done editing. The mtime is
> stored in seconds. Sed, of course, executes in less than a second, so
> the mtime is unchanged in all but the rarest of cases.
Perfect explanation, thanks Kyle!
> It would work if you'd piped it to a script like this:
You don't even need an editor:
set editor="sleep 1 && sed -i -e ..."
works just as well. On that note, however, you probably want formail
instead, due to multiline headers, but formail cannot edit in-place.
Thus, you'll need a script. :(
Or well, maybe not. The following sed -rn snippet extracts
a multiline header (name stored in $1):
:s;/^\$/q;/${1}/bj;d;:j;P;\$!n;/^[[:space:]]/bj;bs
It should not be too hard to come up with a sed recipe that replaces
the subject. My first try failed though (again, with -re):
":s;/^$/be;/^Subject:/bj;P;:j;n;/^[[:space:]]/bj;=;bs;:e;p;:e2;n;p;be2"
This correctly removes the subject. Where the = is, I wanted to
insert a new Subject line:
":s;/^$/be;/^Subject:/bj;P;:j;n;/^[[:space:]]/bj;iSubject: new" -e
"bs;:e;p;:e2;n;p;be2"
but for some reason, that gets called after *every* header. And yet,
the script should never reach that except after encountering
/^Subject:/ in the header, when it spins in the j loop until the
next header is found. *Then* and only then should it insert the
Subject. I am not a sed guru, so if anyone has a clue, please let me
know.
--
martin; (greetings from the heart of the sun.)
\____ echo mailto: !#^."<*>"|tr "<*> mailto:" net@madduck
this message represents the official view of the voices in my head.
spamtraps: madduck.bogus@xxxxxxxxxxx
Attachment:
digital_signature_gpg.asc
Description: Digital signature (see http://martin-krafft.net/gpg/)