[Info-vax] VI* on VMS

Arne Vajhøj arne at vajhoej.dk
Thu Oct 17 08:57:30 EDT 2024


On 10/17/2024 8:53 AM, Arne Vajhøj wrote:
> On 10/17/2024 8:37 AM, Simon Clubley wrote:
>>> What is wrong with eve/tpu? or even LSE?
>>
>> However, when it comes to emacs, it does a _lot_ that EVE does not do.
>> For one simple but very important example, you have brace matching in
>> emacs so you can easily check the closing brace matches the correct
>> opening brace.
> 
> EVE does not have that out of the box.
> 
> But then EVE has relative little out of the box.
> 
> You can add it.
> 
> Either DIY or grab a copy of Kenneth Faitfield's
> EVE_MATCH_DELIMITORS.
> 
> I am afraid there are no online archive of INFO-TPU, but
> the most valuable pieces will have survived somewhere
> (I got the above).

Here it is.

Arne

!++
!   This procedure highlights (in BOLD, REVERSE video) matching pairs
!   of delimitors, the first of which is taken to be the character at
!   the current cursor position.  Highlighting is turned off by invoking
!   this procedure with the cursor positioned on a non-delimitor character.
!   Subsequent invocations turn off the highlighting on previously matched
!   pairs, as well.
!
!   This procedure uses the global marker variables khf$x_match1_position,
!   khf$x_match2_position, khf$x_match3_position, and khf$x_match4_position.
!
! Author/Date:          K.H. Fairfield,         16-Jan-1988
!
!--
Procedure Eve_Match_Delimitors
!         --------------------
Local saved_mark,       ! mark current position
       first_char,       ! first character of matching pair
       last_char,        ! second character of matching pair
       direction,        ! search direction
       n;                ! character position in khf$kt_left_delims or
                         ! khf$kt_right_delims string.


     On_Error
         [TPU$_CONTROLC]:
             Eve$Learn_Abort;
             Eve$$Restore_Position (saved_mark);
         [OTHERWISE]:
             Eve$$Restore_Position (saved_mark);
     Endon_Error;


     saved_mark := Mark (NONE);

!+
!  Make an early return here if the current position is the same
!  position as the last previously marked delimitor.
!-
     If khf$x_match1_position <> 0 Then
         If saved_mark = khf$x_match1_position Then

             khf$x_match1_position:= 0;
             khf$x_match2_position:= 0;
             khf$x_match3_position:= 0;
             khf$x_match4_position:= 0;
             Return (TRUE);

         Endif;
     Endif;

     first_char := CURRENT_CHARACTER;

     n := Index (khf$kt_left_delims, first_char);

     If n > 0 Then
         last_char := Substr (khf$kt_right_delims, n, 1);
         direction := FORWARD;
     Else
         n := Index (khf$kt_right_delims, first_char);

         If n > 0 Then
             last_char := Substr (khf$kt_left_delims, n, 1);
             direction := REVERSE;
         Else
!+
!  Current_Character was not a delimitor.  If highlighting is on, turn it
!  off, else issue an error message.
!-
             If khf$x_match1_position = 0 Then
                 Eve$message ("The current character, " + first_char +
                          ", is not a valid delimitor to match.");
             Endif;
             khf$x_match1_position:= 0;
             khf$x_match2_position:= 0;
             khf$x_match3_position:= 0;
             khf$x_match4_position:= 0;
             Return (FALSE);
         Endif;
     Endif;

     khf$x_match1_position:= Mark (BOLD);
     khf$x_match2_position:= Mark (REVERSE);

     If Khf_Find_Match (first_char, last_char, direction) = 1 Then
         khf$x_match3_position:= Mark (BOLD);
         khf$x_match4_position:= Mark (REVERSE);
         Update (CURRENT_WINDOW);
         Position (khf$x_match1_position);
         Return (TRUE);
     Else
         Position (khf$x_match1_position);
         khf$x_match1_position:= 0;
         khf$x_match2_position:= 0;
         khf$x_match3_position:= 0;
         khf$x_match4_position:= 0;
         Eve$message (" Could not find the matching " + last_char +
                  " character for the current character, " + first_char);
         Return (FALSE);
     Endif;


EndProcedure;           ! Eve_Match_Delimitors


!++
!   The following procedure does the actually search for the matching
!   delimitor character.  A recursive algorithm is used so that intervening
!   pairs of matched delimitors are not mistakenly selected as the match.
!
! Input Parameters:
!
!       first       the delimitor character whose mate is being sought
!
!       last        the matching delimitor character
!
!       direction   the direction to search.  If first_char is a right-
!                   delimitor, the search direction is FORWARD,
!                   otherwise it is REVERSE.
!
! Author/Date:          K.H. Fairfield,         16-Jan-1988
!-

Procedure Khf_Find_Match (first, last, direction)
!         --------------
Local this_patt, this_range;

     this_patt := first + last;
     Loop
         If direction = FORWARD Then
             Move_Horizontal (1);
         Else
             Move_Horizontal (-1);
         Endif;
         this_range := Search_Quietly (Any (this_patt), direction);
         If this_range <> 0
         Then
             Position (this_range);
         Else
             Return (0);
         Endif;
         If CURRENT_CHARACTER = last Then
             Return (1);
         Else
             If Khf_Find_Match (first, last, direction) = 0 Then
                 Return (0);
             Endif;
         Endif;
     Endloop;

Endprocedure;           ! Khf_Find_Match




More information about the Info-vax mailing list