On 5 Mar 2016, at 14:29, Stephen Leake <[email protected]> wrote:
>
> The definition of ada-indent-comment-gnat is:
>
> If non-nil, comments are indented to meet the GNAT comment style check.
> That is, one of:
>
> - multiple of ada-indent
> - next non-blank line
> - previous non-blank line
>
> This seems to imply an order in the three conditions, but it doesn't; as
> long as the comment meets _any_ of the three conditions, it passes the
> GNAT check.
>
> When computing the indentation, the code checks them in this order:
>
> - multiple of ada-indent
> - previous non-blank line
> - next non-blank line
>
> Is that the source of your confusion?
>
> It would make sense to make the definition order match the code order.
As far as I can see the current code is
indent := indentation of previous keyword;
prev-indent := nil;
next-indent := nil;
if ada-indent-comment-gnat then
if indent is a multiple of ada-indent
then
indent := indent;
else
indent previous line;
prev-indent := indentation-of-previous-line;
if indent = prev-indent
then
indent := indent;
else
indent next line;
next-indent := indentation-of-next-line;
if indent = next-indent
then
indent := indent;
else
if prev-indent /= nil or next-indent /= nil then
indent := floor (indent, ada-indent);
end if;
end if;
end if;
end if;
else
indent := indent;
end if;
which has several problems.
First, the initial calculated value of indent is almost bound to be a multiple
of ada-indent, so most of the rest of the code won't have any effect. I don't
think this check is actually necessary? (removing it doesn't seem to make any
difference).
Second, that "floor (indent, ada-indent)" can't be right; you'd think it'd be
something like "min (prev-indent, next-indent)".
Third, we'll only get to this point if neither prev-indent or next-indent is
equal to the initial calculated indent, which seems unlikely?
(I don't have a lot of confidence in my translation of the elisp :-)
> It would also make sense to match the behavior of GPS; I don't currently
> have that installed to check.
GPS has two switches: "Indent comments" and "Align comments on keywords". I
couldn't work out the effect of the first (if any); the second aligns comments
after (some) keywords with the keyword.
I don't think either of these will do what Piotr wants.
_______________________________________________
Emacs-ada-mode mailing list
[email protected]
http://host114.hostmonster.com/mailman/listinfo/emacs-ada-mode_stephe-leake.org