The Revised Maclisp ManualThe PitmanualPage A-25
Published by HyperMeta Inc.
 
Prev | Index | Next
[Blue Marble]
Climate Change
What issue has higher priority?


Edit

LEDIT


LEDITSpecial 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.

LISPT


INF-EDITSpecial 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 filenameTS 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.


LISPTFunction(LISPT)

[ITS Only] A synonym for the no-argument case of INF-EDIT.

The In-Core Lisp Editor


EDITSpecial 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.

Commands are:

 
  Quit from the editor. 
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
 Jump to top of the working expression. 
e1 e2 ... $$ Search for the sequence e1, e2, ... 
$$ Repeat last search attempt. 
e1 e2 ... $$ Insert e1, e2, ... at cursor. 
 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:

 
Move forward (to the right) past one token (a paren or an atom). 
-B Same as F. 
Move back (to the left) past one token (a paren or an atom) 
-F Same as B. 
Move to the right past the next s-expression. 
Move to the left past the previous s-expression. 
Move `down' into the first non-atomic s-expression to the right. 
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). 
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 $$$)))))))

EDITValueNIL

EDIT holds a list of the names for the “editible” properties looked for by the EDIT function when seeking a functional definition for a symbol.

Since the EDIT library is not initially loaded, the default value of EDIT is misleading. When the library loads, if the variable EDIT is null, it will be set to (EXPR FEXPR MACRO).

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:

(SETQ EDIT (CONS 'MAGIC (OR EDIT '(EXPR FEXPR MACRO))))

$$Valueunspecified

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.


$$$Valueunspecified

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.


^^^Valueunspecified

The value of the symbol ^^^ (triple uparrow) is the up-list for the Binford Editor.


[Blue Marble]
Climate Change
Can hydrogen-powered vehicles really help us in time?

The Revised Maclisp Manual (Sunday Morning Edition)
Published Sunday, December 16, 2007 06:17am EST, and updated Sunday, July 6, 2008.
Prev | Index | Next