On Mon, Aug 01, 2022 at 10:40:22AM +1000, raf via Mutt-users wrote: > But if you want this behaviour (despite any ambiguity), > mutt doesn't need to change. You can set the editor > parameter to a script that modifies the quoted reply > to your liking before invoking the real editor. > Something like this perhaps: > > #!/bin/sh > > # Change "> > > blah" quotes to ">>> blah" before editing > > perl -i -e ' > sub requote { my $s = $_[0]; $s =~ s/ >/>/g; $s; } > while (<>) { s/^([> ]+)/requote($1)/e; print; } > ' "$@" > > ${VISUAL:-${EDITOR:-vi}} "$@" > > Note that this script will cope with a mixture like "> >>> > >> blah" > and make it consistent like ">>>>>>> blah". And it won't add a final > space if there isn't one in the input. > > I'm sure there's a better way to do it, but this'll do.
I use vim and have the following vim9script function in my vimrc: | #--------------------------------------------------------------------------- | # fix mail quotes for mutt, e.g. '> >foo' -> '>> foo' | # muttrc: set editor='vim -c ":call FixMailQuotes()"' | # cursor placement only useful if edit_headers is set in mutt | #--------------------------------------------------------------------------- | def g:FixMailQuotes() | # find first body line after headers | var first_body_line = search('^$') + 1 | # compress quote marks | while search('^>[> ]* >', 'w') > 0 | silent! s/> >/>>/e | endwhile | # add space after last '>' if none is present | silent! :%s/^[>]*\zs>\ze[^> ]/> /e | # place cursor at first line of body | cursor(first_body_line, 1) | enddef Not better, but gets along without perl (of course only if you use vim). Quotes are merged and it is ensured that there is a space after the last quote character. '> >> >foo' becomes '>>>> foo') The cursor is set in the first body line after the headers. Yes, this only makes sense if edit_headers is set in mutt. In muttrc one has to set editor like this: | set editor='vim-c ":call FixMailQuotes()"' Maybe this inspires someone. Dennis