[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Ada-mode-users] wrong indentation of some complex expressions
From: |
Stephen Leake |
Subject: |
Re: [Ada-mode-users] wrong indentation of some complex expressions |
Date: |
Mon, 21 Nov 2016 14:50:57 -0600 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (windows-nt) |
Ludovic Brenta <address@hidden> writes:
> In the example below, the line "/= A" is incorrectly indented relative
> to the beginning of the entire expression instead of the sub-
> expression. I think it should be indented by ada-indent relative to B,
> which starts the sub-expression:
>
> procedure Andthen is
> A : Boolean;
> B : Boolean;
> begin
> if A
> and then B
> /= A
> -- should be:
> -- /= A -- indented by ada-indent relative to B
This is related to your post about leading parens; apparently it is all
hanging indents, not just parens.
If I add parens, it does what you want:
if A
and then (B
/= A)
then
end if;
This was done mainly for aggregates and argument lists; it makes less
sense (to me ;) here.
Without the paren, "/= A" is indented relative to "if", because the
first "A" is the start of the expression, and "/= A" is indented
relative to that line.
The indentation engine does not keep track of sub-expressions unless
they are in parens.
So there is no easy way to fix this; we'd have to add a
"sub_expression_start", and mark those in the grammar. The grammar is
structured that way, so that's not too hard. That would slow down the
parser some (parse time is dominated by set-text-property). Then we'd
have to add rules for that.
Ada mode 4.0 does not do what you want (just tested in emacs -Q); does
some other editor?
--
-- Stephe