From bec406fab13616af979a9586a5c96718566150de Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 24 May 2019 10:44:54 +1200 Subject: Make greeting regex even nuttier Needs to be split into two lines now. --- vim/after/ftplugin/mail.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'vim') diff --git a/vim/after/ftplugin/mail.vim b/vim/after/ftplugin/mail.vim index fd2c9705..48731b93 100644 --- a/vim/after/ftplugin/mail.vim +++ b/vim/after/ftplugin/mail.vim @@ -15,9 +15,9 @@ if line('.') == 1 && col('.') == 1 delete endwhile - " Check this line to see if it's a generic hello or hello-name greeting that - " we can just strip out; delete any following lines too, if they're blank - if getline('.') =~? '^>\s*\%(\s*\%( Date: Fri, 24 May 2019 11:05:40 +1200 Subject: Break up and improve greeting pattern --- vim/after/ftplugin/mail.vim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'vim') diff --git a/vim/after/ftplugin/mail.vim b/vim/after/ftplugin/mail.vim index 48731b93..8a8e82fc 100644 --- a/vim/after/ftplugin/mail.vim +++ b/vim/after/ftplugin/mail.vim @@ -17,7 +17,11 @@ if line('.') == 1 && col('.') == 1 " Check this line to see if it's a generic greeting that we can just strip " out; delete any following lines too, if they're blank - if getline('.') =~? '^>\s*\%( *' + \ . '\%(h[eu]llo\+\|hey\+\|hi\+\|sup\|what''s up' + \ . '\|\%(good \)\=\%(morning\|afternoon\|evening\)\)' + \ . '\%( \a\+\)\=' + \ . '[[:punct:]]* *$' delete " Delete quoted blank lines again -- cgit v1.2.3 From d711ee84713221f20f3d1e6d50d4e240b24c94ef Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 24 May 2019 11:29:44 +1200 Subject: More revision/expansion of blank/greeting strip --- vim/after/ftplugin/mail.vim | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) (limited to 'vim') diff --git a/vim/after/ftplugin/mail.vim b/vim/after/ftplugin/mail.vim index 8a8e82fc..b14bb859 100644 --- a/vim/after/ftplugin/mail.vim +++ b/vim/after/ftplugin/mail.vim @@ -10,26 +10,29 @@ if line('.') == 1 && col('.') == 1 " no quote, which is fine call search('\m^>', 'c') - " Delete quoted blank lines until we get to something with substance - while getline('.') =~# '^>\s*$' + " Delete quoted blank lines or quoted greetings until we get to something + " with substance. Yes, I like Perl, how could you tell? + while getline('.') =~? '^> *' + \ . '\%(' + \ . '\%(' + \ . 'g''\=day' + \ . '\|\%(good \)\=\%(morning\|afternoon\|evening\)' + \ . '\|h[eu]\%(ll\|rr\)o\+' + \ . '\|hey\+' + \ . '\|hi\+' + \ . '\|sup' + \ . '\|what''s up' + \ . '\|yo' + \ . '\)' + \ . '[[:punct:] ]*' + \ . '\%(' + \ . '\a\+' + \ . '[[:punct:] ]*' + \ . '\)\=' + \ . '\)\=$' delete endwhile - " Check this line to see if it's a generic greeting that we can just strip - " out; delete any following lines too, if they're blank - if getline('.') =~? '^> *' - \ . '\%(h[eu]llo\+\|hey\+\|hi\+\|sup\|what''s up' - \ . '\|\%(good \)\=\%(morning\|afternoon\|evening\)\)' - \ . '\%( \a\+\)\=' - \ . '[[:punct:]]* *$' - delete - - " Delete quoted blank lines again - while getline('.') =~# '^>\s*$' - delete - endwhile - endif - " Now move to the first quoted or unquoted blank line call search('\m^>\=$', 'c') -- cgit v1.2.3 From 35729ea64429e647fd87775e06e6a2ebb6cbdb1e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 24 May 2019 11:29:57 +1200 Subject: Don't strip tabs after angle quotes Don't solve problems we don't have yet --- vim/after/ftplugin/mail.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'vim') diff --git a/vim/after/ftplugin/mail.vim b/vim/after/ftplugin/mail.vim index b14bb859..47c82bb6 100644 --- a/vim/after/ftplugin/mail.vim +++ b/vim/after/ftplugin/mail.vim @@ -45,7 +45,7 @@ for lnum in range(1, line('$')) let line = getline(lnum) " Get the leading quote string, if any; stop if there isn't one - let quote = matchstr(line, '^[> \t]\+') + let quote = matchstr(line, '^[> ]\+') if strlen(quote) == 0 continue endif @@ -54,7 +54,7 @@ for lnum in range(1, line('$')) let quote = substitute(quote, '[^>]', '', 'g') " Re-set the line - let line = substitute(line, '^[> \t]\+', quote, '') + let line = substitute(line, '^[> ]\+', quote, '') call setline(lnum, line) endfor -- cgit v1.2.3