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


4 Statement-oriented commands

The most basic facility provided by REDUCE mode is the ability to move forward and backward by statement through a file of REDUCE source code. Moving by one statement means moving to the beginning or end of the logical statement currently containing (or respectively preceding or following) point, which may involve skipping many actual statements that are contained within the current statement. In particular, as Emacs looks for the beginning or end of a statement it will skip complete compound statements (begin … end), group statements (<< … >>), and bracketed expressions ((…), {…} and […], even though square brackets are not normally used in REDUCE). Bracket skipping is controlled entirely by the Emacs syntax table.

Hence, “statement” in this manual will normally mean a complete logical statement. A syntax-directed editor clearly must perform a limited amount of parsing, but it must be remembered that a syntax-directed editor has the following important differences from a normal parser, because their basic purposes are different:

Emacs considers REDUCE statements to be terminated by the statement separator characters ; and $. It also considers statements contained within any kind of brackets to be terminated by those brackets, statements within compound statements (begin … end) to be terminated by the begin and end keywords, and statements within group statements (<< … >>) to be terminated by the << and >> tokens. Commas are not considered to separate statements.

More precisely, a statement is considered to begin at the first non-white-space character following the previous statement separator, opening bracket, begin or <<. It is considered to end immediately after the first statement separator or immediately after the last non-white-space character preceding a closing bracket, end or >>.

The current philosophy of REDUCE mode is that the statements within compound or group statements form essentially isolated systems, and that the basic statement-oriented commands should not move point either into or out of this system. Separate commands are provided to move into and out of compound and group statements. However, if you try hard enough, REDUCE mode will let a simple statement-oriented command move out of (but never into) a compound or group statement. Trying hard enough means repeating the same command enough times, which is determined by the value of the user option reduce-max-up-tries (see Customization of the REDUCE IDE), which currently has the default value 2. The overall effect of this is to enforce a brief pause (one ineffective command execution) that serves to prevent you from skipping out of a compound or group statement accidentally, but without causing any serious inconvenience.

There is special code to handle the keyword end when it is used as the end-of-file marker. The following commands all accept a numerical argument, which defaults to 1. The commands to move forward or backward by statements do not move in the opposite direction if given a negative argument, in which case they do not move at all.

C-c C-n
M-x reduce-forward-statement

Move forward to the end of the statement. With an argument, do it that many times. If looking at the end of a block or group, or the end-of-file marker, move over it after reduce-max-up-tries consecutive interactive tries.

C-c C-p
M-x reduce-backward-statement

Move backward to the start of the statement. With an argument, do it that many times. If looking at the beginning of a block or group move over it after reduce-max-up-tries consecutive interactive tries. The end-of-file marker is treated as a statement.

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

Kill the rest of the current statement; if there are no non-blank characters kill through the newline. With an argument, kill that many statements from point. Negative arguments kill complete statements backwards, cf. kill-line.

C-c C-u
M-x reduce-up-block-or-group

Move backward up one level of block or group, i.e. to the beginning of the nearest unpaired begin or <<. A universal argument means move forward, i.e. to the end of the nearest unpaired end or >>. With a numeric argument, do it that many times, where a negative argument means move forward instead of backward.

C-c C-d
M-x reduce-down-block-or-group

Move forward down one level of block or group, i.e. to the end of the nearest unpaired begin or <<. A universal argument means move backward to the beginning of the nearest unpaired end or >>. With a numeric argument, do it that many times, where a negative argument means move backward instead of forward.


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