1
0
mirror of https://github.com/PDP-10/its.git synced 2026-01-19 17:39:17 +00:00
PDP-10.its/src/emacs1/lispt.264
Lars Brinkhoff 2624185d09 Add Lisp-related EMACS libraries:
DOCLSP, ELISP, LEDIT, LISPT, LSPUTL, and XLISP.
2016-12-17 07:09:17 -08:00

12 KiB
Executable File
Raw Blame History

!* -*-TECO-*-!
 
!~FILENAME~:! !LISPT Macros for use with TECO running as an Inferior Job to LISP.!
LISPT

!& Setup LISPT Library:! !S Assigns LISPT text sending macros to ^R commands.
Default setups:
.Z is a q-vector of macros used by LISPT
& LISPT Send Text to Superior :.Z(0)
^R LISPT DEFUN to LISP :.Z(1)
^R LISPT MACSYMA Commands :.Z(2)
^R LISPT Code - Meta-Z :.Z(3)
^R LISPT Rest - C-M-Z :.Z(4)
^R LISPT Buffered Text :.Z(5)
^R LISPT Region Deferred :.Z(6)
^R LISPT Return to DDT - ^_ :.Z(7)
LISPT COMMAND :.Z(8)
^R LISPT REGION TO LISP :.Z(9)
^R LISPT MARK CODE :.Z(10)
^R LISPT Mark DEFUN :.Z(11)
^R LISPT Mark MACSYMA Command :.Z(12)
pointer to *LISPT* buffer :.Z(13)
q-vector of macros for superior :.Z(14)
pointer to current receive buf. :.Z(15)
!
20*5 FS Q VECTOR U.Z
M.M &_LISPT_SEND_TEXT_TO_SUPERIOR U:.Z(0)
M.M ^R_LISPT_DEFUN_to_LISP U:.Z(1)
M.M ^R_LISPT_MACSYMA_COMMANDS U:.Z(2)
M.M ^R_LISPT_Code U:.Z(3)
M.M ^R_LISPT_Rest U:.Z(4)
M.M ^R_LISPT_Buffered_Text U:.Z(5)
M.M ^R_LISPT_Region_Deferred U:.Z(6)
M.M ^R_LISPT_Return_to_DDT U:.Z(7)
M.M &_LISPT_Command U:.Z(8)
M.M ^R_LISPT_Region_to_LISP U:.Z(9)
M.M ^R_LISPT_MARK_CODE U:.Z(10)
M.M ^R_LISPT_Mark_DEFUN U:.Z(11)
M.M ^R_LISPT_Mark_MACSYMA_Command U:.Z(12)
FS B CONS U:.Z(13)
20*5 FS Q VECTOR U:.Z(14)
FS B CONS U:.Z(15)
 
!* setup command dispatch table for requests from superior!
Q:.Z(14) [C -1[0 20 <:I* U:C(%0)> ]0 !* initialize all slots to null!
M.M &_LISPT_READ_JCL U:C(1)
M.M &_LISPT_EDIT_TEXT U:C(2)
M.M &_LISPT_Select_Write_Buffer U:C(3)
M.M &_LISPT_READ_TEXT U:C(4)
M.M &_LISPT_COMMAND_RECEIVER FS SUPERIOR
]C
 
