|The Revised Maclisp Manual||Page A-25|
|LEDIT||Special Form||(LEDIT . filespec)|
[PDP-10 Only] LEDIT is a Lisp/Emacs interface package with the TECO half of the system written as an Emacs library.
LEDIT package has two main purposes: It allows the user to type a command in Lisp which will cause control to be transferred to an Emacs job, passing the Emacs a string of commands to be executed. It also allows the user in Emacs to type a command which will cause control to be transferred to a Lisp job, passing to Lisp a file of code to be read.
For full documentation on LEDIT, run “meta-X Info” from Emacs.
|INF-EDIT||Special Form||(INF-EDIT [jname [filename]])|
[ITS Only] Starts an inferior editor under with a jobname of jname. A filename can be specified to load the job from. If the filename is not specified or incompletely specified, the default filename “TS jname” is tried in the user's working dir, the user's home dir, and finally the system directories.
For full documentation on LISPT, run “meta-X Info” from Emacs.
The In-Core Lisp Editor
|EDIT||Special Form||(EDIT fn)|
The Binford Editor -- available only on the PDP-10; Multics Maclisp has a function named edit which does something different.
This lisp structure editor has been in lisp for some time. Commands are given similar to Teco commands, action is taken on some expression currently in the working space, and a window around the pointer is printed out after every command execution.
The argument, fn, is not evaluated. It is searched for a functional definition (one of the property names given in the list which is the value of the symbol EDIT). The editor is then entered.
The editor reads a command, ended with a space. If the command takes arguments, they are typed as ordinary lisp s-expressions following the command. Commands which can accept a variable number of arguments must have the symbol $$ (altmode altmode) following the last argument to terminate the argument sequence.
Q Quit from the editor. Y sym $$ Yanks sym's function definition. YV sym $$ Yanks sym's value cell. YP sym VALUE $$ Yanks sym's value cell. (archaic form) YP sym prop $$ Yanks prop property of sym. YP sym $$ Yanks the whole plist of sym. J Jump to top of the working expression. S e1 e2 ... $$ Search for the sequence e1, e2, ... S $$ Repeat last search attempt. I e1 e2 ... $$ Insert e1, e2, ... at cursor. K Kill expression at right into value of $$. KI exp Replace expression at right with exp. -KI exp Replace expression at left with exp. IV exp Insert the value of exp at cursor. EV exp Evaluate an expression, typing result.
The next group of commands admit an optional numeric (Base 10.) argument, preceeding the command, to be interpreted as a replication number:
F Move forward (to the right) past one token (a paren or an atom). -B Same as F. B Move back (to the left) past one token (a paren or an atom) -F Same as B. R Move to the right past the next s-expression. L Move to the left past the previous s-expression. D Move `down' into the first non-atomic s-expression to the right. U Move `up' (to the left) out of the s-expression containing the cursor.
The following commands deal with manipulating virtual parentheses. (Note: Exercise care with these commands -- misplacing a virtual paren can cause odd results.)
( Insert a virtual open paren. ) Insert a virtual close paren. D( Virtually delete an open paren. D) Virtually delete a close paren. () Restructure things, making virtual paren changes take effect.
The following commands save/restore the editor context. (Warning: sym is SETQ'd to remember the necessary info.)
SS sym Name this spot sym so it can be returned to later. RS sym Return to a spot named sym.
The following commands related to what info is typed out during editing:
SP Toggle on/off auto-display of info around the cursor (default is on). P Displays info around the cursor (for use when auto-display is off). PW Sets the width of window (in tokens) to its arg.
EDIT is user-extensible. Putting an EDIT property on a symbol makes it an editor command, and when invoked, that function is called with three arguments: a repeat count (default 0), a current `left-list' (the value of $$$), and a current `up-list.'
If EDIT reads a command whose name is not recognized, then if the atom of that name has an edit property, then that property should be a function.
The function may do anything it likes, but will probably want to operate on the function being edited. The editor's cursor is represented by two data structures, the `left-list' (2nd arg) and the `up-list' (3rd arg); the former says how to back up at the current level of list, the latter says how to back up a level of list structure. The left-list is the value of the atom $$$, and the up-list is the value of the atom ^^^.
The car of the left-list is the level of list structure being edited; the cursor is considered to be before the caar of the left-list. The cdr of the left-list is the left-list for the previous point in this level of list.
The up-list is a stack of old left-lists.
The following functions are useful utilities for building new editor functions, and illustrate the correct way to manipulate the left-list and up-list:
;; Sub-primitive functions (DEFUN EDCAR NIL (AND $$$ (NOT (ATOM (CAR $$$))))) (DEFUN EDCAAR NIL (AND (EDCAR) (NOT (ATOM (CAAR $$$))))) ;; The utilities (DEFUN RIGHT NIL (IF (EDCAR) (SETQ $$$ (CONS (CDAR $$$) $$$)))) (DEFUN LEFT NIL (IF (AND $$$ (CDR $$$)) (SETQ $$$ (CDR $$$)))) (DEFUN DOWN NIL (IF (EDCAAR) (SETQ ^^^ (CONS $$$ ^^^) $$$ (NCONS (CAAR $$$))))) (DEFUN UP NIL (IF (AND ^^^ (CAR ^^^) (CDR ^^^)) (SETQ $$$ (CAR ^^^) ^^^ (CDR ^^^)))) (DEFUN YANK (FN) (LET ((PL (GETL FN EDIT))) (IF (NOT PL) (PRINC "??") (SETQ ^^^ NIL $$$ (NCONS PL))))) (DEFUN SPLICE (IT) (COND ((AND (LEFT) (EDCAR)) (RPLACD (CAR $$$) IT) (RIGHT)) ((AND (UP) (EDCAR)) (RPLACA (CAR $$$) IT) (DOWN)))) (DEFUN KILL NIL (PROG1 (CAAR $$$) (SPLICE (IF (EDCAR) (CDAR $$$) (CAR $$$))))) (DEFUN INSERT (IT) (SPLICE (CONS IT (AND $$$ (CAR $$$)))) (RIGHT)) ;; Notice that LEFT, RIGHT, UP, and DOWN return NIL if they fail. ;; KILL returns the thing killed (the standard editor command ;; "K" puts this thing into the value cell of "$$".) ;; As two examples of new editor commands, consider "XCH" ;; (Note that names of editor commands must be three characters or ;; fewer), which transposes the next two items after the cursor, ;; and "BRY", which buries the next thing in <argument> levels ;; of list structure. (DEFUN (XCH EDIT) (N) N ;ignored (INSERT (PROG1 (KILL) (RIGHT)))) (DEFUN (BRY EDIT) (N) (IF (EDCAR) (DO ((I (MAX N 1) (- I 1))) ((ZEROP I)) (SPLICE (RPLACA (CAR $$$) (NCONS (CAAR $$$)))))))
For example, in a mythical system built on Maclisp which used some new property name, such as MAGIC to hold function definitions, one might add the name MAGIC to the list of properties that the EDIT function knows about by doing:
The value of the symbol $$ (double altmode, not double dollarsign) is the last value killed by a K-like command in the Binford editor.
This symbol is initially unbound and becomes bound only after executing such a command.
The value of the symbol $$$ (triple altmode, not triple dollarsign) is the back-up chain for the Binford Editor, the car of which will be pointing to the place in your function where the current edit cursor is. Thus, one may use the editor to position the edit cursor, and then run other programs that “take it from there.”
This symbol is initially unbound and becomes bound only after invoking the editor.
The value of the symbol ^^^ (triple uparrow) is the up-list for the Binford Editor.
|The Revised Maclisp Manual (Sunday Morning Edition)|
Published Sunday, December 16, 2007 06:17am EST, and updated Sunday, July 6, 2008.