Indent until wherever the next line should start, suitable for
however many nested constructs are currently open.
(vl-progindent &key (ps 'ps)) → ps
When we go into a construct such as a module, function
body, always statement, begin block, for loop, and so forth, we
would like to progressively increase our indentation level. We (arbitrarily)
choose to indent by 2 columns for every ``open'' construct, i.e., we want our
output to look something like this:
function bar (...);
integer a = 1;
for(integer b = 0; ...; ...)
foo[b] = a + ...;
To implement progressive indentation, we tinker with the autowrap-col
and autowrap-ind; see ps for background. We generally expect that
autowrap-col starts out at something like 80 or more, while
autowrap-ind starts at 5.
It seems nice for the autowrap-ind to consistently be set to a little
bit past our current progressive indent level. The autowrap-ind controls
how far we'll indent after a long line goes past the right margin. If we're
wrapping such a line in, e.g., the for loop above, then we probably want to
indent to: 8 columns for the foo loop itself, then some extra since it was a
long line we were autowrapping.
So my convention is that vl-progindent will always indent to 5 less
than the autowrap-ind. Note also that whenever we increase the progindent
level, we bump the right margin out, so that the visual width of each line is
roughly constant no matter how far indented over it gets.
Definitions and Theorems
(defun vl-progindent-fn (ps)
(declare (xargs :stobjs (ps)))
(declare (xargs :guard t))
(let ((__function__ 'vl-progindent))
(declare (ignorable __function__))
(vl-indent (nfix (- (vl-ps->autowrap-ind) 5)))))
- Like vl-ps-seq, but increase the progressive indentation while
for all of the statements in the block.