I previously wrote
| I have a partial work-around, by providing an extension to the caseless
| search facilities (ved_ss) in which backward searching does NOT wrap
| by default. I'll broadcast the code separately later.
I append the draft library file. It makes use of the new procedures
provided in Poplog version 14.5, which now make this sort of thing
very much easier than before.
Aaron
------
/* --- University of Birmingham 1994
> File: $poplocal/local/auto/ved_ss.p
> Purpose: Caseless ved searching
> Author: Aaron Sloman, Oct 30 1994
> Documentation: Below
> Related Files: REF * VEDSEARCH, TEACH * VEDSEARCH
*/
/*
LIB VED_SS
CONTENTS - (Use <ENTER> g to access required sections)
-- Introduction
-- Naming conventions
-- Trailing spaces
-- Autoloading
-- The new commands
-- Introduction -------------------------------------------------------
This library provides an alternative to the system caseless search
libraries provided in Poplog V14.5.
If put in $poplocal/local/auto it will shadow the system version. If
put in $poplocal/local/lib it will have to be explicitly loaded, e.g.
by
uses ved_ss
or
lib ved_ss
The existing libraries, ved_ss and ved_ww are modified here, and there
are several extensions.
There are three main changes:
1. Backward caseless search procedures are provided.
2. Backward searching does not wrap as the new default backward
searching does.
3. There is a new state variable associated with these routines,
vedss_searchstring
If any of the procedures described below is run with an empty argument
string they use the current value of vedss_searchstring. This means
that the last string searched for in caseless mode can be different
from the last one searched for normally. This makes it easy to alternate
between searching for two strings.
4. In addition there are new options dealing with different types
of forward or backwards caseless search in different search regions,
-- Naming conventions -------------------------------------------------
The procedures defined below are:
ved_ss ved_ww
ved_bss ved_bww
ved_ssr ved_wwr
ved_bssr ved_bwwr
ved_ssp ved_wwp
ved_bssp ved_bwwp
The commands containing 'ss' involve embedded caseless search, while
those with 'ww' search for non-embedded strings (e.g. complete pop-11
words).
Those starting with 'b' search backwards.
Those ending with 'r' search in the current marked range.
Those ending with 'p' search in the current procedure.
If neither 'r' nor 'p' is present, the whole file is searched.
Thus to search backwards for the previous occurrence of "lvars"
in the current procedure do
ENTER bwwp lvars
Note: none of the backward searches will "wrap" to the bottom of the
file or range or procedure if an instance is not found before the
start location.
-- Trailing spaces ----------------------------------------------------
The main problem with these procedures is that you cannot use a closing
delimiter. This means you can't find trailing spaces by giving a
delimeter. However you can use "\s" to represent trailing spaces, e.g.
ENTER ss define\s
See HELP ASCII for other codes.
-- Autoloading -------------------------------------------------------
To make all the different procedures autoloadable, you would need to
create suitably named files in an autoloadable directory that are either
linked to this one, or which load this, with the command:
uses ved_ss
-- The new commands ---------------------------------------------------
ENTER ss <string>
Searches for string. If string is missing, uses last string
searched for.
ENTER ww <string>
Like ved_ss, but checks for word boundaries at both ends of found
string. This is partly like <ENTER> "<string>" but caseless.
ENTER bss <string>
Like ss but searches backward. Does not wrap.
ENTER bww <string>
Like ww but searches backward. Does not wrap.
ENTER ssr <string>
Search only in range. Does not wrap
ENTER wwr <string>
Search for non-embedded string only in range. Does not wrap
ENTER bssr <string>
Search backward in range. Does not wrap
ENTER bwwr <string>
Search backward for non-embedded string only in range. Does not wrap
ENTER ssp <string>
Search only in current procedure. Does not wrap
ENTER wwp <string>
Search for non-embedded string only in current procedure. Does not wrap
ENTER bssp <string>
Search backward in current procedure. Does not wrap
ENTER bwwp <string>
Search backward for non-embedded string only in current procedure.
Does not wrap
The above commands can be turned into procedures with given
strings by applying veddo to appropriate strings.
E.g.
define ved_bv();
;;; ENTER bv
;;; search backward for "lvars" in current procedure
veddo('bwwp lvars')
enddefine;
*/
section;
compile_mode :pop11 +strict;
global vars
vedss_searchstring = false;
define lconstant vedcaseless_search(proc);
;;; This procedure localises ved_search_state and ensures that
;;; if no argument is given then the last value of vedss_searchstring
;;; will be used
lvars proc;
dlocal ved_search_state, vedargument;
if vedargument = nullstring and vedss_searchstring then
vedss_searchstring -> vedargument;
else
vedargument -> vedss_searchstring
endif;
proc();
enddefine;
define global vars ved_ss();
vedcaseless_search(ved_search_or_substitute(%'-case', undef%))
enddefine;
define global vars ved_ww();
vedcaseless_search(ved_search_or_substitute(%'-case -embed', undef%))
enddefine;
;;; backward versions
define global vars ved_bss();
vedcaseless_search(ved_search_or_substitute(%'-case +back -wrap', undef%))
enddefine;
define global vars ved_bww();
vedcaseless_search(
ved_search_or_substitute(%'-case +back -wrap -embed', undef%))
enddefine;
define global vars ved_ssr();
vedcaseless_search(
ved_search_or_substitute(%'range -case -wrap', undef%))
enddefine;
define global vars ved_wwr();
vedcaseless_search(
ved_search_or_substitute(%'range -case -wrap -embed', undef%))
enddefine;
define global vars ved_bssr();
vedcaseless_search(
ved_search_or_substitute(%'range +back -case -wrap', undef%))
enddefine;
define global vars ved_bwwr();
vedcaseless_search(
ved_search_or_substitute(%'range +back -case -wrap -embed', undef%))
enddefine;
define global vars ved_ssp();
vedcaseless_search(
ved_search_or_substitute(%'procedure -case -wrap', undef%))
enddefine;
define global vars ved_wwp();
vedcaseless_search(
ved_search_or_substitute(%'procedure -case -wrap -embed', undef%))
enddefine;
define global vars ved_bssp();
vedcaseless_search(
ved_search_or_substitute(%'procedure +back -case -wrap', undef%))
enddefine;
define global vars ved_bwwp();
vedcaseless_search(
ved_search_or_substitute(%'procedure +back -case -wrap -embed', undef%))
enddefine;
endsection;
|