example sugar script 'continuation-lines' added
This commit is contained in:
parent
0fdd80f487
commit
a9d5adcd10
3 changed files with 63 additions and 4 deletions
34
src/syntactic-sugar/continuation-lines
Executable file
34
src/syntactic-sugar/continuation-lines
Executable file
|
@ -0,0 +1,34 @@
|
|||
# vim: syn=perl:
|
||||
|
||||
# "sugar script" (syntactic sugar helper) for gitolite3
|
||||
|
||||
# Enabling this script in the rc file allows you to use back-slash escaped
|
||||
# continuation lines, like in C or shell etc.
|
||||
|
||||
# This script also serves as an example "sugar script" if you want to write
|
||||
# your own (and maybe send them to me). A "sugar script" in gitolite will be
|
||||
# executed via a perl 'do' and is expected to contain one function called
|
||||
# 'sugar_script'. This function should take a listref and return a listref.
|
||||
# Each item in the list is one line. There are NO newlines; g3 kills them off
|
||||
# fairly early in the process.
|
||||
|
||||
# If you're not familiar with perl please do not try this. Ask me to write
|
||||
# you a sugar script instead.
|
||||
|
||||
sub sugar_script {
|
||||
my $lines = shift;
|
||||
|
||||
my @out = ();
|
||||
my $keep = '';
|
||||
for my $l (@$lines) {
|
||||
if ($l =~ s/\\$//) {
|
||||
$keep .= $l;
|
||||
} else {
|
||||
$l = $keep . $l if $keep;
|
||||
$keep = '';
|
||||
push @out, $l;
|
||||
}
|
||||
}
|
||||
|
||||
return \@out;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue