(FILECREATED " 3-Aug-84 23:24:01" {PHYLUM}<3-LISP>EMACS>PRIMIT.FPKG;1 18709 changes to: (FNS EMACS.SETCARETPTR EMACS.SETFILEPTR EMACS.SHOWCARET EMACS.GETFILEPTR EMACS.NUMERIC.ARG EMACS.NUMERIC.ARG.P EMACS.CHAR.FWD EMACS.CHAR.BACK EMACS.POINT EMACS.WORD.FWD EMACS.WORD.BACK EMACS.WORD.END EMACS.WORD.BEGINNING EMACS.SEXPR.FWD EMACS.SEXPR.BACK SKIP.PREFIX.CHARACTERS.BACK EMACS.BALANCED.SEXPR.BACK EMACS.PARA.BEGINNING EMACS.PARA.END EMACS.BOL EMACS.EOL EMACS.REGION.BEGINNING EMACS.REGION.END EMACS.FILENAME EMACS.PUT EMACS.GET EMACS.SAVE.ALL.FILES EMACS.BOFP EMACS.EOFP EMACS.DELETE EMACS.MARK.REGION EMACS.INIT.ARRAY EMACS.SKIP.SYNTAX.FWD EMACS.SKIPTO.SYNTAX.FWD EMACS.SKIP.SYNTAX.BACK EMACS.SKIPTO.SYNTAX.BACK EMACS.BACKPEEKBIN)) (* Copyright (c) 1984 by Xerox Corporation) (PRETTYCOMPRINT PRIMITCOMS) (RPAQQ PRIMITCOMS ((INITVARS (EMACS.ARRAY NIL) (EMACS.CR 1) (EMACS.WS 2) (EMACS.NONCR 4) (EMACS.NONWS 8) (EMACS.WORD 16)) (FNS EMACS.SETCARETPTR EMACS.SETFILEPTR EMACS.SHOWCARET EMACS.GETFILEPTR EMACS.NUMERIC.ARG EMACS.NUMERIC.ARG.P EMACS.CHAR.FWD EMACS.CHAR.BACK EMACS.POINT EMACS.WORD.FWD EMACS.WORD.BACK EMACS.WORD.END EMACS.WORD.BEGINNING EMACS.SEXPR.FWD EMACS.SEXPR.BACK SKIP.PREFIX.CHARACTERS.BACK EMACS.BALANCED.SEXPR.BACK EMACS.PARA.BEGINNING EMACS.PARA.END EMACS.BOL EMACS.EOL EMACS.REGION.BEGINNING EMACS.REGION.END EMACS.FILENAME EMACS.PUT EMACS.GET EMACS.SAVE.ALL.FILES EMACS.BOFP EMACS.EOFP EMACS.DELETE EMACS.MARK.REGION EMACS.INIT.ARRAY EMACS.SKIP.SYNTAX.FWD EMACS.SKIPTO.SYNTAX.FWD EMACS.SKIP.SYNTAX.BACK EMACS.SKIPTO.SYNTAX.BACK EMACS.BACKPEEKBIN))) (RPAQ? EMACS.ARRAY NIL) (RPAQ? EMACS.CR 1) (RPAQ? EMACS.WS 2) (RPAQ? EMACS.NONCR 4) (RPAQ? EMACS.NONWS 8) (RPAQ? EMACS.WORD 16) (DEFINEQ (EMACS.SETCARETPTR (LAMBDA (STREAM PTR) (* "Gumby" " 3-Aug-84 23:23") (* Move caret to new filepos. *) (TEDIT.SETSEL STREAM (ADD1 (IMIN (IMAX PTR 0) (GETEOFPTR STREAM))) 0 'LEFT) (EMACS.SETFILEPTR STREAM PTR))) (EMACS.SETFILEPTR (LAMBDA (STREAM PTR) (* "Gumby" " 3-Aug-84 23:23") (* patch around bug in TEDIT SETFILEPTR. *) (PROG ((EOF (GETEOFPTR STREAM))) (IF (IGREATERP EOF 0) THEN (SETFILEPTR STREAM (IMIN EOF PTR)) (SETFILEPTR STREAM (IMIN EOF PTR)))))) (EMACS.SHOWCARET (LAMBDA (STREAM) (* "Gumby" " 3-Aug-84 23:23") (PROG (PTR) (SETQ PTR (EMACS.GETFILEPTR STREAM)) (EMACS.SETCARETPTR STREAM PTR) (TEDIT.NORMALIZECARET (fetch (EMACSSTREAM TEXTOBJ) of STREAM)) (EMACS.SETCARETPTR STREAM PTR)))) (EMACS.GETFILEPTR (LAMBDA (STREAM) (* "Gumby" " 3-Aug-84 23:23") (* Returns the position of the caret (0 if empty buffer) *) (OR (CAR (NLSETQ (GETFILEPTR STREAM))) 0))) (EMACS.NUMERIC.ARG (LAMBDA (STREAM) (* "Gumby" " 3-Aug-84 23:23") (OR (WINDOWPROP (fetch (EMACSSTREAM WINDOW) of STREAM) 'NUMERIC.ARG) 1))) (EMACS.NUMERIC.ARG.P (LAMBDA (STREAM) (* "Gumby" " 3-Aug-84 23:23") (WINDOWPROP (fetch (EMACSSTREAM WINDOW) of STREAM) 'NUMERIC.ARG))) (EMACS.CHAR.FWD (LAMBDA (STREAM QTY) (* "Gumby" " 3-Aug-84 23:23") (* Forward QTY chars. *) (EMACS.SETFILEPTR STREAM (IMIN (GETEOFPTR STREAM) (IPLUS (EMACS.GETFILEPTR STREAM) (OR QTY 1)))))) (EMACS.CHAR.BACK (LAMBDA (STREAM QTY) (* "Gumby" " 3-Aug-84 23:23") (* Backward QTY chars. *) (EMACS.SETFILEPTR STREAM (IMAX 0 (IDIFFERENCE (EMACS.GETFILEPTR STREAM) (OR QTY 1)))))) (EMACS.POINT (LAMBDA (STREAM) (* "Gumby" " 3-Aug-84 23:23") (\BIN STREAM) (\BACKBIN STREAM))) (EMACS.WORD.FWD (LAMBDA (STREAM QTY) (* "Gumby" " 3-Aug-84 23:23") (* Forward QTY words + whitespace. *) (FOR I FROM 1 TO (IMAX QTY 1) DO (EMACS.SKIP.SYNTAX.FWD STREAM EMACS.WS) (EMACS.SKIP.SYNTAX.FWD STREAM EMACS.NONWS)))) (EMACS.WORD.BACK (LAMBDA (STREAM QTY) (* "Gumby" " 3-Aug-84 23:23") (* Backward QTY words + whitespace. *) (FOR I FROM 1 TO (IMAX QTY 1) DO (EMACS.SKIP.SYNTAX.BACK STREAM EMACS.WS) (EMACS.SKIP.SYNTAX.BACK STREAM EMACS.NONWS)))) (EMACS.WORD.END (LAMBDA (STREAM) (* "Gumby" " 3-Aug-84 23:23") (* Forward to end of current word. *) (EMACS.SKIP.SYNTAX.FWD STREAM EMACS.NONWS) (EMACS.SKIP.SYNTAX.FWD STREAM EMACS.WS))) (EMACS.WORD.BEGINNING (LAMBDA (STREAM) (* "Gumby" " 3-Aug-84 23:23") (* Backward to front of current word. *) (EMACS.SKIP.SYNTAX.BACK STREAM EMACS.NONWS) (EMACS.SKIP.SYNTAX.BACK STREAM EMACS.WS))) (EMACS.SEXPR.FWD (LAMBDA (STREAM) (* "Gumby" " 3-Aug-84 23:23") (RESETLST (RESETSAVE \BQUOTELEVEL (IQUOTIENT MAX.FIXP 2)) (* Don%'t let BQUOTE screw us *) (READ STREAM)))) (EMACS.SEXPR.BACK (LAMBDA (STREAM) (* "Gumby" " 3-Aug-84 23:23") (PROG (CHAR CLOSE.PTR) (EMACS.SKIP.SYNTAX.BACK STREAM EMACS.WS) (IF (EMACS.BOFP STREAM) THEN (ERROR!)) (SETQ CHAR (\BACKBIN STREAM)) (IF (EQ CHAR (CHARCODE ")")) THEN (EMACS.BALANCED.SEXPR.BACK STREAM (CHARCODE "(") (CHARCODE ")")) (SKIP.PREFIX.CHARACTERS.BACK STREAM) (RETURN NIL)) (IF (EQ CHAR (CHARCODE "]")) THEN (EMACS.BALANCED.SEXPR.BACK STREAM (CHARCODE "[") (CHARCODE "]")) (SKIP.PREFIX.CHARACTERS.BACK STREAM) (RETURN NIL)) (IF (EQ CHAR (CHARCODE "%"")) THEN (PROG NIL AGAIN (WHILE (AND (NOT (EMACS.BOFP STREAM)) (NEQ (SETQ CHAR (\BACKBIN STREAM)) (CHARCODE %"))) DO (* Keep reading. *)) (IF (EQ (EMACS.BACKPEEKBIN STREAM) (CHARCODE %%)) THEN (\BACKBIN STREAM) (GO AGAIN))) (SKIP.PREFIX.CHARACTERS.BACK STREAM) (RETURN NIL)) (IF (MEMBER CHAR (CHARCODE ("(" "["))) THEN (ERROR!)) (EMACS.SKIP.SYNTAX.BACK STREAM EMACS.WORD) (SKIP.PREFIX.CHARACTERS.BACK STREAM)))) (SKIP.PREFIX.CHARACTERS.BACK (LAMBDA (STREAM) (* "Gumby" " 3-Aug-84 23:23") (EMACS.SKIP.SYNTAX.BACK STREAM EMACS.WS) (WHILE (AND (NOT (EMACS.BOFP STREAM)) (MEMBER (EMACS.BACKPEEKBIN STREAM) (CHARCODE ("," "↑" "\" "'")))) DO (\BACKBIN STREAM) (EMACS.SKIP.SYNTAX.BACK STREAM EMACS.WS)) (EMACS.SKIP.SYNTAX.FWD STREAM EMACS.WS))) (EMACS.BALANCED.SEXPR.BACK (LAMBDA (STREAM OPENER CLOSER) (* "Gumby" " 3-Aug-84 23:23") (OR (NLSETQ (PROG ((CLOSE.PTR (EMACS.GETFILEPTR STREAM)) CHAR) (IF (AND (EQUAL EMACS.LAST.CLOSE.PTR CLOSE.PTR) (EQ EMACS.LAST.STREAM.FLASHED STREAM) (EQ CLOSER EMACS.LAST.CLOSE.CHARACTER)) THEN (EMACS.SETFILEPTR STREAM EMACS.LAST.CORRESPONDING.OPEN.PTR) ELSE (WHILE (NEQ (SETQ CHAR (EMACS.BACKPEEKBIN STREAM)) OPENER) DO (EMACS.SEXPR.BACK STREAM)) (IF (NOT CHAR) THEN (ERROR!)) (\BACKBIN STREAM) (SETQ EMACS.LAST.CLOSE.PTR CLOSE.PTR) (SETQ EMACS.LAST.STREAM.FLASHED STREAM) (SETQ EMACS.LAST.CLOSE.CHARACTER CLOSER) (SETQ EMACS.LAST.CORRESPONDING.OPEN.PTR (EMACS.GETFILEPTR STREAM))))) (PROGN (SETQ EMACS.LAST.STREAM.FLASHED NIL) (ERROR!))))) (EMACS.PARA.BEGINNING (LAMBDA (STREAM PTR) (* "Gumby" " 3-Aug-84 23:23") (* Sets FILEPTR at beginning of Tedit line wrt filepos PTR. *) (IF PTR THEN (EMACS.SETFILEPTR STREAM PTR)) (EMACS.SKIP.SYNTAX.BACK STREAM EMACS.NONCR) (EMACS.GETFILEPTR STREAM))) (EMACS.PARA.END (LAMBDA (STREAM PTR) (* "Gumby" " 3-Aug-84 23:23") (* Sets FILEPTR at end of line wrt filepos PTR. *) (IF PTR THEN (EMACS.SETFILEPTR STREAM PTR)) (EMACS.SKIP.SYNTAX.FWD STREAM EMACS.NONCR) (EMACS.GETFILEPTR STREAM))) (EMACS.BOL (LAMBDA (STREAM PTR) (* "Gumby" " 3-Aug-84 23:23") (EMACS.PARA.BEGINNING STREAM PTR))) (EMACS.EOL (LAMBDA (STREAM PTR) (* "Gumby" " 3-Aug-84 23:23") (EMACS.PARA.END STREAM PTR))) (EMACS.REGION.BEGINNING (LAMBDA (STREAM SELECTION) (* "Gumby" " 3-Aug-84 23:23") (EMACS.SETCARETPTR STREAM (FETCH CH# OF (OR SELECTION (FETCH SEL OF STREAM)))))) (EMACS.REGION.END (LAMBDA (STREAM SELECTION) (* "Gumby" " 3-Aug-84 23:23") (EMACS.SETCARETPTR STREAM (FETCH CHLIM OF (OR SELECTION (FETCH SEL OF STREAM)))))) (EMACS.FILENAME (LAMBDA (STREAM INCREMENT.VERSION) (* "Gumby" " 3-Aug-84 23:23") (PROG ((FILENAME (FETCH FULLFILENAME OF (FETCH TXTFILE OF (fetch (EMACSSTREAM TEXTOBJ) of STREAM)))) UNPACKED) (IF (NOT INCREMENT.VERSION) THEN (RETURN FILENAME) ELSE (SETQ VERSION (LISTGET (UNPACKFILENAME FILENAME) 'VERSION)) (RETURN (PACKFILENAME 'VERSION (IF (AND (NUMBERP VERSION) (NEQ INCREMENT.VERSION 'NONE)) THEN (ADD1 VERSION)) 'BODY FILENAME)))))) (EMACS.PUT (LAMBDA (STREAM DONT.ASK ALWAYS.WRITE) (* "Gumby" " 3-Aug-84 23:23") (PROG (OUTNAME FILE OFILE (TEXTOBJ (TEXTOBJ STREAM))) (IF (NOT (OR (fetch (EMACSSTREAM DIRTY) of STREAM) ALWAYS.WRITE)) THEN (TEDIT.NOTIFY STREAM "(No changes need to be written)" '(CLEARW)) ELSE (SETQ FILE (IF (AND DONT.ASK (NEQ (EMACS.FILENAME STREAM) T)) THEN (EMACS.FILENAME STREAM 'NONE))) (COND (FILE (* We were given a file to use.) (SETQ OFILE FILE)) ((type? STREAM (fetch TXTFILE of TEXTOBJ)) (* There was a file!) (SETQ OFILE (UNPACKFILENAME (fetch FULLFILENAME (fetch TXTFILE of TEXTOBJ)))) (AND OFILE (LISTPUT OFILE 'VERSION NIL)) (SETQ OFILE (TEDIT.GETINPUT TEXTOBJ "File to PUT to: " (AND OFILE (PACKFILENAME OFILE))))) (T (SETQ OFILE (TEDIT.GETINPUT TEXTOBJ "File to PUT to: ")))) (SETQ OFILE (U-CASE (MKATOM OFILE))) (TEDIT.PUT (fetch (EMACSSTREAM TEXTOBJ) of STREAM) OFILE) (TEDIT.NOTIFY STREAM (CONCAT "Written: " (EMACS.FILENAME STREAM)) '(CLEARW)) (EMACS.SET.BUFFER.NAME STREAM))))) (EMACS.GET (LAMBDA (STREAM FILENAME) (* "Gumby" " 3-Aug-84 23:23") (PROG (WINDOW (FILENAME (U-CASE (MKATOM (OR FILENAME (TEDIT.GETINPUT STREAM "File to Get: ")))))) (IF FILENAME THEN (SETQ WINDOW (ALREADY.BEING.EDITED FILENAME)) (IF (NOT WINDOW) THEN (TEDIT.GET (fetch (EMACSSTREAM TEXTOBJ) of STREAM) FILENAME) (EMACS.SETCARETPTR STREAM 0) (* Why is this necessary? *) (EMACS.SET.BUFFER.NAME STREAM) ELSE (TTY.PROCESS (WINDOWPROP WINDOW 'PROCESS))))))) (EMACS.SAVE.ALL.FILES (LAMBDA NIL (* "Gumby" " 3-Aug-84 23:23") (FOR BUFFER IN EMACS.ALL.BUFFERS DO (NLSETQ (IF (FETCH \DIRTY OF (TEXTOBJ BUFFER)) THEN (* Allow user to ↑G any files he doesn%'t want to save) (ERSETQ (EMACS.PUT (FETCH STREAMHINT OF (TEXTOBJ BUFFER))))) )) (PRINT 'Done.) NIL)) (EMACS.BOFP (LAMBDA (STREAM) (* "Gumby" " 3-Aug-84 23:23") (ZEROP (EMACS.GETFILEPTR STREAM)))) (EMACS.EOFP (LAMBDA (STREAM) (* "Gumby" " 3-Aug-84 23:23") (IEQP (EMACS.GETFILEPTR STREAM) (GETEOFPTR STREAM)))) (EMACS.DELETE (LAMBDA (STREAM PTR1 PTR2) (* "Gumby" " 3-Aug-84 23:23") (* Delete between PTR1 & PTR2 inclusive. *) (PROG ((PTR (EMACS.GETFILEPTR STREAM)) LENGTH) (IF (AND (ZEROP PTR1) (ZEROP PTR2)) THEN (RETURN)) (IF (ILESSP PTR2 PTR1) THEN (* Avoid screw *) (SETQ PTR1 (PROG1 PTR2 (SETQ PTR2 PTR1)))) (SETQ PTR1 (IMAX 0 PTR1)) (SETQ PTR2 (IMIN (GETEOFPTR STREAM) PTR2)) (SETQ LENGTH (IDIFFERENCE (ADD1 PTR2) PTR1)) (TEDIT.DELETE STREAM (ADD1 PTR1) LENGTH) (EMACS.SETFILEPTR STREAM (COND ((ILEQ PTR PTR1) PTR) ((ILEQ PTR PTR2) PTR1) (T (IDIFFERENCE PTR LENGTH))))))) (EMACS.MARK.REGION (LAMBDA (STREAM PTR1 PTR2) (* "Gumby" " 3-Aug-84 23:23") (* Set selection to be between PTR1 & PTR2 inclusive. *) (* Makes a pending delete selection *) (PROG ((PTR (EMACS.GETFILEPTR STREAM))) (IF (ILESSP PTR2 PTR1) THEN (* Avoid screw *) (SETQ PTR1 (PROG1 PTR2 (SETQ PTR2 PTR1)))) (SETQ PTR1 (IMAX 0 PTR1)) (SETQ PTR2 (IMIN (GETEOFPTR STREAM) PTR2)) (TEDIT.SETSEL STREAM (ADD1 PTR1) (IDIFFERENCE (ADD1 PTR2) PTR1) T)))) (EMACS.INIT.ARRAY (LAMBDA NIL (* "Gumby" " 3-Aug-84 23:23") (OR EMACS.ARRAY (SETQ EMACS.ARRAY (ARRAY 256 'BYTE 0 0))) (FOR I FROM 0 TO 255 DO (SETA EMACS.ARRAY I (LOGOR EMACS.NONCR EMACS.NONWS))) (FOR I IN (LIST (CHARCODE TAB) (CHARCODE LF) (CHARCODE SP)) DO (SETA EMACS.ARRAY I (LOGOR EMACS.WS EMACS.NONCR))) (SETA EMACS.ARRAY (CHARCODE CR) (LOGOR EMACS.WS EMACS.CR)) (SETQ EMACS.LAST.STREAM.FLASHED NIL) (SETQ EMACS.LAST.CORRESPONDING.OPEN.PTR NIL) (SETQ EMACS.LAST.CLOSE.PTR NIL) (SETQ EMACS.LAST.CLOSE.CHARACTER NIL) (* Define EMACS.WORD for 3-LISP. *) (FOR I FROM 0 TO 255 DO (SETA EMACS.ARRAY I (LOGOR (ELT EMACS.ARRAY I) EMACS.WORD))) (FOR I IN (CONSTANT (LIST (CHARCODE "(") (CHARCODE ")") (CHARCODE "[") (CHARCODE "]") (CHARCODE CR) (CHARCODE LF) (CHARCODE TAB) (CHARCODE SP) (CHARCODE "'") (CHARCODE "↑") (CHARCODE "\") (CHARCODE ",") (CHARCODE "%""))) DO (SETA EMACS.ARRAY I (LOGAND (ELT EMACS.ARRAY I) (LOGNOT EMACS.WORD)))))) (EMACS.SKIP.SYNTAX.FWD (LAMBDA (STREAM CLASS) (* "Gumby" " 3-Aug-84 23:23") (* Skip chars in CLASS. *) (WHILE (AND (NOT (EMACS.EOFP STREAM)) (BITTEST (ELT EMACS.ARRAY (\PEEKBIN STREAM)) CLASS)) DO (\BIN STREAM)))) (EMACS.SKIPTO.SYNTAX.FWD (LAMBDA (STREAM CLASS) (* "Gumby" " 3-Aug-84 23:23") (* Skip to chars in CLASS. *) (WHILE (AND (NOT (EMACS.EOFP STREAM)) (NOT (BITTEST (ELT EMACS.ARRAY (\BIN STREAM)) CLASS))) DO))) (EMACS.SKIP.SYNTAX.BACK (LAMBDA (STREAM CLASS) (* "Gumby" " 3-Aug-84 23:23") (* Skip backwards over chars in CLASS. *) (WHILE (AND (NOT (EMACS.BOFP STREAM)) (BITTEST (ELT EMACS.ARRAY (EMACS.BACKPEEKBIN STREAM)) CLASS)) DO (\BACKBIN STREAM)))) (EMACS.SKIPTO.SYNTAX.BACK (LAMBDA (STREAM CLASS) (* "Gumby" " 3-Aug-84 23:23") (* Skip backwards to chars in CLASS. *) (WHILE (AND (NOT (EMACS.BOFP STREAM)) (NOT (BITTEST (ELT EMACS.ARRAY (\BACKBIN STREAM)) CLASS))) DO))) (EMACS.BACKPEEKBIN (LAMBDA (STREAM) (* "Gumby" " 3-Aug-84 23:23") (IF (GREATERP (GETFILEPTR STREAM) 0) THEN (\BACKPEEKBIN STREAM)))) ) (PUTPROPS PRIMIT.FPKG COPYRIGHT ("Xerox Corporation" 1984)) (DECLARE: DONTCOPY (FILEMAP (NIL (1884 18627 (EMACS.SETCARETPTR 1894 . 2262) (EMACS.SETFILEPTR 2264 . 2673) ( EMACS.SHOWCARET 2675 . 3031) (EMACS.GETFILEPTR 3033 . 3340) (EMACS.NUMERIC.ARG 3342 . 3552) ( EMACS.NUMERIC.ARG.P 3554 . 3754) (EMACS.CHAR.FWD 3756 . 4085) (EMACS.CHAR.BACK 4087 . 4401) ( EMACS.POINT 4403 . 4556) (EMACS.WORD.FWD 4558 . 4948) (EMACS.WORD.BACK 4950 . 5344) (EMACS.WORD.END 5346 . 5680) (EMACS.WORD.BEGINNING 5682 . 6027) (EMACS.SEXPR.FWD 6029 . 6328) (EMACS.SEXPR.BACK 6330 . 7703) (SKIP.PREFIX.CHARACTERS.BACK 7705 . 8137) (EMACS.BALANCED.SEXPR.BACK 8139 . 9075) ( EMACS.PARA.BEGINNING 9077 . 9491) (EMACS.PARA.END 9493 . 9887) (EMACS.BOL 9889 . 10042) (EMACS.EOL 10044 . 10191) (EMACS.REGION.BEGINNING 10193 . 10420) (EMACS.REGION.END 10422 . 10645) (EMACS.FILENAME 10647 . 11239) (EMACS.PUT 11241 . 12566) (EMACS.GET 12568 . 13171) (EMACS.SAVE.ALL.FILES 13173 . 13622) (EMACS.BOFP 13624 . 13778) (EMACS.EOFP 13780 . 13955) (EMACS.DELETE 13957 . 14870) ( EMACS.MARK.REGION 14872 . 15634) (EMACS.INIT.ARRAY 15636 . 16926) (EMACS.SKIP.SYNTAX.FWD 16928 . 17281 ) (EMACS.SKIPTO.SYNTAX.FWD 17283 . 17634) (EMACS.SKIP.SYNTAX.BACK 17636 . 18038) ( EMACS.SKIPTO.SYNTAX.BACK 18040 . 18422) (EMACS.BACKPEEKBIN 18424 . 18625))))) STOP