HELP INITIAL.EX                                         Aaron Sloman July 1983

What follows is a collection of examples of things POPLOG users do to tailor
the system to suit themselves. I am grateful to colleagues and students for
permission to use their INIT.P and VEDINIT.P files, etc.


-- VMS COMMAND FILES --------------------------------------------------------

An example VMS command file to create a new saved image containing your own
goodies:

Creates a saved image called MYPOP.PSV containing all the stuff if the file
MYPOP.P. The image can be run with the VMS command:
    POP11/MYPOP

for which you can define a suitable abbreviation in your LOGIN.COM, e.g.
    POP :== 'POP11/MYPOP'.

Instead of MYPOP, use whatever you like. The source file and saved image do
not need to use the same name.

It is possible to save the image in such a way that it looks to see
whether it has been invoked with a file name, e.g.

    POP FOO

in which case it will start up by running the editor and reading in the file
FOO.

If the POP system is changed (or re-linked) you'll have to build a new
saved image.

Here's the command file:

$del mypop.psv;*        !!! delete old version
$!!! run pop11, which will read in rest of this file             
$pop11
load mypop.p        ;;; load source files
if syssave("mypop") then    ;;; syssave produces TRUE  when image is restored
    pr(popversion);         ;;; Prints out header, with version of POP
    popready -> interrupt;  ;;; optional, see help POPREADY
    true -> pop_first_setpop;   ;;; pretend no setpop yet

    /*
    The next instruction allows you to invoke this image by typing
            POP11/MYMPOP FOO
    in which case POP will go straint into the editor with the file FOO
    */
    unless poparglist == [] then
        charout(10);
        popval([ved ^^poparglist ;])
    endunless;
    setpop()
else
    sysexit()       ;;; this branch runs when image has been created
endif;
$! end of POP11 invocation



============================================================================

/*----------INIT.P and VEDINIT.P combined - by Chris Slymon-----------*/             

true -> popsyscall;     ;;; fuller error messages

define macro newp;
    ;;; create a new saved image, using current state, and delete old one.
    sysobey('delete poplib:initdone.psv.*');
    syssave('poplib:initdone.psv')=>
enddefine;

/* Add my poplib: to list of directories searched */
[% 'poplib:' %] <> popuseslist -> popuseslist;  /* for explicit lib commands */
[% 'poplib:' %] <> popautolist -> popautolist;    /* for autoloading */

800 -> vedautowrite;
false -> vedterminalselect;         ;;; use V200 suppress enquiry about terminals
false -> vedscrollscreen;           ;;; refresh, don't scroll, for screen down

/* invoke various local library extensions to ved */
uses autoindent;
uses vedkey5;
uses ved_ff;
uses ved_incsearch;

/* define facilities for abbreviation */

section $-library => vedsetmacro ved_killmac ved_lmac
                     ved_shmac ved_domac ved_nomac ved_setmac
                     ved_macro_expanders;

vars vedmacprops;

define vedlastword() -> vedtemp;
    vars vedline vedcolumn _string;
    vedsetlinesize();
    if vedcolumn == 1 or vedcolumn > vvedlinesize + 1
            or (vedthisline() -> _string; _string(vedcolumn - 1) = ` `) then
        false
    else
        vedcolumn -> vedtemp;
        vedcharleft();
        until vedatitemstart(vedcolumn,_string,vvedlinesize + 1) do
            vedcolumn - 1 -> vedcolumn;
        enduntil;
        consword(substring(vedcolumn,vedtemp-vedcolumn,_string))
    endif; -> vedtemp;
enddefine;

define vedwordbreak();
    vars vedtemp last_word;
    if vedonstatus then return endif;
    if (vedmacprops(vedlastword() ->> last_word) ->> vedtemp) then
        if vedtemp.isprocedure then
            vedtemp()
        else
            repeat length(last_word) times
                vedchardelete();
            endrepeat;
            vedinsertstring(vedtemp)
        endif
    endif;
enddefine;

define global vedsetmacro( word);
    if isproperty( word) then
        word -> vedmacprops;
    else
        -> vedmacprops( word);
    endif;
