bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#21526: 24.5; prolog-mode: broken indentation for if-then-else constr


From: Markus Triska
Subject: bug#21526: 24.5; prolog-mode: broken indentation for if-then-else construct
Date: Tue, 06 Oct 2015 01:49:54 +0200

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> It does, if you do the C-M-f from just before the dot.
> The fact that you have to "jump over the dot" is the crucial hint you
> (the user) give to Emacs that you want to jump over "the whole LHS/RHS
> of that dot" rather than over a deeper part of the AST.

Please consider the following additional test case for navigating Prolog
code with C-M-f and C-M-b, which now unexpectedly move too far.

The snippet I am using to demonstrate the regression is:

   test :-
           (   a,
               b
           ;   (   c,
                   d
               ;   e,
                   f
               ),
               g,
               h
           ).

I begin with point at HERE:

   test :-
           (   a,
               bHERE
           ;   (   c,
                   d
               ;   e,
                   f
               ),
               g,
               h
           ).

>From that position, I press C-M-f, and get:

   test :-
           (   a,
               b
           ;   (   c,
                   d
               ;   e,
                   f
               ),
               g,
               hHERE
           ).

This, in my view, already skips too far ahead, over too many other
constructs. (For comparison, with Stefan Bruda's mode, C-M-f in the same
situation moves point to the comma before the goal "g/0").

The most unusual aspect though is, in my view, that not only does it
take a disproportionate amount of the inverse command (C-M-b) to get
approximately back to the original position, but it is in fact not
possible to get satisfactorily close to it (say, within an offset of 1)
with C-M-b alone. This is what happens on repeated C-M-b:

   test :-
           (   a,
               b
           ;   (   c,
                   d
               ;   e,
                   f
               ),
               g,
               HEREh
           ).

followed by:

   test :-
           (   a,
               b
           ;   (   c,
                   d
               ;   e,
                   f
               ),
               HEREg,
               h
           ).

followed by:

   test :-
           (   a,
               b
           ;   HERE(   c,
                   d
               ;   e,
                   f
               ),
               g,
               h
           ).

followed by:

   test :-
           (   HEREa,
               b
           ;   (   c,
                   d
               ;   e,
                   f
               ),
               g,
               h
           ).

I tried navigating several such code snippets with Stefan Bruda's mode,
starting from various positions. In all cases, the important invariant
seems to be preserved that, give or take an offset of at most 1, we can
invert a C-M-f with a subsequent C-M-b in most if not all situations
that are of great practical importance when moving through Prolog code.

All the best,
Markus





reply via email to

[Prev in Thread] Current Thread [Next in Thread]