!* These are usually wanted!
M.M ^R_LISPT_CODE U...Z
M.M ^R_LISPT_REST U..Z
M.M ^R_LISPT_Return_to_DDT U._
M.M ^R_LISPT_REGION_To_LISP U:.X()
M.M ^R_LISPT_MARK_CODE U:.X()
M.M ^R_LISPT_Region_Deferred U:.X(@)
M.M ^R_LISPT_Buffered_Text U:.X(Z)
Q:.B ( :I* *LISPT* M(M.M &_Create_Buffer+4) U:.Z(13)
FS XJNAME : F6 [J
F~J LISPT "E M(M.M LISP_MODE
"# F~ODEFundamental "E M(M.M LISP_Mode''
:IODE [0PT] UEDITOR_TYPE !* SET EDITOR TYPE FOR MODE LINE !
QBUFFER_NAME 1 F[ REREAD !* SAVE CURRENT BUFFER IND, SUPPRESS MODLN!
M(M.M SELECT_BUFFER*LISPT*
M(M.M 0_MODE M(M.M SELECT_BUFFERI
F] REREAD ]I ]0
M(M.M &_SET_MODE_LINE
1,M.M &_EMACS_LISPT_SETUP_HOOK [0 !* temporary hack!
Q0"N 0FO..Q LISPT_SETUP_HOOK - Q0 "E
:I* M.V LISPT_SETUP_HOOK''
 
M(0FO..Q LISPT_Setup_Hook F"E W :I* ') !* Macro the setup hook, if any!


!& LISPT Send Text to Superior:! !S Send text between arguments to superior job
Text in the buffer delimited by the arguments is sent
to the superior job. A string argument determines the
type of text being sent. Current choices are LISP,
MACSYMA, and RANDOM. Normally LISP and MACSYMA code is interpreted
by a read-eval-print loop while RANDOM text is just sent as data.
If no text was specified, just return to superior.!
 
!* The protocol for communicating with the superior job: !
!* This macro sets the virtual buffer boundaries around the !
!* text to be zapped; this text will end with a " ^C|^C" just !
!* outside the boundaries. The intention of this delimiter is !
!* that | terminates any open | strings, and ^C should be !
!* to be a read macro character that executes a throw outside !
!* of the read-eval-print loop. Alternatively, the read loop !
!* can check FILEPOS against ZV. !
!* The gap will have been closed up. !
!* A .BREAK 16, is used to return to the superior job. !
!* The following special bits are used in the address field: !
!* 1 LISP code !
!* 2 MACSYMA code !
!* 4 RANDOM text (data) !
!* 10 Return directly to DDT (and then back) !
!* 20 Return directly to DDT but not back !
!* 100 Silent return !
!* 200 !
!* 400 !
!* 1000 Error return for FS SUPERIOR operations !
!* ("back" means when the TTY is returned to the superior LISP !
!* it is returned immediately to TECO. !
!* If none of these bits is set, then no text is to be zapped. !
!* In addition, the 100000 bit must be on. !
 
 & 3 + 1 [1 f* !* get first char, flush the rest!
!* Decode by first 2 bits: !
!* L=0, M=1, R=2 !
fs %OPLSP"E :i*NLI Not_a_LISP_Inferior? fs err '
q1-3"e 4u1 ' !* checking string args is too slow!
f [z f[ vb !* QZ is the end of text!
fs z - qZ f[ vz !* Set VZ between end of text and EOF token!
:I* [..J FR 1F? !* indicate change of environment, close gap!
q1 + 100000. fs exit !* Do .BREAK 16, with code type!
F+  !* Exit this subroutine!

!& LISPT Command:! !C Command for sending code to a MACSYMA or LISP intended
to be used from plain TECO.!
FF"E :M:.Z(3) '
FF-1"E F :M:.Z(3) '
FF-2"E F :M:.Z(4) '
.(  J  fs ^R Mark W M:.Z(9) )J

!^R LISPT Return to DDT:! !^R Redefines the usual macro to return directly to DDT
from under a superior LISP job.!
0[0 FN F+
:I* [..J FR !* Turn off mode line in indicate change!
FF "E 10. '"# 20.' U0 !* No arg, then auto return, else not!
fs %OPLSP "E 0U0' !* If not LISP inferior, plain return!
q0 + 100000. fs exit !* Exit with return to DDT command!
 !* and redisplay!

!^R LISPT Region to LISP:! !^R Send code or text between .,<mark> to superior.
Tries to determine text type first from the contents of the buffer, then by
the current editing mode.!
 
[1[2 :i* RANDOM [A .[P
0fo ..q Editor_Name "e fs ^R mark ' !* Try to win in non EMACS
! "# :' !* otherwise use  pdl
! ,.f U2 U1
!* What kind of code do we have? First try to decide based on buffer contents!
q2,q1 :fb */  \;  \$  )  NIL [4 !* Look for various chars!
q4"e q2j 0,0a f ; $ +1 "G :iA MACSYMA' !* Handle case of no CRLF at end!
"# :i* FO ..Q MODE [3 !* Now try MODE!
f~ 3 LISP "e q3uA '
"# f~ 3 MACSYMA "e q3uA'
"# :iA RANDOM'''
ozap'
q4+4 "g :iA MACSYMA'"# :iA LISP''
!zap! qPj q1,q2 M:.Z(0) A !* Call zapper subroutine!


!^R LISPT DEFUN to LISP:! !^R Send DEFUN's immediately to a LISP superior job.
A DEFUN is defined by CRLF ( or ( at the beginning of the buffer. ))!
.[p F[ S STRING
:L .[0
-:S
( () "L L' !* search for the beginning of a DEFUN!
.[1 FLL :L !* end of defun!
.-Q0 "L :S"L 0L .U1'' !* point was previously between defuns!
Q1 J F"L +1' FLL !* move over specified number !
.,q1 f (qpj) M:.Z(F"N W 6') LISP !* Send DEFUN's to LISP!


!^R LISPT Mark DEFUN:! !^R Mark a DEFUN for deferred reading by LISP.!
1, :M:.Z(1) !* Run ^R LISPT DEFUN to LISP !

!^R LISPT MACSYMA Commands to MACSYMA:! !^R Send MACSYMA code to a MACSYMA superior job.
Sends the command being pointed at by the cursor and arg-1 subsequent commands.!
.[p :l .[0 !L1!
-:s */  \;  \$ ( !* find the beginning!
 )+ 1 "E -:s /* "e :i*CFE Comment_Format_Error fs err'
O L1'
.-B"N :F [1 W Q1-Q0+1"G O L1'' !* if cursor on the same line, again!
:L ^ F !* skip leading CRLFs!
J
.U1
!L2! ,f F"e 1'( !* absolute value!
) :s /*  \;  \$ ( !* Now search for the end!
)+1 "E :s*/"e :i*CFE Comment_Format_Error fs err'
O L2'
q1,. (qpj) f M:.Z( F"N W 6') MACSYMA


!^R LISPT Mark MACSYMA Commands:! !^R Mark MACSYMA commands for deferred reading.!
1, :M:.Z(2) !* Run ^R LISPT MACSYMA Commands !

!^R LISPT Code:! !^R Send code to Superior LISP.
Run ^R LISPT MACSYMA in MACSYMA mode, otherwise run ^R LISPT DEFUN.!
:i* FO ..Q Mode [0
f ^ :M:.Z( f~ 0 MACSYMA "N 1'"# 2')

!^R LISPT Mark Code:! !^R Mark for reading, either LISP or MACSYMA expressions.!
:i* FO ..Q Mode [0
f ^ :M:.Z( f~ 0 MACSYMA "N 11'"# 12')

!^R LISPT Rest of Buffer:! !^R Send this piece of code and the rest of the buffer.
Sends it as LISP or MACSYMA code if in LISP or MACSYMA mode, otherwise as text.!
:i* FO ..Q Mode [0 [1 F[ S String .[P
f~ 0 LISP "E :L .[0 -:S !* If LISP mode, go to top of lists!
( () "L L' .[1 FLL :L !* then to the end of the current one!
.-Q0"L :S"L 0L .U1'' !* if we were between defuns, go next!
Q1J .,Z (QPJ)M:.Z(0) LISP ' !* zap to the end !
f~ 0 MACSYMA "E :L .[1 !L1!
-:S \;  \$ */!* find the beginning!
) + 3 "E !* encountered a comment!
-:S /* "E :i*CFE Comment_Format_Error fs err'
O L1'
:F U0W Q0-Q1+1 "G .-B"N O L1'' !* on same line? go back!
.-B "N :L ^ F !* skip leading CRLF's!
J'
.,Z (QPJ) M:.Z(0) MACSYMA '
0L .,Z (QPJ) M:.Z(0) RANDOM !* otherwise, random text !


!^R LISPT Buffered Text:! !^R Send code buffered up to Superior.!
Q:.Z(13) F"N [..O '
"# W ]..N :I*NLB No_LISPT_text_Buffer fs err'
z-b"E ]..O]..N :I*LBE LISPT_Text_Buffer_Empty Fs err'
bj z: W M:.Z(9) !* Macro ^R LISPT Region to LISP!
hk 0 !* empty the buffer !

!^R LISPT Region Deferred:! !^R Save the region for sending to superior job.!
Q:.Z(13) "E :I*NLB No_LISPT_Text_Buffer fs err '
FS RGETTY "N ^FT (Text_Saved) ' !* Acknowledge !
FF-3"E F* F '"# :,. ' F( !* use args if provided!
Q:.Z(13) [..O zj !* just like ^R Append Buffer!
.-B"G I !* Blank lines between items !

'
) G (-FS QP SLot0

!& LISPT COMMAND Receiver:! !S A macro to be assigned to FS Superior,
interprets requests from its superior job. An argument specifies
what command the superior is requesting. If the left half of the arg
is 0, the right half is a command, otherwise the left half is a count
and the right half is an address in the superior to read from.
Commands are invoked by indexing into a q-vector in :.Z(14).!
Q:.Z(14) [Q !* load dispatch, check lh not 0 !
/1000000. [Y !* left half of superior's command!
qy"N 4'"# &17.' [C !* and get command number!
1:< qy , ( &777777. ) M:Q(qC (]C]Y]Q !* compute args, clean up!
)) F"E W 100.'( !* if no ret val, silent!
> F"N U..0 F[ B bind G..0 !* If error, let superior read error msg!
BJ 1F? 101000.FS EXIT W
- FS QP unwind
100.(' !* and return silently !
) +100000. fs exit

!& LISPT Edit Text:! !S Handle a request by superior to edit text.
Edit the last buffer selected by the superior.!
q:.Z(15) [..o
f+ 
hk
0

!& LISPT READ JCL:! !S Simply read JCL and macro it, if any.
By convention, not allowed to directly modify the buffer.!
M( F[ MODIFIED !* no mods !
.,(FJ).FX*( !* snarf JCL !
F] ModifiedW))
0

!& LISPT READ TEXT:! !S Read text from the superior.
First arg is a character count, and the second arg is a word address.!
Q:.Z(15) [..O !* If a buffer specified, select it!
F[ D DEV !* so default isn't set to USR!
400377. F[ D FN1 !* specify superior job!
0 f[ d fn2 !* 0 so FN1 interpreted as a job!
er usr: !* Open the USR channel to superior!
*5 fs if access !* set access pointer!
 FY EC !* Yank in text from the superior!
0 !* return !

!& LISPT SELECT WRITE BUFFER:! !S Select a buffer for receiving text from LISP.
Reads JCL for the name of the buffer.!
0FO..Q Buffer_Name "E q:.z(15) u..Y !* if undefined, not in an EMACS so!
FS B CONS U:.Z(15) 0' !* just cons up a new one!
qBuffer_Name [B !* save buffer for restoring !
1 F[ REREAD !* fake out redisplay, mode line display!
FN :I*B  M(M.M Select_Buffer !* restore buffer later!
F[ Modified .,(FJ). FXB !* get the buffer name from LISP!
FQB-1"L :iB MAIN ' !* default to MAIN !
qB M(M.M Select_Buffer !* select or create the specified buffer !
q:.b( qBuffer_index+4) U:.Z(15) !* Install new buffer !
100100. fsexit !* temporary exit, so superior can read BB!
0 !* and exit !