enddefine;

vars ved_pop_macros;

newproperty([
    [d 'define']
    [dg 'define global']
    [dm 'define macro']
    [c 'constant']
    [rt 'return']
    [t 'then']
    [v 'vars']
    [sc 'section']
    [sw 'switchon']
    [fc 'foreach']
    [fv 'forevery']
    [ul 'unless']
    [ut 'until']
    [w 'while']
    [p 'procedure']
    [l 'else']
    [li 'elseif']
    [lu 'elseunless']
    [qi 'quitif']
    [ql 'quitloop']
    [qu 'quitunless']
    [rp 'repeat']
    [ei 'endif']
    [ed 'enddefine']
    [er 'endrepeat']
    [esc 'endsection']
    [esw 'endswitchon']
    [ef 'endfor']
    [efc 'endforeach']
    [efv 'endforevery']
    [eul 'endunless']
    [eut 'enduntil']
    [ew 'endwhile']
    [ep 'endprocedure']
],
        30,false,true) -> ved_pop_macros;

vedsetmacro( ved_pop_macros);

define vedmatchendstartingat( column) -> _item;
    vars vedline vedcolumn vvedlinesize;
    until vedline = 1 do
        vedcharup();
        unless vvedlinesize = 0 then
            vedtextleft();
            if vedcolumn = column
                    and member(vednextitem() ->> _item,vedopeners) then
                return
            endif;
        endunless;
    enduntil;
    false  -> _item;
enddefine;

define vedemacro();
    vars ending;
    vedmatchendstartingat(vedcolumn - 1) -> ending;
    if ending then
        vedinsertstring('nd' >< ending);
    endif;
enddefine;

vedsetmacro(vedemacro,"e");

define vedebmacro();
    vars ending;
    vedmatchendstartingat(max(vedcolumn - 2 - vedindentstep, 1)) -> ending;
    if ending then
        vedchardelete();
        vedinsertstring('nd' >< ending >< ';');
    endif;
enddefine;

vedsetmacro(vedebmacro,"eb");

define global veddowordbreak( proc);
    vedwordbreak();
    proc();
enddefine;

global vars ved_macro_expanders;
[% ' ', ',', ';', '\n', '\r', '\t' %] -> ved_macro_expanders;

define vedmackey( string);
    vars temp;
    unless pdpart( vedgetproctable(string) ->> temp) == veddowordbreak then
        vedsetkey(string ,veddowordbreak(% temp %));
    endunless;
enddefine;

define global ved_domac();
    applist( ved_macro_expanders, vedmackey);
enddefine;

define vedresetmackey( string);
    vars temp;
    if isclosure( vedgetproctable(string) ->> temp) then
        vedsetkey(string , frozval( 1, temp));
    endif;
enddefine;

define global ved_nomac();
    applist( ved_macro_expanders, vedresetmackey);
enddefine;

define global ved_setmac();
    vars _space;
    if vedargument = '' then
        vederror('Usage: setmac <string> <substitution string>');
    elseif locchar( ` `, 1, vedargument) ->> _space then
        substring(_space + 1, length( vedargument) - _space, vedargument)
            -> vedmacprops(consword(substring(1,_space - 1,vedargument)));
    elseif vedmacprops( consword( vedargument)) then
        vedputmessage( vedargument >< ' cleared');
        false -> vedmacprops(consword(vedargument));
    else
        vederror('No macro defined for ' >< vedargument);
    endif;
enddefine;

define global ved_killmac();
    vedputmessage('Clearing macros');
    appproperty( vedmacprops,
        procedure item value;
            false -> vedmacprops( item);
        endprocedure);
enddefine;

define global ved_shmac();
    vars temp;
    if vedargument = '' then
        appproperty( vedmacprops,
            procedure item value;
                pr( newline);
                pr( item); pr(tab); pr(value);
            endprocedure);
    elseif vedmacprops(consword(vedargument)) ->> temp then
        vedputmessage( '' >< temp); /* could be a procedure */
    else
        vedputmessage('No macro defined for ' >< vedargument);
    endif;
enddefine;

