GNU bug report logs -
#21526
24.5; prolog-mode: broken indentation for if-then-else construct
Previous Next
Reported by: Markus Triska <triska <at> metalevel.at>
Date: Sun, 20 Sep 2015 16:21:01 UTC
Severity: minor
Found in version 24.5
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
Message #14 received at 21526 <at> debbugs.gnu.org (full text, mbox):
> test :-
> ( HERE
> with point again being at the "H". In other words, the electric
> parenthesis indents `prolog-paren-indent', which is typically 4.
Good, thanks. I think this does work correctly, currently, right?
> That is, notice in particular that this new line is NOT indented the
> same amount as the immediately preceding Prolog goals. There is a clear
> reason for this: The immediately preceding Prolog goal, namely c, is
> NOT followed by a comma. This means that where HERE appears, only two
> things can realistically follow:
Right, this is a current problem in SMIE, as mentioned: it doesn't know
about such "realistically". It just knows that the grammar would allow
a comma at that point just as much as a semi-colon or lots of other
things, and it even thinks that there are yet further possibilities
(which actually aren't allowed by Prolog).
I'll have to think about how to best teach SMIE about this.
> To (unexpectedly) first indent the block and then only re-indent it when
> "." is pressed would in my view be a regression compared to that.
No doubt it's a regression.
>>
>> - there are two desired indentations for "b". IIUC You want
>>
>> (a ->
>> b1,
>> b2
>> ;c1,
>> c2)
>>
>> whereas the current code tries to accommodate
>>
>> (a ->
>> b1,
>> b2;
>> c1,
>> c2)
> The two most common ways to indent Prolog's if-then-else are:
>
> ( a ->
> b,
> c
> ; d,
> e
> ),
>
> and:
>
> ( a
> -> b,
> c
> ; d,
> e
> )
OK, the latter should be easy to support. The former might require
a bit more works (or a config var).
>> ( a ->
>> b
>> ; c
>> ).
> I've never seen this indentation style in a decade
I'm not surprised. This indentation is only the indirect result of
supporting
(a ->
b1,
b2;
c).
and since indentation normally only looks at the previous lines, the
indentation of "b1," can't depend on whether the following semi-colon is
at the end of a line, or at the beginning of a line.
Stefan
This bug report was last modified 4 years and 269 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.