# HG changeset patch # User Meredith Howard # Date 1476075355 14400 # Node ID 1bb7fe33cd7462b3f954a488c6ef9d5fc76b8857 # Parent 7f1e71910dc69aa846998167812e5e89ee95b49e Add previous sig removal diff --git a/.vim/ftplugin/mail.vim b/.vim/ftplugin/mail.vim --- a/.vim/ftplugin/mail.vim +++ b/.vim/ftplugin/mail.vim @@ -2,6 +2,35 @@ setl textwidth=72 setl formatoptions=jaw12tcql setl spell +" http://cedricduval.free.fr/download/mail.vim +function! Mail_Erase_Sig() + " search for the signature pattern (takes into account signature delimiters + " from broken mailers that forget the space after the two dashes) + let i = 0 + while ((i <= line('$')) && (getline(i) !~ '^> *-- \=$')) + let i = i + 1 + endwhile + + " if found, then + if (i != line('$') + 1) + " first, look for our own signature, to avoid deleting it + let j = i + while (j < line('$') && (getline(j + 1) !~ '^-- $')) + let j = j + 1 + endwhile + + " second, search for the last non empty (non sig) line + while ((i > 0) && (getline(i - 1) =~ '^\(>\s*\)*$')) + let i = i - 1 + endwhile + + " third, delete those lines plus the signature + exe ':'.i.','.(j - 1).'d' + endif +endfunction + +call Mail_Erase_Sig() + " Get right to composing the body: if line('$') > 1 :0 @@ -10,4 +39,3 @@ if line('$') > 1 :+1 :exe 'startinsert' endif -