From: Shawn M Moore Date: Sun, 10 May 2009 19:44:37 +0000 (-0400) Subject: First stab at sticking a useful default into the package statement X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f26587a1d7f605819399d2eb5bd3cfec0a048a2e;p=gitmo%2Fmoose-dev-utils.git First stab at sticking a useful default into the package statement --- diff --git a/vim/moose_snippets.vim b/vim/moose_snippets.vim index 5b97d8d..ae377a6 100644 --- a/vim/moose_snippets.vim +++ b/vim/moose_snippets.vim @@ -38,8 +38,21 @@ function! SnippetFile(filename) return Snippet(abbr, str) endfunction +function! ParameterizedModule() + let current_file = expand("%") + let t = substitute(current_file, '\.pm', '', '') + let t = substitute(t, 'lib/', '', '') + + " Sadly, this does not work because : is a special character in snippet + " tag names. Any ideas? + "let module = substitute(t, '/', '::', 'g') + let module = substitute(t, '/.*', '', '') + + return '<{' . module . '}>' +endfun + call Snippet('class', [ - \"package <{ClassName}>;", + \"package ".ParameterizedModule().";", \"use Moose;", \"", \"extends '<{SuperClass:RemoveEmptySuperClass()}>';", @@ -51,7 +64,7 @@ call Snippet('class', [ \"", \"1;"]) call Snippet('role', [ - \"package <{RoleName}>;", + \"package ".ParameterizedModule().";", \"use Moose::Role;", \"", \"<{}>", @@ -101,7 +114,7 @@ call Snippet('after', [ " MooseX support call Snippet('prole', [ - \"package <{RoleName}>;", + \"package ".ParameterizedModule().";", \"use MooseX::Role::Parameterized;", \"", \"<{}>",