On Sat, May 17, 2014 at 11:51:40AM -0700, Kevin J. McCarthy wrote:
> Karl Voit wrote:
> > 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"
> 
> Hi Karl,
> 
> Mutt doesn't attempt to stat the file until after the "editor" process
> exits.  My guess is that your os.rename() command (or some other line in
> the script) is failing and python is aborting.  You may want to take a
> look at https://pthree.org/2011/03/24/hashcash-and-mutt/ for an example
> python wrapper and see if that helps.
> 
I have a bash wrapper for vile (another vi clone, very like vim) which
works fine, it's as follows:-


#!/bin/bash
#
#
# Wrapper script for using vile from mutt
#
fn=$1
#
#
# See if file has long lines
#
ll=`wc -L $fn | sed s#$fn##`
if (($ll > 100))
then
    #
    #
    # Wrap long lines (and include a '> ' at the front of each wrapped section)
    #
    tmp=`mktemp /tmp/vimuttXXXXXXX`
    cp $fn $tmp
    awk '
    /^> /   { if (length($0) > 100)
                {
                    nl = ""
                    n = split($0, ln)
                    for (i = 1; i <= n; ++i)
                    {
                        nl = nl ln[i] " "
                        if (length(nl) > 72)
                        {
                            printf("%s\n", nl)
                            nl = "> "
                        }
                    }
                    printf("%s\n", nl)
                }
                else
                {
                  print
                }
            }
    !/^> / { print }
    ' $tmp >$fn
    rm $tmp
fi
vile -c':set wrapmargin=-72' $fn



-- 
Chris Green

Reply via email to