define global ved_lmac();
    if vedargument = '' then
        vederror('Argument needed');
    endif;
    vedargument >< ' ' >< vedlastword() -> vedargument;
    ved_setmac();
enddefine;

endsection;

vedsetmacro( 'define global ved', "dgv");
vedsetmacro( '->', "--");
vedsetmacro( '->>', "-^");

vars ved_sfv;
ved_sourcefile -> ved_sfv;

define ved_vved();
    'ved_' >< vedargument >< '.p' -> vedargument;
    ved_ved();
enddefine;

;;; displays the current time

define ved_date;
    vedputmessage(sysdaytime())
enddefine;

define ved_mine();
    vedtopfile();
    vedlineabove();
    vedinsertstring('Chris Slymon, June 1983\n');
enddefine;

define ved_wswap();
    if vedstartwindow < 24 then '24' else '12' endif; -> vedargument;
    ved_ws();
enddefine;

define vedinitfile;
/*    unless issubstring(".",1,vedvedname) then
        70
    else
        78
    endunless; -> vedlinemax;
*/
    if vedcurrent = 'output' then
        false -> vedautowrite;
    endif;
    if sysisprogfile(vedcurrent) then
        vedpopnewlines();
        ved_domac();
    else
        vedvednewlines();
        ved_nomac();
    endif;
enddefine;

define ved_cr();
    vars vedargument;
    '/\^M//' -> vedargument;
    ved_gs();
    '/\^L//' -> vedargument;
    ved_gs();
enddefine;

define ved_rqved();
    false -> vedchanged;
    ved_qved();
enddefine;

define ved_rwqved();
    vars vedwriteallfiles;
    true  -> vedwriteallfiles;
    false -> vedchanged;
    ved_wqved();
enddefine;

define vedfindnextword;
    '"' >< vednextitem() -> vedargument;
    ved_search();
enddefine;

define vedfindlastword;
    '"' >< vednextitem() -> vedargument;
    ved_backsearch();
enddefine;

define ved_nextword;
    vednextitem() -> vvedworddump;
enddefine;

vars locate_char_time; 100 -> locate_char_time;

define vedlocatechar();
    vars char;
    if charin_timeout( locate_char_time) ->> char then
        vedlocate(consstring(char,1))
    else
        vederror('too slow');
    endif;
enddefine;

define vedbacklocatechar();
    vars char;
    if charin_timeout( locate_char_time) ->> char then
        vedbacklocate(consstring(char,1))
    else
        vederror('too slow');
    endif;
enddefine;

define ved_ccl;
    vedscreenleft();
    until vedcolumn > vvedlinesize do
        vedchangecase();
    enduntil;
enddefine;

define ved_ao;
    false -> vedautowrite;
enddefine;

define vedlmax( num);
    num -> vedargument;
    ved_linemax();
enddefine;

define ved_section();
    vedlinebelow();
    vedinsertstring('section ' >< vedargument >< ' => ');
    vedpositionpush();
    vedinsertstring(';\n');
    vedendfile();
    vedinsertstring('\nendsection;');
    vedpositionpop();
enddefine;

;;; KEYS - <ESC> + function key on v200

