ED INDEX

ED _ _ _ _ _ _ _ _ _ _ _ _ command

The ed command invokes a simple line editor for REDUCE input statements.

syntax:

ed<integer> or ed

edcalled with no argument edits the last input statement. If <integer> is greater than or equal to the current line number, an error message is printed. Reenter a proper ed command or return to the top level with a semicolon.

The editor formats REDUCE's version of the desired input statement, dividing it into lines at semicolons and dollar signs. The statement is printed at the beginning of the edit session. The editor works on one line at a time, and has a pointer (shown by ^) to the current character of that line. When the session begins, the pointer is at the left hand side of the first line. The editing prompt is >.

The following commands are available. They may be entered in either upper or lower case. All commands are activated by the carriage return, which also prints out the current line after changes. Several commands can be placed on a single line, except that commands terminated by an ESC must be the last command before the carriage return.

_ _ _ b Move pointer to beginning of current line.

_ _ _ d<digit> Delete current character and next (digit-1) characters. An error message is printed if anything other than a single digit follows d. If there are fewer than <digit> characters left on the line, all but the final dollar sign or semicolon is removed. To delete a line completely, use the k command.

_ _ _ e End the current session, causing the edited expression to be reparsed by REDUCE.

_ _ _ f<char> Find the next occurrence of the character <char> to the right of the pointer on the current line and move the pointer to it. If the character is not found, an error message is printed and the pointer remains in its original position. Other lines are not searched. The f command is not case-sensitive.

_ _ _ i<string>ESC Insert <string> in front of pointer. The ESC key is your delimiter for the input string. No other command may follow this one on the same line.

_ _ _ k Kill rest of the current line, including the semicolon or dollar sign terminator. If there are characters remaining on the current line, and it is the last line of the input statement, a semicolon is added to the line as a terminator for REDUCE. If the current line is now empty, one of the following actions is performed: If there is a following line, it becomes the current line and the pointer is placed at its first character. If the current line was the final line of the statement, and there is a previous line, the previous line becomes the current line. If the current line was the only line of the statement, and it is empty, a single semicolon is inserted for REDUCE to parse.

_ _ _ l Finish editing this line and move to the last previous line. An error message is printed if there is no previous line.

_ _ _ n Finish editing this line and move to the next line. An error message is printed if there is no next line.

_ _ _ p Print out all the lines of the statement. Then a dotted line is printed, and the current line is reprinted, with the pointer under it.

_ _ _ q Quit the editing session without saving the changes. If a semicolon is entered after q, a new line prompt is given, otherwise REDUCE prompts you for another command. Whatever you type in to the prompt appearing after the q is entered is stored as the input for the line number in which you called the edit. Thus if you enter a semicolon, neither input ed will find anything under the current number.

_ _ _ r<char> Replace the character at the pointer by <char>.

_ _ _ s<string>ESC Search for the first occurrence of <string> to the right of the pointer on the current line and move the pointer to its first character. The ESC key is your delimiter for the input string. The s function does not search other lines of the statement. If the string is not found, an error message is printed and the pointer remains in its original position. The s command is not case-sensitive. No other command may follow this one on the same line.

_ _ _ x <or space> Move the pointer one character to the right. If the pointer is already at the end of the line, an error message is printed.

_ _ _ - <(minus)> Move the pointer one character to the left. If the pointer is already at the beginning of the line, an error message is printed.

_ _ _ ? Display the Help menu, showing the commands and their actions.

examples:

(Line numbers are shown in the following examples)

 

2: >>x**2 + y; 

X^{2} + Y 

3: >>ed 2; 

  X**2 + Y; 

  ^ 

For help, type '?' 

?-                  (Enter three spaces and key{Return}) 

  X**2 + Y; 

     ^ 

?- r5 

  X**5 + Y; 

     ^ 

?- fY 

  X**5 + Y; 

	 ^ 

?- iabc (Terminate with key{ESC} and key{Return}) 

  X**5 + abcY; 

	    ^ 

?- ---- 

  X**5 + abcY; 

	^ 

?- fbd2 

  X**5 + aY; 

	  ^ 

?- b 

  X**5 + aY; 

  ^ 

?- e 

AY + X^{5} 

4: >>procedure dumb(a); 

>>write a; 

DUMB 

5: >>dumb(17); 

17 

6: >>ed 4; 

  PROCEDURE DUMB (A); 

  ^ 

WRITE A; 

?- fArBn 

  WRITE A; 

  ^ 

?- ibegin scalar a; a := b + 10; (Type a space, key{ESC}, and key{Return}) 

  begin scalar a; a := b + 10; WRITE A; 

?- f;i end key{ESC}, key{Return} 

  begin scalar b; b := a + 10; WRITE A end; 

					  ^ 

?- p 

 PROCEDURE DUMB (B); 

 begin scalar b; b := a + 10; WRITE A end; 

 -  -  -  -  -  -  -  -  -  - 

  begin scalar b; b := a + 10; WRITE A end; 

					  ^ 

?- e 

DUMB 

7: >>dumb(17); 

27 

8: >> 

Note that REDUCE reparsed the procedure dumb and updated the definition.

Since REDUCE divides the expression to be edited into lines at semicolons or dollar sign terminators, some lines may occupy more than one line of screen space. If the pointer is directly beneath the last line of text, it refers to the top line of text. If there is a blank line between the last line of text and the pointer, it refers to the second line of text, and likewise for cases of greater than two lines of text. In other words, the entire REDUCE statement up to the next terminator is printed, even if it runs to several lines, then the pointer line is printed.

You can insert new statements which contain semicolons of their own into the current line. They are run into the current line where you placed them until you edit the statement again. REDUCE will understand the set of statements if the syntax is correct.

If you leave out needed closing brackets when you exit the editor, a message is printed allowing you to redo the edit (you can edit the previous line number and return to where you were). If you leave out a closing double-quotation mark, an error message is printed, and the editing must be redone from the original version; the edited version has been destroyed. Most syntax errors which you inadvertently leave in an edited statement are caught as usual by the REDUCE parser, and you will be able to re-edit the statement.

When the editor processes a previous statement for your editing, escape characters are removed. Most special characters that you may use in identifiers are printed in legal fashion, prefixed by the exclamation point. Be sure to treat the special character and its escape as a pair in your editing. The characters ( ) # ; ' ` are different. Since they have special meaning in Lisp, they are double-escaped in the editor. It is unwise to use these characters inside identifiers anyway, due to the probability of confusion.

If you see a Lisp error message during editing, the edit has been aborted. Enter a semicolon and you will see a new line prompt.

Since the editor has no dependence on any window system, it can be used if you are running REDUCE without windows.