Procedure find_match (choice)
tmp := 0; ! reset previous range if any
home := Mark(None);
Case choice from 0 to 2
[0] : used := ")";
opposite:= "(";
patt := "(" | ")";
[1] : used := "]";
opposite:= "[";
patt := "[" | "]";
[2] : used := "}";
opposite:= "{";
patt := "{" | "}";
Endcase;
copy_text(used);
Set (Screen_update,Off);
counter := 1;
Move_horizontal(-1);
origin := Mark(None);
Move_horizontal(-1);
Loop
ou := Search_quietly(patt,Reverse);
Exitif ou = 0;
Position(ou);
If Current_Character = opposite
Then
counter := counter - 1;
Else
counter := counter + 1;
Endif;
Exitif counter = 0;
Move_horizontal(-1);
Endloop;
If counter = 0
Then
fin := Mark(None);
tmp := Create_Range(origin,fin,Bold);
Else
Message('No match found ...');
Endif;
Position(home);
Set (Screen_update,On);
Endprocedure;
Les touches ) ] et } associées à la procédure seront définies :
Define_key('find_match(0)',Key_name(")"));
Define_key('find_match(1)',Key_name("]"));
Define_key('find_match(2)',Key_name("}"));