There are two comment conventions used in REDUCE. One is the comment
statement, which is a statement that begins with the keyword
comment and ends with a statement separator. This is not used
much in modern REDUCE code. The most commonly used form of comment
begins with a
% character and ends at the end of the line.
Hence, it can appear either on its own on a line or at the end of a line
after other code.
Comments are ignored (skipped) by all syntax-directed commands. (This is not trivial to achieve, since comments can contain essentially arbitrary text including keywords, and %-comments can contain statement separators, which do not have any syntactic significance.) There is currently no way to use any of the REDUCE syntax-directed commands on comment statements.
There is no special support for comment statements other than that they are currently completely ignored. There is considerably more support for %-comments, much of which is already built into Emacs because %-comments are very similar to the comments used in Emacs Lisp. Indeed, the comment conventions supported by REDUCE mode are modelled primarily on those used in Emacs Lisp mode.
The comment commands are intimately related to the automatic comment indentation conventions. (These are the indentation conventions enforced by the Emacs comment and indentation commands, although the user is not otherwise forced to follow them.) See Indenting REDUCE code automatically.
The indentation of a %-comment that begins with no more than 2
characters together and appears alone on a line is determined by the
previous non-blank line. If this is a procedure (header) statement then
the comment line is indented relative to it, otherwise it has no indent
relative to the previous line, and at the beginning of a file it is not
indented at all. A %-comment at the end of a line of code is indented
to the column specified by the value of the standard Emacs buffer-local
comment-column, which by default is 40 (half way across
a “standard” 80 column page), unless the code extends beyond this
column. In that case, the comment begins one space later.
This convention can be over-ridden as follows. If the comment begins
with 3 or more
% characters then the comment indentation is not
changed. This allows a comment to be placed anywhere on an empty line
without any risk of it being automatically re-indented.
A new single-%-comment can be introduced and/or automatically indented
by the standard Emacs command
indent-for-comment, normally bound
to the key Meta-;. An existing %-comment can be automatically
continued on the next line by the standard Emacs command
indent-new-comment-line, normally bound to the key
Meta-LFD. This will copy the structure of the %-comment to
be continued, including the number of
% characters and the
indentation. All other indentation commands will also indent
%-comments, in particular those bound to the TAB and
BACKTAB (i.e. Shift-TAB) keys.
See Indenting REDUCE code automatically.
Indent this line’s comment appropriately, or insert an empty comment.
Break the line at point and indent, continuing a comment if presently within one. The body of the continued comment is indented under the previous comment line.
The only program text that it normally makes sense to fill or justify is
comment text. Hence, REDUCE mode rebinds the key M-q that
normally fills or justifies a paragraph to the command
reduce-fill-comment. This should be completely safe to use in
REDUCE code (unlike
fill-paragraph etc., which would be a
potential disaster were there no undo facility!), and makes it easy to
keep comments formatted tidily. Currently this command fills or
justifies only %-comments and not comment statements.
Fill successive %-comment lines around or immediately following point. A prefix argument means justify as well.
REDUCE mode also provides commands for turning sections of text into
%-comments by adding
% characters at the start of each line,
which will be referred to as “start-comments”. These commands are
intended primarily for temporarily preventing REDUCE from executing
sections of code without actually removing them. Such a section can be
either the current region or the procedure ending after point. By
default, these commands automatically toggle the comment status. When
given an interactive argument, they remove any start-commenting of the
specified section of text if the argument is negative (or null) and
insert start-commenting if the argument is positive. The precise text
that is added to or removed from each line is the value of the variable
reduce-comment-region-string, which defaults to ‘%% ’.
Comment/uncomment every line in the region. By default, it toggles the
commenting, i.e. it comments the region if it is uncommented and
uncomments if it is commented. With an interactive argument, comment if
non-negative, uncomment if null or negative (cf. minor modes). When
commenting, it puts the value of the variable
reduce-comment-region-string at the beginning of every line in the
reduce-comment-region, but applies to the procedure ending