From 2eeff06b3e1a850a1194df49ca236cc2aaf8dae4 Mon Sep 17 00:00:00 2001 From: Andre Walker Date: Tue, 13 Sep 2016 15:30:13 +0200 Subject: [PATCH 1/2] Suggest a better default for Perl package names The previous snippet for Perl 'package' was apparently copy-pasted from html.snippets (see 'head' and 'title' snippets). It didn't really make sense, and for me it actually always returned an empty string. This one looks for the path name of the file and removes everything up to the lib/ folder. It then replaces '/' with '::'. I think it's a pretty sensible default. Finally, I also added "use strict" and "use warnings" to the package definition. --- snippets/perl.snippets | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index 65120a2..c6d865b 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -84,7 +84,9 @@ snippet fore ${1:expression} foreach @${2:array}; # Package snippet package - package ${1:`substitute(vim_snippets#Filename('', 'Page Title'), '^.', '\u&', '')`}; + package ${1:`vim_snippets#Filename(expand('%:p:s?.*lib/??:r:gs?/?::?'))`}; + use strict; + use warnings; ${0} @@ -93,7 +95,9 @@ snippet package __END__ # Package syntax perl >= 5.14 snippet packagev514 - package ${1:`substitute(vim_snippets#Filename('', 'Page Title'), '^.', '\u&', '')`} ${2:0.99}; + package ${1:`vim_snippets#Filename(expand('%:p:s?.*lib/??:r:gs?/?::?'))`} ${2:0.99}; + use v5.14; + use warnings; ${0} From b468a4374f8ee496c8bd611a6cba668e5160fd54 Mon Sep 17 00:00:00 2001 From: Andre Walker Date: Tue, 13 Sep 2016 16:58:28 +0200 Subject: [PATCH 2/2] Actually, Filename() here is not necessary --- snippets/perl.snippets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index c6d865b..2ed2932 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -84,7 +84,7 @@ snippet fore ${1:expression} foreach @${2:array}; # Package snippet package - package ${1:`vim_snippets#Filename(expand('%:p:s?.*lib/??:r:gs?/?::?'))`}; + package ${1:`expand('%:p:s?.*lib/??:r:gs?/?::?')`}; use strict; use warnings; @@ -95,7 +95,7 @@ snippet package __END__ # Package syntax perl >= 5.14 snippet packagev514 - package ${1:`vim_snippets#Filename(expand('%:p:s?.*lib/??:r:gs?/?::?'))`} ${2:0.99}; + package ${1:`expand('%:p:s?.*lib/??:r:gs?/?::?')`} ${2:0.99}; use v5.14; use warnings;