Re: changing the subject line of a thread
On Wednesday, 29 August 2007 at 08:57, Gary Johnson wrote:
> On 2007-08-29, Holger Weiss <lists@xxxxxxxxxx> wrote:
> > * Kyle Wheeler <kyle-mutt@xxxxxxxxxxxxxx> [2007-08-28 13:58]:
> > > HEH. This *would* work, if you were on a much slower machine (or if
> > > 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. It would work
> > > if you'd piped it to a script like this:
> > >
> > > #!/bin/sh
> > > sleep 1
> > > sed -i -e '/./d' "$1"
> > >
> > > Because then the mtime would be guaranteed (more or less) to be
> > > different from when mutt created the tmp file.
> >
> > I worked around the same problem in some $editor script by incrementing
> > the mtime via touch(1) as I didn't want the script to sleep(1).
> >
> > I guess it would be nice if Mutt (optionally?) used the MD5 sum or
> > something instead of the mtime to check whether a file is modified.
>
> I was surprised by Kyle's comment because I thought mutt already did
> this, so I looked in the code. It turns out that mutt _sometimes_
> does this. In the mutt_edit_headers() and ci_send_message()
> functions, mutt sets the mtime of the temporary file back one second
> before invoking the editor so that even if the editing occurs
> instantaneously, the mtime will be different after editing. Mutt
> then checks the mtime after invoking the editor to see if the file
> changed.
>
> Oddly, mutt does not do this in the edit_one_message() function
> which I think is the one being used in this case. I think this
> should be fixed. If folks agree and unless someone else wants to go
> for it, I can submit a patch.
That sounds like a good idea. But it would probably be good to set the
mtime back to its original time after editing if the message isn't
modified.