12.5 Running, rerunning and switching to REDUCE

The main command to start REDUCE is run-reduce, which is bound to the key M-R (that’s a capital R, so use META-SHIFT-r) in REDUCE mode. It is also available in the REDUCE mode Run REDUCE menu.

If the option reduce-run-multiple is non-nil (which by default it is) then run-reduce starts a new REDUCE process every time it is executed; successive REDUCE process buffers have successively higher numbers at the end of their names, e.g. *CSL REDUCE*, *CSL REDUCE 1*, *CSL REDUCE 2*, ... Otherwise it only starts a new REDUCE process if necessary – if an appropriate REDUCE process is already running then it simply switches to it. Finally, these commands run the hooks from reduce-run-mode-hook (after the comint-mode-hook is run).

If the option reduce-run-autostart is non-nil (which by default it is) then all commands that require a REDUCE process automatically start one if necessary. See Customization of REDUCE Run mode. Where appropriate, input commands have their own history lists, and if run in REDUCE mode then any input file defaults to the file being edited.

M-R
M-x run-reduce

This command prompts for the name of a REDUCE command in the minibuffer, using completion and ignoring case. The REDUCE command names are as specified by the option reduce-run-commands and the default command name is as specified by the option reduce-run-command-name-default, if non-nil. If you don’t provide a command name, i.e. you just hit RET, then the command aborts. The REDUCE process buffer is named using the name of the REDUCE command that it runs, e.g. *CSL REDUCE* or *PSL REDUCE*.

If this command is executed with a prefix argument then it reads an actual command to run REDUCE from the minibuffer and runs that command. In this case, the REDUCE process buffer is named without any reference to the REDUCE command, e.g. *REDUCE*.

A couple of convenience commands allow you to re-start a running REDUCE process in the same buffer and switch from any REDUCE-mode buffer to a running REDUCE process buffer.

M-x rerun-reduce

This command is defined only in REDUCE Run mode, i.e. in a REDUCE process buffer. If REDUCE is running in the current buffer then it is terminated. The command then reruns the REDUCE command whose name is shown in the buffer name. If no command name is shown then it uses the previous explicit command. Beware that this command previously had the now-obsolete name re-run-reduce.

C-c C-z
M-x switch-to-reduce

This command is defined only in REDUCE mode. It is primarily intended for internal use by other commands but it can be used interactively to switch to a running REDUCE process buffer. If the current buffer is an active REDUCE process buffer then the command does nothing; if there is only one active REDUCE process buffer then the command switches to it; otherwise, the command reads the name of an active REDUCE process buffer from the minibuffer with completion. This means that pressing the TAB key will give a list of active REDUCE process buffers from which to select one. It remembers the last buffer used and offers that as the default, making it easy to switch repeatedly to the same REDUCE process buffer. This function is used by all commands described below that send REDUCE code fragments to a running REDUCE process. With an interactive argument, position the cursor at the end of the REDUCE process buffer.

If REDUCE is not running then this command will start REDUCE automatically by calling run-reduce if the option reduce-run-autostart is non-nil (which by default it is).

Within a running REDUCE process buffer, pressing RET at the end of a line of input sends it to REDUCE, as with the standard REDUCE interfaces. However, if there is no terminator at the end of the line then a ; is automatically appended, unless there is a ? in the input line (implying that the input is the response to a user query, which must not be followed by a terminator). You can avoid this automatic behaviour completely by holding down the SHIFT key, i.e. by pressing SHIFT-RET.

RET
reduce-run-send-input

Send the preceding input to REDUCE after appending a ; if appropriate; holding down the SHIFT key avoid this.

The following REDUCE mode key binding is also available in REDUCE Run mode.

M-TAB
C-c TAB
reduce-complete-symbol

Perform completion on the REDUCE symbol preceding point (or preceding the region if it is active). Compare that symbol against the elements of reduce-completion-alist. If a perfect match (only) has a cdr then delete the match and insert the cdr if it is a string or call it if it is a (nullary) function, passing on any prefix argument (in raw form).

Note that most of the default key bindings provided by comint mode are also available in REDUCE Run mode.

The REDUCE Run library provides a REDUCE Run major mode menu and also adds a slightly modified version of this menu to the menu bar in REDUCE mode. These two menus provide appropriate access to all the REDUCE Run mode commands.