Google
 

Trailing-Edge - PDP-10 Archives - mit_emacs_170_teco_1220 - emacs/crl.emacs
There are no other files named crl.emacs in the archive.
!* -*-TECO-*-!
!^R Extended Command:! !^R Read an extended command from the terminal with completion.
This command reads the name of a function, with completion,
followed by the string arguments for the function.  Then the
function is called.  Completion is done as the function name is typed
(for more information type the HELP key while entering the name).
Follow the function name with a  and then the arguments; end with <cr>.
For customization info see the source code.!

!* Internals:
Uses & Read Command Name and & Read Line to echo at bottom of screen.
If the variable Read Command Prompt exists it specifies the prompt string;
otherwise "MM " is used.  A numeric argument is passed along to the M-X
command.  The command string is saved on the minibuffer ring
so that ^R Re-execute Mini will redo it, and ^R Execute Mini
with argument will get it back for editing.!

    fsQPPtr[7			    !* Save PDL ptr so cleanup before execute!
    [0[1[2[5[6			    !* save regs!

    :i0 ff"n		    !* 0: Start with null string!
	ff&1"N :\u0'	    !* 0: Post-comma argument!
	ff&2"N :\u1 :i01,0'	    !* 0: Pre-comma arg too!
	:i00_'		    !* 0: Argument(s) and space!

    :i*M-X_fo..qRead_Command_Promptu2	    !* get prompt string in q2!
    :i1
    <	4,q1m(m.m&_Read_Command_Name)02u1u6
	fq1-1"l '		    !* if empty arg or rubbed out then return!
	q6&2"n :i6 1;'		    !* ended with CR, make null arglist.!
	@:i*| :ft m(m.mDescribe)1 |f[HelpMac
				    !* set help macro to do describe!
	q6"n @ft'		    !* If command name already printed, add Altmode.!
	1#q6&1,m(m.m&_Read_Line)021u6	    !* read arguments!
	-1fsQPUnwind		    !* restore help macro!
	fq6;			    !* exit unless empty or rubbed out!
	>			    !* keep trying!
    :i10M(M.M_1)6   !* Stick <n>MM ...  around typed command!
    f1:"l		    !* If there is a ^] in the string,!
      1fo..qQuote_Execute_Command"n	    !* user want ^] quoting?!
	f[BBind g1		    !* yes!
	j <:s; i>	    !* replace each one by two of them.!
	hx1 f]BBind''
    f=(q:.n(0)f"e w :i*')1"n  !* If this command not same as previous command,!
	q.n[..o zj -5d		    !* push this command onto ring buffer of!
	j 5,0i ]..o		    !* minibuffer commands.!
	q1u:.n(0)'		    !* made room, now store it!
    :m( q1(q7fs qp unwind))	    !* Now execute command after restoring outer environment.!
!^R Instant Extended Command:! !^R Run extended command; let it read its own arguments.
This command is the same as ^R Extended Command except that
it does not read any string arguments; the function itself does so.
This allows special processing such as completion to be done
on arguments which are function names or filenames.!

!*
Internals:
Uses & Read Command Name to echo at bottom of screen.
If the variable Instant Command Prompt exists it specifies the prompt string;
otherwise "C-M-X " is used.  A numeric argument is passed along to the MM
command.!

    fsQPPtr[7 [0[1		    !* Save PDL ptr so cleanup before execute!

    :i0 ff"n		    !* 0: Start with null string!
	ff&1"N :\u0'	    !* 0: Post-comma argument!
	ff&2"N :\u1 :i01,0'	    !* 0: Pre-comma arg too!
	:i00_'		    !* 0: Argument(s) and space!

    :i*C-M-X_fo..qInstant_Command_Promptu1   !* get prompt string in q1!
    9,f01u1
    fq1:"g 0'			    !* if empty arg or rubbed out then return!
    f:m(m.m1(q7fsQPUnwind)) !* Goto MM command!
!& Read Command Name:! !S Read in an command name, with completion.
Rubout, ^D, ^U and ^L perform editing.  Space and Altmode do completion.
? lists choices.

Takes a prompt-string as a following string argument.
A numeric argument is the initial contents of the string to be accumulated.
A pre-comma arg containing the "4" bit means don't wait for a confirming CR;
the "2" bit means complete over the symbol table in CRL List using the prefix
string in CRL Prefix.  The "8" bit is deliberately ignored.
The "16" bit permits names that don't match.
The "32" bit means CR is allowed with an empty name.

The F^K command with the "8" bit set in its precomma arg
calls & Read Command Name, passing along its arguments.

Two values are returned, the second being the completed string
(or 0 if exit was due to over-rubout).
The first is bit-decoded; 1 means we displayed the string,
2 means the terminating character was Return, 4 means we terminated
without doing completion so the string might not match any alternative.

See Source code for more info.!

!* If the 16 bit is set in the pre-comma arg, then names
which don't match are permitted.  How to specify one is
controlled by the value of CRL Non-Match Method:
2 bit:  CR will terminate without performing completion
4 bit:  LF will terminate without performing completion
8 bit:  if user types CR and completion is not possible,
        typing another CR will terminate without performing completion
	(this overrides the presence of the 2 bit); also, typing
	C-CR will terminate without performing completion (if your
	terminal cannot generate the 9-bit character set, then you
	may want to set the 4 bit also, so the you can use LF)
The default value is 2.  (A value of 1 will prohibit non-matches
in ALL cases.)

CRL Name Lister can (if not zero) contain a function for use
in assembling the list of matching items, for "?".
This function is used as follows:  

	(1) For each name to display, the function is called with no
	pre-comma arg, and a post-comma arg which is an index into CRL
	List (which can be found in Q.1).  The function should insert
	information about that name into the buffer beginning at
	point, and include a CRLF at the end.

	(2) The function is called with a pre-comma arg of 1, with the
	buffer containing all the names.  The entire buffer will be
	displayed after the function returns.  (Some things it can do:
	sort the names, insert a heading, etc.)

If the variable CRL Name Type is nonzero, it should contain
a string such as "buffer" which fits in the slot:
"You are entering a <name type> name..."
It is used in help messages.

If the variable CRL Help is nonzero, it is printed
after the regular help message is given.
*!

    [0[1[2[3[4[5[6[7		    !* save regs!
    1F[^P CASE			    !* Ignore case when sorting!
    :I6			    !* Read prompt string argument!
    0[8				    !* Q8 is nonzero if we are echoing.!
    0[9				    !* Q9 is nonzero => type altmode after completed name.!
    q..q[.1 :i*MM_[.2		    !* Q.1 and Q.2 for normal case of MM-command completion --!
				    !* use standard symbol table and "MM " prefix to select!
				    !* only the MM-variables.!

    0[.0			    !* Q.0 contains whether and how to allow non-matches.!
    &20."n 2fo..Q CRL_Non-match_Methodu.0
             q.0&8 "n q.0&777777777775.u.0 ''

    &2"n qCRL_Listu.1	    !* Q.1 has the symbol table to complete over.!
	   0fo..qCRL_Prefixu.2	    !* Q.2 has the prefix string -- only variables starting!
	   q.2"e :i.2''	    !* with that are considered, and the returned name does!
				    !* not include the prefix string.!

    0[.3			    !* Q.3 = number of chars not to erase & reprint!
				    !* when completion occurs (already complete & verified)!
    0[.4			    !* Number of chars of name printed.!
    0f[HelpMacro		    !* Help character should be seen be FI!
    f[BBind fq()"g g()'	    !* Make temp buffer to accumulate command name in.!
    q..ou5
    o Read

 !Redisp!
    1u8
    :i*CfsEchoDis		    !* Clear echo area!
    fs rgetty"e @ft
'
    @ft6 @ht		    !* Retype prompt string and input!
    zu.4
    o Read

 !BarfCR!			    !* Here if cannot complete and user!
				    !* typed CR!
    fg				    !* Type bell.!
    fs rgetty"n @ft_'	    !* Force cursor back to echo area on ITS.!
    q8"n @ft'		    !* type altmode to inform user!
    Q.0&8 "N			    !* if 8-bit of CRL Non-Match Method is set!
 "E FI:FI-  !* and user types another CR,!
        q8 "N @FT
'
	q8+6,(hx*) ''		    !* returns with what user typed!
    o Redisp			    !* otherwise flush altmode!

 !Barf!				    !* Here if tried to complete and no match!
    fg				    !* and that is not allowed.  Type bell.!
    fs rgetty"n @ft_'	    !* Force cursor back to echo area on ITS.!
    o Read

 !Changed!			    !* Come here when completion augments the string.!
    q8"n			    !* If we have started printing,!
      fs rgetty"n
        q.4-q.3< :i*X fs echo dis >	    !* Reprint any chars that weren'r verified!
	q.3,z@t'		    !* and print new ones.!
      "# q.4,z@t'		    !* On printing tty, just print new ones.!
      zu.4'
    zu.3			    !* All chars we have are verified, even if not printed.!
!* If name is fully complete, think about exiting.!
    q9"n &4"n			    !* If pre-comma arg has the 4 bit, return completed name.!
	   q8,q3'
	 q8"n @ft 0u9	    !* If waiting for CR with completed string, type an!
           :fi-13"n o Redisp'''    !* altmode, but if next char isn't cr, flush the Alt.!
!Read!
    q8"e 0:"e o Redisp''
    @:fiu0 q0-4110."e oHELP'	    !* Handle HELP!
) "eq0-(200.+* Handle C-CR!
	q.0&8 "n		    !* return immediately!
	  q8 "n @FT		    !* echo return!
 '
	  q8+4,(HX*)''
    fiu0
    q0-32"e ."e o Read''	    !* Ignore initial spaces.!
    q0f
?"l	    !* Not a special character!
        q0-
 "e Q.0&4 "n	    !* LF typed so return immediately!
	  q8+4,(HX*) ''
	q0-"e fiu0'		    !*  quotes the next character!
	q0i			    !* Add char to buffer.!
	q8"n fs^RMode"n -1@t %.4 ''  !* Echo if in ^R mode!
	oRead'			    !* back for more!
    q0-"e			    !* Turn ^R into ^ and R.!
        i^ R
	q8"n fs ^RMode"n -2@t %.4 %.4''
	oRead'
    q0-177."e			    !* Rubout?!
        q8"e q0fsReRead oRedisp'
	z"e q8,0 '		    !* Rubout when string empty returns 0.!
	zj 0au0 -d		    !* Put char being rubbed in Q0, and remove from buffer.!
	fsrgetty"e @ft0 '   !* Type character if cannot erase!
	"#  q0-40."l oRedisp'	    !* Erase if possible!
	    :i*X fs echodis
	    Q.4-1u.4
	    q.4-q.3"l q.4u.3'
	    oRead''
    q0-
"e oRedisp'		    !* ^L redisplays the current string!
    q0f:"l hk 0u.3 oRedisp' !* ^D and ^U flush input and reprompt.!
    q0-?"e			    !* Help requested?!
	&2"e			    !* Completing over MM-commands, so load BARE.!
	  f=(0,2:g5)^R"e	    !* Must do it befor the F[BBIND.!
	    m(m.m &_Load_Bare)''

	f[BBind :ft		    !* Get buffer to mess with!

	&2"e			    !* Completing over MM-commands, so look thru libraries.!
	  fs :ej page*5120+400000000000.u7 !* ptr to 1st file!
	  <   fq7:;
	      g(q7m.m~DIRECTORY~)  !* get directory for file!
	      q7+4+fq7u7	    !* ptr to next file!
	      >
	  j .u3 i

	  <   2r :s
5;	      0l q3,.k l	    !* save command name!
	      .-z; .u3 0:l
	      > q3,zk'		    !* Done mapping down library space.!

				    !* Now pick out possibles from the symbol table.!

	:fo.1.25,0fu3  !* Q3: index to first match in symbol table.!
	:fo.1.25,0fu4	    !* Q4: index to last match in symbol table.!
	q4-q3/q:.1(0) <		    !* iterate over all matches in symbol table.!
	    0fo..q CRL_Name_Listeru7
	    q7"n q3m7'		    !* Either call user's routine!
	    "#			    !* or do the standard thing.!
	      q:.1(q3)u7	    !* Q7: Matching symbol name!
	      fq.2,fq7g7 i
 '				    !* insert variable name!

	    q3+q:.1(0)u3	    !* next match in symbol table!
	    >

	j
	&2"e < :s~; 0lk>'	    !* Don't mention functions with ~ in their names.!
	0fo..q CRL_Name_Listeru7
	q7"n 1,m7'		    !* Either call user's routine!
	"# 
	    l  		    !* or sort list,!
	  j < .-z; x1 l < .-z; 1f=1"N 1;' k > >    !* remove duplicates!
	  '

	ft Here_are_the_possible_completions_of_what_you_have_typed:

	ht 0fsflushedw f]BBind    !* Type the matching commands!
	0u..h f oRedisp'

!*** Character typed is space or altmode or CR.!
 !Retry!

"e		q0- !* if CR, see if we should return without!
				    !* doing completion. return if...!
      (Q.0&2"'n)(		    !* 2-bit of CRL Non-Match Method is set or...!
      )  ((z"'e)&(&40."'n)) "n  !* empty name and 32-bit of arg is set!
        q8"n @FT
 '
	Q8+6,(HX*) ''

    &2"e z-1"e 0a:fcfLVKEIW:"l !* Hack one-letter abbreviations if want MM-name.!
      h@fc
      f~5L"e i ist_'
      f~5V"e i iew_'
      f~5K"e i ill_'
      f~5E"e i dit_'
      f~5I"e i nsert_'
      f~5W"e i hat_'
      o Changed'''		    !* Done hacking one-letter abbreviations.!

    :i3 :i4			    !* Q3 has the largest thing we abbreviate!
				    !* Q4 has the smallest!
    :fo.1.25,0fu1	    !* get offset of the smallest symbol!
    fq.1/5-q1"g q:.1(q1)u2	    !* whose name we abbreviate!
	f~2.2,0f-fq.2"g fq.2,fq2:g2u4''    !* and use it as smallest!
    :fo.1.25,0fu1    !* get offset of the largest symbol!
    q1-1"g q:.1(q1-q:.1(0))u2	    !* whose name we abbreviate!
	f~2.2,0f-fq.2"g fq.2,fq2:g2u3''    !* and use as largest!

    &2"e			    !* Now map down library space if we want an MM-command.!
      f=(0,2:g5)^R"e		    !* If name starts with ^R, make built-in functions avail.!
        m(m.m &_Load_Bare)'
      fs :ej page*5120+400000000000.u7	    !* ptr to 1st file!
      f[BBind			    !* get temp. buffer to do G's into!
      <	fq7:;			    !* exit if no more files!
	q7+8+fq(q7+4)u2		    !* ptr to FO table of file!
	:fo25,0f*5u1
	fq2-q1"g
	    q1,q1+5g2		    !* If smallest thing we abbreviate in this file!
	    .-5fsword+q2u1	    !* is smaller than smallest so far, it is new smallest!
	    f~14"l q1u4''
	:fo25,0f*5u1
	q1-14"g
	   q1-10,q1-5g2		    !* Same for largest thing we abbreviate in this file!
	   .-5fsword+q2u1
	   f~13"g q1u3''
	hk q7+4+fq7u7		    !* ptr to next file!
	>  f]BBind'

    f~34u1			    !* get no. of chars of A and B that match!
    q1"l			    !* if smallest > largest then no match.!
      (&20."'e)(q0-32"'n) "n
 "E o Baq0-' "# o Barf ''

      :i7 q7u2'		    !* but that is ok if non-match ok!
				    !* and user typed a space!
    "# q3u7 q1"n 0,q1-1:g3u7'	    !* q7 gets common initial segment of q3 and q4.!
       z,fq7:g7u2'		    !* Q2 gets that, minus the chars we already have.!
"e fq0-q7"e q4u3 0u1''  !* CR: if smallest is initial seg of biggest,!
				    !* regard it as a full completion.!
    q0-32"e			    !* Space: complete only the first word.!
      fq2"e q1"n		    !* if not exact match, but no completion possible,!
        0,0a-32"e oBarf'	    !* barf if second space in a row.!
	32i q8"n @ft_ %.4' oRead''    !* but allow one space to be forced in.!
      32f2+1u2 q2"g	    !* Space and completion is possible: stop!
	0,z+q2:g7u7''		    !* at first space.!
    "# fq2"e q1"n
         fq4-z"n		    !* Not space and ambiguous => barf unless exact match.!
	"e q0-fCR'
	           "# oBarf''
	 q4u3'''		    !* Exact match => regard as fully completed.!
    f~34"e fq3-fq7"e		    !* Entire name has been completed.!
"e q8"q0-t
' 2+q8,(:i*3)'		    !* If char typed is CR, return completed name.!
				    !* Copy the name, in case it comes from BARE.!
      1u9''			    !* Otherwise, say name is complete.!
    hkg7 o Changed		    !* Stick in completed text, maybe redisplay, continue.!

 !HELP!
    fiw :ftYou_are_typing_in_
    &2"e ftthe_name_of_an_EMACS_extended_command	    !* Normal MM-name completion.!
	   :i7_command'
    "# 0fo..q CRL_Name_Typeu7	    !* Completion over some arbitrary list.!
       fq7"g :I7_7 '
       "# :I7 '
       ft a7_name '
    ft.
Use_Rubout_to_delete_previous_characters;_use__to_delete_the_whole_thing.
Typing_Space_or_Altmode_causes_as_much_of_the_name_as_possible_to_be
filled_in_for_you_(this_is_called_completion).
Type_?_to_list_all_the7_names_which_match_what_you_have_typed.

    &6-4"e ft			    !* no CR required and completing!
				    !* over command names; assume that!
				    !* this was called from M-X!
If_completion_fills_in_the_entire7_name_an_Altmode_()_appears.
__You_can_then_start_typing_the_arguments_to_the_command.
__Terminate_them_with_a_Return.__If_there_are_no_arguments,
__you_can_use_just_Return_after_a_sufficient_abbreviation.'

    "# ft
If_completion_fills_in_the_entire7_name,_
      &4"e 			    !* CR required!
ft an_Altmode_()_appears. '
      "#				    !* no CR required!
ft it_will_be_chosen. '

      Q.0&2"e ft		    !* CR completes!
Typing_Return_will_complete_the7_name_and_terminate.
        &40."n ft		    !* also null entry allowed!
__You_may_also_type_Return_if_there_are_no_other_characters,
__to_enter_a_null7_name ''

      Q.0&8 "n ft		    !* 2 CR's does complete!
If_completion_is_not_possible_after_typing_Return,_typing_a_second
Return_will_terminate_the7_name,_without_completion.  (An_altmode
will_appear_after_you_type_the_first_Return,_as_a_reminder.) '

      "# ft			    !* CR doesn't complete!
Typing_Return_will_terminate_the7_name,_without_completion. '

      Q.0&4 "n ft		    !* LF doesn't complete!
Typing_Linefeed_will_terminate_the7_name,_without_completion. '

      0fo..q CRL_HelpU7	    !* more help info!
      q7"n FT
7 ''

    FT

    0u..h f oRedisp