outmode.tex 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. \section{Outmoded Operations}
  2. \begin{Command}{ED}
  3. The \name{ed} command invokes a simple line editor for REDUCE input
  4. statements.
  5. \begin{Syntax}
  6. \name{ed} \meta{integer} or \name{ed}
  7. \end{Syntax}
  8. \name{ed} called with no argument edits the last input statement. If
  9. \meta{integer} is greater than or equal to the current line number, an error
  10. message is printed. Reenter a proper \name{ed} command or return to the
  11. top level with a semicolon.
  12. The editor formats REDUCE's version of the desired input statement,
  13. dividing it into lines at semicolons and dollar signs. The statement is
  14. printed at the beginning of the edit session. The editor works on one
  15. line at a time, and has a pointer (shown by \name{^}) to the current
  16. character of that line. When the session begins, the pointer is at the
  17. left hand side of the first line. The editing prompt is \name{>}.
  18. The following commands are available. They may be entered in either upper
  19. or lower case. All commands are activated by the carriage return, which
  20. also prints out the current line after changes. Several commands can be
  21. placed on a single line, except that commands terminated by an \key{ESC}
  22. must be the last command before the carriage return.
  23. \begin{itemize}
  24. \item[b]
  25. Move pointer to beginning of current line.
  26. \item[d\meta{digit}]
  27. Delete current character and next (digit-1) characters. An error message
  28. is printed if anything other than a single digit follows d. If there are
  29. fewer than \meta{digit} characters left on the line, all but the final
  30. dollar sign or semicolon is removed. To delete a line completely, use the
  31. k command.
  32. \item[e]
  33. End the current session, causing the edited expression to be reparsed by
  34. REDUCE.
  35. \item[f\meta{char}]
  36. Find the next occurrence of the character \meta{char} to the right of the
  37. pointer on the current line and move the pointer to it. If the character is
  38. not found, an error message is printed and the pointer remains in its
  39. original position. Other lines are not searched. The f command is not
  40. case-sensitive.
  41. \item[i\meta{string}\key{ESC}]
  42. Insert \meta{string} in front of pointer. The \key{ESC} key is your
  43. delimiter for the input string. No other command may follow this one on
  44. the same line.
  45. \item[k]
  46. Kill rest of the current line, including the semicolon or dollar sign
  47. terminator. If there are characters remaining on the current line, and it
  48. is the last line of the input statement, a semicolon is added to the line
  49. as a terminator for REDUCE. If the current line is now empty, one of the
  50. following actions is performed: If there is a following line, it becomes
  51. the current line and the pointer is placed at its first character. If the
  52. current line was the final line of the statement, and there is a previous
  53. line, the previous line becomes the current line. If the current line was
  54. the only line of the statement, and it is empty, a single semicolon is
  55. inserted for REDUCE to parse.
  56. \item[l]
  57. Finish editing this line and move to the last previous line. An error message
  58. is printed if there is no previous line.
  59. \item[n]
  60. Finish editing this line and move to the next line. An error message is
  61. printed if there is no next line.
  62. \item[p]
  63. Print out all the lines of the statement. Then a dotted line is printed, and
  64. the current line is reprinted, with the pointer under it.
  65. \item[q]
  66. Quit the editing session without saving the changes. If a semicolon is
  67. entered after q, a new line prompt is given, otherwise REDUCE prompts you
  68. for another command. Whatever you type in to the prompt appearing after
  69. the q is entered is stored as the input for the line number in which you
  70. called the edit. Thus if you enter a semicolon, neither \nameref{input}
  71. \name{ed} will find anything under the current number.
  72. \item[r\meta{char}]
  73. Replace the character at the pointer by \meta{char}.
  74. \item[s\meta{string}\key{ESC}]
  75. Search for the first occurrence of \meta{string} to the right of the
  76. pointer on the current line and move the pointer to its first character.
  77. The \key{ESC} key is your delimiter for the input string. The s function
  78. does not search other lines of the statement. If the string is not found,
  79. an error message is printed and the pointer remains in its original
  80. position. The s command is not case-sensitive. No other command may
  81. follow this one on the same line.
  82. \item[x \meta{or space}]
  83. Move the pointer one character to the right. If the pointer is already at
  84. the end of the line, an error message is printed.
  85. \item[- \meta{(minus)}]
  86. Move the pointer one character to the left. If the pointer is already at the
  87. beginning of the line, an error message is printed.
  88. \item[?]
  89. Display the Help menu, showing the commands and their actions.
  90. \end{itemize}
  91. \begin{Examples}
  92. \explanation{(Line numbers are shown in the following examples)} \\
  93. 2: >>x**2 + y; \\
  94. X^{2} + Y \\
  95. 3: >>ed 2; \\
  96. X**2 + Y; \\
  97. ^ \\
  98. For help, type '?' \\
  99. ?- (Enter three spaces and \key{Return}) \\
  100. X**2 + Y; \\
  101. ^ \\
  102. ?- r5 \\
  103. X**5 + Y; \\
  104. ^ \\
  105. ?- fY \\
  106. X**5 + Y; \\
  107. ^ \\
  108. ?- iabc (Terminate with \key{ESC} and \key{Return}) \\
  109. X**5 + abcY; \\
  110. ^ \\
  111. ?- ---- \\
  112. X**5 + abcY; \\
  113. ^ \\
  114. ?- fbd2 \\
  115. X**5 + aY; \\
  116. ^ \\
  117. ?- b \\
  118. X**5 + aY; \\
  119. ^ \\
  120. ?- e \\
  121. AY + X^{5} \\
  122. 4: >>procedure dumb(a); \\
  123. >>write a; \\
  124. DUMB \\
  125. 5: >>dumb(17); \\
  126. 17 \\
  127. 6: >>ed 4; \\
  128. PROCEDURE DUMB (A); \\
  129. ^ \\
  130. WRITE A; \\
  131. ?- fArBn \\
  132. WRITE A; \\
  133. ^ \\
  134. ?- ibegin scalar a; a := b + 10; (Type a space, \key{ESC}, and \key{Return}) \\
  135. begin scalar a; a := b + 10; WRITE A; \\
  136. ?- f;i end \key{ESC}, \key{Return} \\
  137. begin scalar b; b := a + 10; WRITE A end; \\
  138. ^ \\
  139. ?- p \\
  140. PROCEDURE DUMB (B); \\
  141. begin scalar b; b := a + 10; WRITE A end; \\
  142. - - - - - - - - - - \\
  143. begin scalar b; b := a + 10; WRITE A end; \\
  144. ^ \\
  145. ?- e \\
  146. DUMB \\
  147. 7: >>dumb(17); \\
  148. 27 \\
  149. 8: >> &
  150. \end{Examples}
  151. \begin{Comments}
  152. Note that REDUCE reparsed the procedure \name{dumb} and updated the
  153. definition.
  154. Since REDUCE divides the expression to be edited into lines at semicolons or
  155. dollar sign terminators, some lines may occupy more than one line of screen
  156. space. If the pointer is directly beneath the last line of text, it
  157. refers to the top line of text. If there is a blank line between the
  158. last line of text and the pointer, it refers to the second line
  159. of text, and likewise for cases of greater than two lines of text. In other
  160. words, the entire REDUCE statement up to the next terminator is printed, even
  161. if it runs to several lines, then the pointer line is printed.
  162. You can insert new statements which contain semicolons of their own into the
  163. current line. They are run into the current line where you placed them
  164. until you edit the statement again. REDUCE will understand the set of
  165. statements if the syntax is correct.
  166. If you leave out needed closing brackets when you exit the editor, a message
  167. is printed allowing you to redo the edit (you can edit the previous line
  168. number and return to where you were). If you leave out a closing
  169. double-quotation mark, an error message is printed, and the editing must be
  170. redone from the original version; the edited version has been destroyed.
  171. Most syntax errors which you inadvertently leave in an edited statement are
  172. caught as usual by the REDUCE parser, and you will be able to re-edit the
  173. statement.
  174. When the editor processes a previous statement for your editing, escape
  175. characters are removed. Most special characters that you may use in
  176. identifiers are printed in legal fashion, prefixed by the exclamation
  177. point. Be sure to treat the special character and its escape as a pair in
  178. your editing. The characters \name{( ) # ; ' `} are different. Since
  179. they have special meaning in Lisp, they are double-escaped in the editor.
  180. It is unwise to use these characters inside identifiers anyway, due to the
  181. probability of confusion.
  182. If you see a Lisp error message during editing, the edit has been aborted.
  183. Enter a semicolon and you will see a new line prompt.
  184. Since the editor has no dependence on any window system, it can be used if you
  185. are running REDUCE without windows.
  186. \end{Comments}
  187. \end{Command}
  188. \begin{Command}{EDITDEF}
  189. The interactive editor \nameref{ed} may be used to edit a user-defined
  190. procedure that has not been compiled.
  191. \begin{Syntax}
  192. \name{editdef}(\name{identifier})
  193. \end{Syntax}
  194. where \name{identifier} is the name of the procedure. When \name{editdef}
  195. is invoked, the procedure definition will be displayed in editing mode,
  196. and may then be edited and redefined on exiting from the editor using
  197. standard \nameref{ed} commands.
  198. \end{Command}