MACROS

The upper-case letters 'A' to 'W' and the punctuation symbols have a fixed significance to ECCE. All the lower-case letters, and the upper-case letters 'X' to 'Z', are available for definition as macros, that is as abbreviations for sequences of characters. So also are the control keys.

Command and text macros

The printing keys mentioned have a significance as macros only within commands, since in data-entry mode or within text strings they stand for themselves. Any of them may be used in a position where a command letter is expected and may stand for any sequence or partial sequence of commands. The letters 'X' to 'Z' and 'x' to 'z' have two additional properties: first, they may be used in a position where a text parameter is required; and, second, they may be defined to stand for a text sequence appearing in the file being edited, or the secondary input file, using the Define Macro ("^") command. Initially the lower-case letters 'a' to 'w' are defined to be equivalent to their upper-case equivalents. Where command letters appear within a macro definition, it is sensible to use the upper-case form if it is intended to utilise the basic meaning of that command letter, lest the lower-case form should have been re-defined.
The control keys are always interpreted as macros, in one of two ways, depending on how they have been defined. One form of definition forces interpretation of the sequence of characters for which the key stands as a command sequence; the other causes the use of the key to be equivalent to typing the characters explicitly as part of the text being entered. The distinction is indicated when defining one of these keys by using a colon to define a command sequence and an equals-sign to define a direct replacement sequence. Note that the content of a command macro is interpreted, not when the definition is made, but when the macro is used.

Exclamation-mark in macro

When an exclamation-mark is used in place of a text parameter within a sequence invoked as a command macro, the effect is to cause the actual text parameter to be sought at the point following the macro call. Here again any of the forms of text parameter -- delimited string, text macro letter, ditto, or exclamation mark -- are valid.

Key enquiry command %Q

The Special command "%Q" is provided as a way of finding out the current significance of any key. It may be used as a one-shot command or to cause entry to Enquiry mode. The first involves pressing the key about which information is required immediately after the "%Q" (followed by RETURN if not a control key). The second is indicated by typing just "%Q" followed by RETURN. In this case the Editor continues to prompt for keys to be explained until a colon is typed; as before an immediate-action key does not require a following RETURN. For any basic editing command letter, a brief indication of the meaning of the letter is given. For a key defined as a macro, the current definition of that macro is printed out; for a multi-line sequence, only the first line is printed out.

Key definition command %K

The Special command "%K" is used to define or re-define keys. Like "%Q," it may be used as a one-shot command or to enter a Key-definition mode. In the first case, a single definition is entered along with the "%K", while in the definition mode, the Editor continues to prompt for definitions until a colon is typed. Each definition takes the form of the key to be defined followed by a colon or equals sign followed by the text making up the definition. When a control key is being defined, depression of the control key in the course of the definition causes an asterisk to be echoed. Use of the colon rather than equals-sign as separator indicates that a control key is being defined to stand for a command sequence rather than a direct replacement text string. To cover the case where it is realised after typing in a command that it could usefully have been defined as a macro, an alternative form of definition is provided to define the key to be the text of the last explicitly typed command line. This is: key to be defined followed by the ditto symbol (").

Use of command macros

After the definitions %K x=F/basically/ %K y=MR*I/ : the following equivalences would apply xS/actually/ -> F/basically/S/actually/ M-10 x T/y/ I/,/ -> M-10 F/basically/ T/y/ I/,/ ycomment/ -> MR*I/ :comment/ A command macro letter may abbreviate any initial part of a command sequence; the last example illustrates a case where it includes the opening delimiter for a text string and a fixed initial part. The effect of typing a macro character (letter or control key) is always literal substitution of the sequence of characters for which it stands.
Where a macro letter is defined to be a complete group of two or more commands it is always sensible to include parentheses in the definition, as in "%K z=(F.error.I.**.)" rather than just "%K z=F.error.I.**.", so that if a repetition count is attached to the macro letter, it will apply to the whole sequence and not just the last component (see next Section). The definition of one macro may include a reference to another, but any form of circular definition is invalid and an occurrence of any of the macro letters within text delimiters always stands for itself.
One common case where temporary macros can be useful is when some but not all occurrences of a text string, say "max", have to be changed to something else, say "count", inspection being required to determine which. With the two definitions %K x=F/max/ %K y=S/count/x "x" can be used to find the first occurrence of "max" and thereafter "y" or "x" depending on whether a change is required or not. Macro definitions persevere until the end of the editing session or until the relevant key is re-defined.