[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon May 7 04:41:32 1995 
Subject:controlling search in VED in Poplog V14.5 
From:A . Sloman 
Volume-ID:950508.01 

Having been very annoyed for the umpteenth time by the new behaviour
in VED's search regarding wrap/nowrap, I now have devised the following
solution, which may be of use to others.

It works on the assumption that the active variable ved_search_state
holds 9 objects of which the third is a boolean that determines whether
wrapping round the end of the file is allowed or not allowed.
Unfortunately this is based on trial and error, as the documentation in
REF VEDSEARCH does not provide the information. So I am not sure whether
my solution is guaranteed to work in all contexts.

Does anyone know?

Objective: to make the "repeat" search key sequences work as documented
in TEACH VEDSEARCH, i.e.
=======================================================================
-- Repeat forward search: <ESC> / --------------------------------------

The sequence <ESC> /  can be used to repeat the last search. It will
use the last search string to search forward like <ENTER> / and
<ENTER> ".

-- Repeat backward search: <ESC> \ ------------------------------------

This is exactly like <ESC> /  except that it searches backwards and does
not wrap around the top of the file.
=======================================================================

There are two things wrong with the current version (compared with the
previous behaviour and the above documentation):
    (a) backward search using "ESC \" DOES wrap by default
    (b) forward search using "ESC /" will NOT wrap if the last
        search command explicitly used the no-wrap option.

The following procedure overcomes this. It can be used to "re_search",
i.e. search again using the previous search string, either forward or
backward, but ensuring that forward search wraps and backward search
doesn't. vedsetkey is then used to change the behaviour of "ESC /" and
"ESC \".

define vednew_re_search(forward);
    ;;; Search forward or backward, using previous search state
    ;;; settings, except that forward search always wraps and backward
    ;;; search never does

    lvars forward;  ;;; a boolean

    lconstant search_items = 9,
        search_vector = initv(search_items);

    ;;; save the contents of ved_search_state in the vector
    fill(ved_search_state, search_vector)->;
    if forward then
        ;;; allow wrapping by setting third item of state true
        true -> search_vector(3);
        explode(search_vector) -> ved_search_state;
        ved_re_search();
    else
        ;;; prevent wrapping
        false -> search_vector(3);
        explode(search_vector) -> ved_search_state;
        ved_re_backsearch();
    endif;
    ;;; re-set contents of vector
    set_subvector(0, 1, search_vector, search_items)
enddefine;

;;; search forward, using the  wrap default.
vedsetkey('\^[/', vednew_re_search(%true%));    ;;; ESC /

;;; search back, using the no wrap default.
vedsetkey('\^[\\', vednew_re_search(%false%));  ;;; ESC \
=======================================================================

Aaron