/usr/share/elvis/scripts/match.ex is in elvis-common 2.2.0-11.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | " Defines a "match" alias, which moves the cursor to a matching word. The
" lists of matching words can be easily changed.
" Contributed by Ian Utley (iu@apertus.uk.com)
alias match {
"Move to the line where the pairing keyword is located
local a b d x y i nowrapscan magic magicchar=^$.[* noignorecase
"x and y are lists of matching words -- we'll seek forward from x words
"and backward from y words. The words listed here are appropriate for
"Unix shell scripts.
set x="if/then/case/do/begin/repeat" y="fi/else/esac/done/end/until"
let a=current("word")
if (a == "")
then error Cursor is not on a word
set b=""
while b=="" && x!="."
do {
if a==dirfile(x)
then {
let b=dirfile(y)
set d=forward
}
if a==dirfile(y)
then {
let b=dirfile(x)
set d=backward
}
let x=dirdir(x)
let y=dirdir(y)
}
if ( b=="" )
then error (a) is not a matchable keyword
mark c
set i=1
if (d=="forward")
then {
while ( i != 0 )
do {
set i=0
try eval /\<(b)\>
else {
" Failed to locate a match
'c
error No matching (b) located
}
mark d
eval 'c,'d global /\<(a)\>/ let i=i+1
eval 'c,'d global /\<(b)\>/ let i=i-1
}
}
if (d=="backward")
then {
while ( i != 0 )
do {
set i=0
try eval ?\<(b)\>
else {
" Failed to find a match
'c
error No matching (b) located
}
mark d
eval 'd,'c global /\<(a)\>/ let i=i+1
eval 'd,'c global /\<(b)\>/ let i=i-1
" global command has moved cursor back to 'c
'd
}
}
}
|