Next: , Previous: , Up: Top   [Contents][Index]

5 Procedure-oriented commands

Files of REDUCE source code frequently consist mainly of procedure definitions. This is certainly true of symbolic-mode code, and hence it is true of most of the source code of the REDUCE system itself. REDUCE mode provides the following operations on procedures. They work on all kinds of REDUCE procedures provided they contain the keyword procedure somewhere within the first statement of their definition.

A procedure is considered to begin at the first non-white-space character of the definition, and to end after the statement defining the procedure body. White space and the first newline after the procedure body are always considered to be part of the procedure. The commands to mark, kill and reformat a procedure also include all blank lines after the procedure definition, because this seems most convenient in practice. Some procedure-oriented commands support a prefix argument.

The two commands for moving over procedures accept a positive integer argument that indicates by how many procedures to move – the default is 1. These commands do not move in the opposite direction if given a negative argument, in which case they do not move at all.

M-x reduce-forward-procedure

Move forward to the next end of a procedure. With a numeric argument, do it that many times.

M-x reduce-backward-procedure

Move backward to the next start of a procedure. With a numeric argument, do it that many times.

Regardless of whether point is within a procedure or not, these two commands move respectively to the first following end of a procedure, or the first preceding start of a procedure. To move to the start of the next procedure, move forward to its end and then move backward to its start.

The remaining commands do not accept an argument because (even without an argument) they can change large portions of text. Marking a procedure is the basis of the other operations on procedures.

M-x reduce-mark-procedure

Put the mark after the next end of a procedure and point at the start of that procedure. A procedure ends after any trailing white space. With a numeric argument, mark that many following procedures including this one.

C-c k
M-x reduce-kill-procedure

Kill the procedure (and trailing white space) ending after point.

M-x reduce-indent-procedure

Indent the procedure (and trailing white space) ending after point. See Indenting REDUCE code automatically.

It is often desirable to be able to see as much as possible of a procedure definition within the current window. The standard Emacs command reposition-window (see Scrolling in The Emacs Editor) attempts to do this for Lisp functions, and the command reduce-reposition-window provides a harness to apply this function to REDUCE procedures, to which the standard key C-M-l is rebound.

M-x reduce-reposition-window

Reposition the procedure containing point to maximize its visibility within the window. See Scrolling in The Emacs Editor, and see the documentation for the function reposition-window for details.

To restrict all editing to a single REDUCE procedure, the standard Emacs key C-x n d that runs the command narrow-to-defun is rebound to a function to narrow to the current procedure.

C-x n d
M-x reduce-narrow-to-procedure

Make text outside the current procedure invisible. The procedure visible is the one that contains point or follows point. With a prefix argument, narrow to the following arg procedures including this one. See Narrowing in The Emacs Editor.

Next: , Previous: , Up: Top   [Contents][Index]