Hi!
For a works-for-me-hack[1], I need to write a Python wrapper-script
for the editor (vim at my side).
The wrapper basically parses the temporary file which was created by
mutt (muttfilename), creates a new temporary file with modified
content (TMPFILENAME), and currently tries to replace muttfilename
with TMPFILENAME by deleting and renaming:
[...]
log.write('re-wrote email to TMPFILENAME\n')
assert(os.path.isfile(muttfilename))
assert(os.path.isfile(TMPFILENAME))
os.remove(muttfilename)
log.write('removed muttfilename; renaming TMPFILENAME to muttfilename
...\n')
os.rename(TMPFILENAME, muttfilename) ## <-- here, mutt does take over
again!!! :-(
log.write('renamed TMPFILENAME to muttfilename\n') ## <-- does not get into
log any more
assert(os.path.isfile(muttfilename))
assert(os.path.isfile(TMPFILENAME) == False)
log.write('calling EDITOR ...\n')
call([EDITOR, muttfilename])
[...]
After renaming, I want to invoke my editor, make my manual changes
to the email body and after quitting the editor, mutt should take
over again.
However, when I rename TMPFILENAME to muttfilename, mutt takes over
the process again. This skips the editor part completely. Mutt
complains that the muttfilename is missing:
"Can't stat /tmp/mutt-grmlvrs-1002-5074-359: No such file or
directory"
This way, the message file is lost entirely.
So: how do I accomplish my wrapper so that mutt takes over again
after the editor quits and not before? How can I replace the content
of the mutt-temp-file before my editor without letting mutt taking
over in-between?
Thanks for your help!
[1] Yes, you are tempted to question my hack-approach - I would.
Please don't because I really tried to do the stuff using mutt hooks
and unfortunately this does not work at all because of the
complexity of the stuff I need to do in background as well. Please
let's assume, that there is no other way than to write a
wrapper-script in Python. :-)
--
Karl Voit