[%
     `P`, ved_y,
     `Q`, ved_yankw,
     `R`, ved_yankl,
     ` `, ved_yankw,
     `!`, ved_swl,
     `"`, ved_swr,
     `#`, nonmac dcl,
     `$`, vedmarkfind,
     `%`, ved_jp,
     `&`, ved_t,
     ```, vedexchangeposition,
     `(`, ved_cps,
     `)`, undef,
     `*`, undef,
     `D`, ved_margin,
     `C`, ved_break,
     `A`, ved_wswap,
     `H`, ved_mef,
     `t`, ved_mbf

     %] -> vedescapetable( `\^[`);

vedsetkey('\^A', ved_xup);
vedsetkey('\^F', ved_sw);
vedsetkey('\^T', ved_tr);
vedsetkey('\^Z', ved_xdn);
vedsetkey('\^[a', ved_sla);
vedsetkey('\^[b', ved_slb);
vedsetkey('\^[d', ved_d);
vedsetkey('\^[g', ved_nextword);
vedsetkey('\^[s', ved_incsearch);
vedsetkey('\^[C', vedendline);              ;;; ->
vedsetkey('\^[0', vedlmax(% '70'%));
vedsetkey('\^[8', vedlmax(% '78'%));
vedsetkey('\^[]', ved_ucw);                 ;;; CONVERT keypad .
vedsetkey('\^[^', ved_lcw);                 ;;; CONVERT keypad ,
vedsetkey('\^[\^[b', vedbacklocatechar);
vedsetkey('\^[\^[e', ved_rrq);
vedsetkey('\^[\^[f', vedlocatechar);
vedsetkey('\^[\^[]', vedfindnextword);      ;;; <ESC> CONVERT keypad .
vedsetkey('\^[\^[^', vedfindlastword);      ;;; <ESC> CONVERT keypad ,

vedsetkey('\^[.',
    procedure;
        vars vedstatic;
        true -> vedstatic;
        vedcharinsert(`.`);
        vedcharright();
        vedchangecase();
    endprocedure);

vedsetkey('\^[,',
    procedure;
        vars vedstatic;
        true -> vedstatic;
        vedcharinsert(`,`);
        vedcharright();
        vedchangecase();
    endprocedure);


===========================================================================


;;; Jonathan Laventhol.  most of this really should be a vedinit.p

1 -> popsyscall;
1 -> popgctrace;

;;; compile init.p in current directory, unless that's this file
;;;
unless sysdirectory() = '[JCL]' then trycompile('init.p') endunless;

;;; add library to front of directory lists
;;;
'disk$2c:[jcl.lib]' :: delete('disk$2c:[jcl.lib]', popautolist) -> popautolist;
'disk$2c:[jcl.lib]' :: delete('disk$2c:[jcl.lib]', popuseslist) -> popuseslist;

uses newpr;
newpr(isproperty, procedure(p);
                    '<property>\n'.pr;
                    appproperty(p, printf(% '%p\t%p\n' %))
                  endprocedure);

;;; fix up ved.  swap screenright and textright keys to be like ded
;;;
false -> vedautowrite;          ;;; no autowrite
false -> vedversions;           ;;; no autopurging
false -> vedscrollscreen;       ;;; refresh, not scroll
4 -> vedindentstep;             ;;; small tabs
true ->> vedlmr_print_in_file   ;;; doit in file
-> vedlmr_errs_in_file;         ;;; ditto for errors
vedsetkey('\^[C', vedscreenright);      ;;; like in the ...
vedsetkey('\^[]', vedtextright);        ;;;     ... old country

vedsetkey('\^[b', procedure;
                   vedputmessage(if vedchanged then vedchanged else 'no' endif
                                    >< ' changes')
                  endprocedure);

uses vednkother;

========================================================================



12 -> item_chartype(`\\`);      /* make backslash an alphabeticiser */


true -> vedmidscreen;
1500 -> vedautowrite;

false -> vednotabs;

define ved_-();
    ;;; ENTER -
    ;;; ads two hyphens before, and a whole row of them after, stuff on line
    1 -> vedcolumn;
    vedinsertstring('-- ');
    vedtextright();
    vedcharinsert(` `);
    until vedcolumn == vedlinemax do vedcharinsert(`-`) enduntil;
enddefine;

define ved_^();
    ;;; ENTER ^
    ;;; search for another occurrence of item to right of cursor
    vedlocate(vednextitem())
enddefine;

;;; make <ESC> CTRL-N invoke it
vedsetkey('\^[\^N', ved_^);

;;; define ENTER ; as meaning put comment at beginning of line
;;; cannot define a procedure with name "ved_;" - so create name using
;;; consword, declare it, and assign suitable procedure to it.

popval([ vars ^(consword('ved_' >< ";")) ;]);

procedure;
    vedpositionpush();
    1 -> vedcolumn; vedinsertstring(';;;');
    vedpositionpop();
endprocedure -> valof(consword('ved_' >< ";"));

uses vedkey5;

uses ved_go;

define ved_delafter;
    ;;; ENTER DELAFTER <string>
    ;;; find every occurrence of string and delete to end of line
    vars vedautowrite;
    false -> vedautowrite;
    repeat vedlocate(vedargument); vedcleartail() endrepeat
enddefine;

define ved_tlo();
    ;;; transcribe current line out to other file
    vedmarkhi(); vedmarklo(); ved_to();
enddefine;

define ved_tli();
    ;;; transcribe line from other file to this one
    vedswapfiles();
    ved_tlo();
    vedswapfiles();
enddefine;


define ved_pg;
    ;;; put in '.pg' on line above
    vedlineabove(); 1 -> vedcolumn; vedinsertstring('.tp 5')
enddefine;


define vedinitfile;
    ;;; run each time file put on screen. Some of this should go in next proc
    vars _x;
    if sysisprogfile(vedcurrent) then
        false -> vednotabs
    elseif issubstring('.ref',1,vedcurrent)
    or issubstring('.help',1,vedcurrent)
    or issubstring('.teach',1,vedcurrent)
    or (sysdirectory() -> _x; issubstring('.REF',1,_x))
    or issubstring('.HELP',1,_x)
    or issubstring('.TEACH',1,_x)
    or issubstring('primer',1,_x)
    then true -> vednotabs
    endif;
    if (issubstring('news',1,vedcurrent) ->> _x)
        and _x + 3 == datalength( vedcurrent)
    then
        4 -> vedleftmargin
    endif;
    if vedcurrent = 'output' then false -> vedwriteable endif;
    if issubstring('primer',1,vedcurrent) then 72 -> vedlinemax endif;
enddefine;

define vedveddefaults();
    ;;; run once when file is read in, or new one started,
    ;;; before it's put on screen
    vars p;
    if locchar(`]`,1,vedcurrent) ->> p then p+1 else 1 endif -> p;
    if issubstring('.pma',p,vedcurrent)
    or issubstring('.mar',p,vedcurrent)
    or issubstring('.ps',p,vedcurrent)
    or issubstring('.s',p,vedcurrent)
    then 8
    else 4
    endif -> vedindentstep;
    vedinitfile();
enddefine;

;;; tell ved not to do auto line break for certain files
[ '.mar' '.pma' '.s' '.ps'] <> vednonbreakfiles -> vednonbreakfiles;


define ved_-();
    ;;; used to insert '-- ' before and lots of '-------' after text
    ;;; on current line, to make headings
    1 -> vedcolumn;
    vedinsertstring('-- ');
    vedtextright();
    vedcharinsert(` `);
    until vedcolumn == vedlinemax do vedcharinsert(`-`) enduntil;
enddefine;

======================================================================
Jon Cunningham

The following is taken from a file used by Jon Cunningham to build a saved
image which he uses for most of his work. It includes a lot of abbreviations
to save typing. Also a lot of alterations to the editor.

;;; define a collection of abbreviations
vars macro def; "define" -> nonmac def;
vars macro fed; "enddefine" -> nonmac fed;
vars macro --; "->" -> nonmac --;
vars macro ^; "=>" -> nonmac ^;
vars macro ^^; "==>" -> nonmac ^^;
vars macro ef; "elseif" -> nonmac ef;
vars macro fi; "endif" -> nonmac fi;
vars macro el; "else" -> nonmac el;
vars macro rep; "repeat" -> nonmac rep;
vars macro per; "endrepeat" -> nonmac per;
vars macro rof; "endfor" -> nonmac rof;
vars macro les; "unless" -> nonmac les;
vars macro sel; "endunless" -> nonmac sel;
vars macro til; "until" -> nonmac til;
vars macro lit; "enduntil" -> nonmac lit;

uses bye;       ;;; Make sure LIB BYE is loaded.

['[]' '[jonc.lib]' '[jonc.auto]'] ncjoin popuseslist -> popuseslist;
delete('USE$POP:[pop.lib.turtle]','[jonc.auto]' :: popautolist) -> popautolist;

false -> popwarnings;
false -> popmishaps;

vedsetup();
lib vedkey5;

define macro ;         ;;; CTRL V to invoke VED
    vedscreenraw();
    if vedvedname = vednullstring then 'temp.p' -> vedvedname endif;
    chain(vedveddefaults, vedvedname,vededitor);
enddefine;

vars oldvederror;
vederror -> oldvederror;

define vederror(string);
    ;;; Change VED's error handling so that if it doesn't recognise
    ;;; a command it tries to interpret it as a POP command
    if string = 'UNKNOWN COMMAND' then
        ':'><vedcommand -> vedargument;
        ved_pop11()
    else
        oldvederror(string)
    endif
enddefine;

define vedlastword() -> vedtemp;
vars vedpositionstack;
    if vedcolumn == 1 then false -> vedtemp; return endif;
    vedpositionpush();
    vedsetlinesize();
    if vedcolumn > vvedlinesize then
        vedtextright()
    elseif vedcolumn-1 > vedleftmargin and vedthisline()(vedcolumn-1) == ` ` then
        vedwordleft()
    endif;
    vedcolumn -> vedtemp;
    vedwordleft();
    if vedcurrentchar() == ` ` then vedwordright() endif;
    if vedtemp > vedcolumn then
        consword(substring(vedcolumn,vedtemp-vedcolumn,vedthisline()))
            -> vedtemp
    else
        false -> vedtemp
    endif;
    vedpositionpop()
enddefine;

define vednextword();
    vars vedpositionstack;
    vedpositionpush();
    vedwordright();
    vedlastword();
    vedpositionpop()
enddefine;

define vedfirstwordisopener();
    vars vedtemp;
    vedtextleft();
    vednextword() -> vedtemp;
    member(vedtemp,vedopeners) or member(vedtemp,vedbackers)
enddefine;

define veddeletetab();
;;;
repeat vedindentstep times
        vedchardelete()
    endrepeat
enddefine;

define myreturn();
;;; This procedure is assigned to the return key, to do indentation
vars dtab vedpositionstack;
    vedpositionpush();
    if sysfiletype(vedcurrent) = 'p' then
        if (vedcolumn /== 1)
                and (vedcharleft(); vedcurrentchar() /== `;`)
                and vedcurrentchar() /== `>`
        then
            if vedfirstwordisopener() then
                1
            else
                true
            endif
        else
            false
        endif -> dtab;
        vedtextleft();
        vedexchangeposition();
        vedcharinsert(`\r`);
        front(vedpositionstack)(2) -> vedpositionstack;
        repeat vedpositionstack - 1 times
            vedcharinsert(32)
        endrepeat;
        if dtab then
            if dtab == 1 then
                vedcharinsert(9)
            elseif vedcolumn >= vedindentstep-1 then
                veddeletetab()
            endif
        endif
    else
        vedtextleft();
        unless vvedlinesize == 0 then
            vedcolumn - 1 -> vedleftmargin
        endunless;
        vedpositionpop();
        vedcharinsert(`\r`)
    endif;
    repeat
        vedsetcursor();
    quitunless(dup(rawcharin()) == 127);
        veddeletetab(erase())
    endrepeat;
    vedinput()
enddefine;

define vedreturn();
    if vedonstatus then
        veddocr()
    else
        myreturn()
    endif
enddefine;

define vedoldabove();
vars vedtemp;
    vedtextleft();
    vedcolumn -> vedtemp;
    vedlineabove();
    vedtemp -> vedcolumn
enddefine;

define vedbelow();
    vedtextright();
    vedreturn();
enddefine;

define vedabove();
    if vedline == 1 then vedoldabove()
    else vedcharup();
        vedbelow()
    endif
enddefine;

false -> vedscrollscreen;

define autovars();
;;; for inserting variable declarations in current file
;;; insert declaration for last word typed in
vars vedpositionstack word;
    vedpositionpush();
    vedlastword() -> word;
    repeat
        vedbacklocate('define');
        quitunless(issubstring('enddefine',1,vedthisline()))
    endrepeat;
    repeat
        vednextline();
        quitunless(length(vedthisline()) > 3 and substring(1,4,vedthisline()) = ';;; ')
    endrepeat;
    if vednextword() == "vars" then
        vedlocate(';');
        vedinsertstring(' '><word)
    else
        vedlineabove();
        vedinsertstring('vars '><word><';')
    endif;
    vedpositionpop()
enddefine;

;;; Now a package to enable VED automatically to expand abbreviations

;;; set up table of abbreviations used by next procedure
vars vedmacprops;
newproperty([   [def 'define']
    [fed 'enddefine']
    [-- '->']
    [%"^"% '=>']
    [%"^^"% '==>']
    [ef 'elseif']
    [fi 'endif']
    [el 'else']
    [rep 'repeat']
    [per 'endrepeat']
    [rof 'endfor']
    [les 'unless']
    [sel 'endunless']
    [til 'until']
    [lit 'enduntil']
    [whi 'while']
    [ihw 'endwhile']
    [pro 'procedure']
    [orp 'endprocedure']
],
        30,false,true) -> vedmacprops;

define vedwordbreak(vedaction);
;;; expands abbreviations whenever a space is typed
vars vedtemp;
    if (vedmacprops(vedlastword()) ->> vedtemp) then
        if vedtemp.isprocedure then
            vedtemp()
        else
            vedcharinsert(` `);
            vedwordleft();
            vedwordleft();
            if vedcurrentchar() == ` ` then
                vedwordright()
            endif;
            vedwordrightdelete();
            vedinsertstring(vedtemp)
        endif
    endif;
    vedaction()
enddefine;

define vedendmac();
;;; expands end into appropriate thing - endif, enduntil, enddefine, etc.
;;; does this by searching up for matching opener. Assume indentation is OK
vars vedpositionstack vedtemp;
    vedcharinsert(` `);
    vedwordleft();
    vedwordleft();
    if vedcurrentchar() == ` ` then
        vedwordright()
    endif;
    vedcolumn -> vedtemp;
    vedpositionpush();
    repeat forever
        if vedline == 1 then
            '' -> vedtemp;
            quitloop
        endif;
        vedcharup();
        vedtextleft();
        if vedcolumn == vedtemp then
            vedwordright();
            if member(.vedlastword.dup,vedopeners) then
                -> vedtemp;
                quitloop
            else
                .erase
            endif
        endif
    endrepeat;
    vedpositionpop();
    vedwordrightdelete();
    vedinsertstring('end'><vedtemp)
enddefine;

vedendmac -> vedmacprops("end");

define vedbigswap();
;;; swaps files, but goes to larger window
    vedswapfiles();
    vedsetwindow()        
enddefine;

define ved_auto();
    vedsetkey(' ',vedwordbreak(% vedcharinsert(%` `%)%));
    vedsetkey(';',vedwordbreak(% vedcharinsert(%`;`%)%));
    vedsetkey(',',vedwordbreak(% vedcharinsert(%`,`%)%));
    vedsetkey('\r',vedwordbreak(% vedreturn %));
    vedsetkey('\n',vedwordbreak(% vedchardown pdcomp vedtextleft %))
enddefine;

define ved_unauto();
;;; resets auto macro stuff
    vedsetkey(' ',vedinsertvedchar);
    vedsetkey(';',vedinsertvedchar);
    vedsetkey('\r',vedreturn);
    vedsetkey('\n',vedchardown pdcomp vedtextleft);
    vedsetkey(',',vedinsertvedchar)
enddefine;

define vedinitfile();
    ;;; run whenever a file is set (or reset) on screen
    if sysfiletype(vedcurrent) = 'p' then
        ved_auto()
    else
        ved_unauto()
    endif;
enddefine;

ved_auto();

uses ved_index;

define vedveddefaults();
vars type;
    if vedcurrent = 'output'
        or (sysfiletype(vedcurrent) ->> type) = 'lis'
        or type = 'log'
    then
        false -> vedwriteable
    endif;
    if vedwriteable then
        vedinput('\^[?Mensureindex\^[?p')
    endif
enddefine;

erase(ved_h);
'temp.p' -> vedvedname;

;;; Tell VED abount files which should not have automatic line break
'.lis' :: ('.t' :: vednonbreakfiles) -> vednonbreakfiles;

false -> vedterminalselect;

uses ved_go;
60 -> ved_go_delay;
800 -> vedautowrite;

define vedendline();
    if vedcolumn = vvedlinesize + 1  then
        vedchardown();
    endif;
    vvedlinesize + 1 -> vedcolumn;
enddefine;

define vedbeginline();
vars vedtemp;
    vedcolumn -> vedtemp;
    vedtextleft();
    if vedcolumn >= vedtemp then
        if vedtemp > vedleftmargin + 1 then
            vedleftmargin + 1 -> vedcolumn
        elseif vedtemp > 1 then
            1 -> vedcolumn
        else
            vedcharup();
            vedtextleft()
        endif
    endif
enddefine;


;;; Map appropriate procedures onto key sequences.
;;; See HELP * ASCII and * STRINGS

vedsetkey('\^[)', vedabove);
vedsetkey('\^[*', vedbelow);
vedsetkey('\^[\^I', veddeletetab);
vedsetkey('\^[#',vedswapfiles);
vedsetkey('\^[x',vedbigswap);
vedsetkey('\^[s',vedsetstatic);
vedsetkey('\r', vedreturn);

vedsetkey('\^A',vedbeginline);
vedsetkey('\^Z',vedendline);
vedsetkey('\^P',ved_pop);
vedsetkey('\^V','\^[?Mved ');
vedsetkey('\^[u',autovars);
============================================================================
PLOGINIT.P Prolog initialisation files

/* ROGER EVANS : initialisation for Prolog - PLOGINIT.P
    compiled as POP-11 when Prolog starts up
*/


'[rogere.prolib]' :: popautolist -> popautolist;
'[rogere.prolib]' :: popuseslist -> popuseslist;

/* Set funtion keys to switch languages:
   assume they transmit ESC then a character.
   So define ESC as a macro which reads next character then
   switches subsystem.
*/
section $-escape(switch_subsystem_to,prolog_macro);

vars POP11code,TOPcode,PROLOGcode;

80 -> POP11code;  /* F0 */
81 -> TOPcode;    /* F1 */
82 -> PROLOGcode; /* F2 */

define vars macro   ;  ;;; ESC - doesn't print
    vars c;
    rawcharin() -> c;
    pr('\n\^G');
    if c == POP11code then
        switch_subsystem_to("pop11");
    elseif c == TOPcode then
        switch_subsystem_to("top");
    elseif c == PROLOGcode then
        switch_subsystem_to("prolog");
    else
        pr('Edit keys don\'t work outside VED\n');
        pr('(at least, most of them don\'t)\n');
        interrupt();
    endif;
enddefine;

nonmac  -> prolog_macro("");      ;;; make it work in Prolog too

section_export("");

section_cancel(current_section);

endsection;


================================================================
;;; PLOGINIT.P --- file compiled as POP11 on Prolog startup
;;;
;;; Jonathan laventhol, 15 July 1983.
;;; ------------------------------------------------------------------------

;;; if there is a PLOGINIT.PL in the login directory then reconsult it
;;;
if   readable('poplib:ploginit.pl')
then prolog_compile('poplib:ploginit.pl')
endif;

;;; how to make a private library accessable via library/1 and showlib
;;;
'disk$2c:[jcl.prolog]' :: prologliblist -> prologliblist;

/* ---- stuff in prolog: invoke prolog compiler for rest of file -----*/

:- prolog_language(prolog).

/* this could be in PLOGINIT.PL */

/* no silly messages */
    :- prolog_gctrace(on).                  /* "off" is the default */

/* member, append, and friends */
    :- library(useful).

/* autoload-or-fail action on unknown predicate */
    :- library(unknown), unknown(_, autoload).      /* "fail" is default" */

/* simple interface to pop11 */
    :- library(simplepop).

/* string printing stuff */
    :- library(strings).

/* make strings print as characters -- uses library(string) stuff */
    portray(S) :-
        string(S), !, writes(S).
===========================================================================

--- C.vms/help/initial.ex
--- Copyright University of Sussex 1991. All rights reserved. ----------
