GNU bug report logs - #21526
24.5; prolog-mode: broken indentation for if-then-else construct

Previous Next

Package: emacs;

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


View this message in rfc822 format

From: Markus Triska <triska <at> metalevel.at>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 21526 <at> debbugs.gnu.org
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 <at> 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




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.