diff options
author | Jesse Luehrs <doy@tozt.net> | 2009-05-11 22:13:03 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2009-05-11 22:13:03 -0500 |
commit | 26871691f7b6f7ad796bbbbaee558db2d55099d3 (patch) | |
tree | 2fb29a6644589f521b5f87500cbb250660e70e72 /vim/after/ftplugin | |
parent | bf90f8a405384aa956d6c4d3da714dfdc1ac858b (diff) | |
download | conf-26871691f7b6f7ad796bbbbaee558db2d55099d3.tar.gz conf-26871691f7b6f7ad796bbbbaee558db2d55099d3.zip |
update moose snippets with a better "remove unchanged line" function
Diffstat (limited to 'vim/after/ftplugin')
-rw-r--r-- | vim/after/ftplugin/moose_snippets.vim | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/vim/after/ftplugin/moose_snippets.vim b/vim/after/ftplugin/moose_snippets.vim index 7b35cf5..c020782 100644 --- a/vim/after/ftplugin/moose_snippets.vim +++ b/vim/after/ftplugin/moose_snippets.vim @@ -5,14 +5,13 @@ if !exists('loaded_snippet') || &cp finish endif -function! RemoveEmptySuperClass() - s/^extends '<{}>';\n//e - return @z -endfun - -function! RemoveEmptyLine() - s/^\s*<{}>\s*\n//e - return @z +function! RemoveUnchangedLine() + if match(getline('.'), "<{}>") >= 0 + normal! dd + return '' + else + return @z + endif endfun function! Snippet(abbr, str) @@ -38,7 +37,7 @@ call Snippet('class', [ \"package <{ClassName}>;", \"use Moose;", \"", - \"extends '<{SuperClass:RemoveEmptySuperClass()}>;", + \"extends '<{SuperClass:RemoveUnchangedLine()}>;", \"", \"<{}>", \"", @@ -50,14 +49,14 @@ call Snippet('has', [ \"has <{attr}> => (", \ "is => '<{rw}>',", \ "isa => '<{Str}>',", - \ "<{options:RemoveEmptyLine()}>", + \ "<{options:RemoveUnchangedLine()}>", \");"]) call Snippet('hasl', [ \"has <{attr}> => (", \ "is => '<{rw}>',", \ "isa => '<{Str}>',", \ "lazy_build => 1,", - \ "<{options:RemoveEmptyLine()}>", + \ "<{options:RemoveUnchangedLine()}>", \");", \"", \"sub _build_<{attr}> {", @@ -67,6 +66,7 @@ call Snippet('hasl', [ call Snippet('sub', [ \"sub <{name}> {", \ "my $self = shift;", + \ "my (<{arg:RemoveUnchangedLine()}>) = @_;", \ "<{}>", \"}"]) call Snippet('around', [ |