Subject: Re: bug#21526: 24.5; prolog-mode: broken indentation for if-then-else construct

From: Markus Triska <[email-masked]>
Date: Tue, 06 Oct 2015 00:38:49 +0200

Stefan Monnier <[email-masked]> writes:

> Looks good, installed, thanks.

Great! One further devation from Stefan Bruda's mode is:

   test :-
           X = [
                   a,
                   b
           ].

We expect instead, as with Stefan Bruda's version, the layout:

   test :-
           X = [
                   a,
                   b
               ].

Notice that this regression is very visible, since it affects the module
declaration that most Prolog files begin with. For example, consider:

   :- module(x, [
                     a,
                     bHERE

when I, with point at "HERE", press RET, then I get with Emacs git:

   :- module(x, [
                     a,
                     b
                     HERE

The indentation for this new line is already different from Stefan
Bruda's version, but not in itself a serious mistake at that point: It
is theoretically possible that further list elements still follow.  In
practice though, that is extremely unlikely, and we would therefore
prefer the level of the opening "[" (as with Stefan Bruda's version):

   :- module(x, [
                     a,
                     b
                 HERE

However, suppose you retain the current behaviour of Emacs git, and then
close the whole module declaration by entering "]).", yielding:

   :- module(x, [
                     a,
                     b
                     ]).HERE

Then, if you press RET (as most users certainly would here), you get:

   :- module(x, [
                     a,
                     b
             ]).

and this is clearly not the intended layout for a term like that.
Instead, the indentation level of "[" should equal that of "]".

Another deviation from Stefan Bruda's mode is an unusually large
indentation for arguments of declarations like:

   :- public
                   a,
                   b.

Please consider indenting arguments less, for example, as in:

   :- public
             a,
             b.

Thank you and all the best,
Markus