all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Markus Triska <triska@metalevel.at>
Cc: 21526@debbugs.gnu.org
Subject: bug#21526: 24.5; prolog-mode: broken indentation for if-then-else construct
Date: Mon, 05 Oct 2015 22:23:48 -0400	[thread overview]
Message-ID: <jwvd1wsu4et.fsf-monnier+emacsbugs@gnu.org> (raw)
In-Reply-To: <87zizxrldy.fsf@metalevel.at> (Markus Triska's message of "Tue, 06 Oct 2015 00:38:49 +0200")

>    test :-
>            X = [
>                    a,
>                    b
>            ].


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

>    test :-
>            X = [
>                    a,
>                    b
>                ].

Try M-x smie-edebug RET to see where this is decided.  The above is just
the standard behavior used in many other major modes.  I prefer the
behavior above, so it probably requires a config var.

> The indentation for this new line is already different from Stefan
> Bruda's version, but not in itself a serious mistake at that point

Disagreement with Bruda's version is indeed not considered a bug, in
general, since Bruda's indentation code is far from perfect.

> 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 "]".

Actually, I would personally prefer something like

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

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

>    :- public
>                    a,
>                    b.

Indeed, that's a poor choice, and oddly enough it's not the result of
a simple bug.  The patch below should improve the behavior.


        Stefan


diff --git a/lisp/progmodes/prolog.el b/lisp/progmodes/prolog.el
index 81aeb8d..61d3a3c 100644
--- a/lisp/progmodes/prolog.el
+++ b/lisp/progmodes/prolog.el
@@ -988,7 +988,16 @@ This is really kludgy, and unneeded (i.e. obsolete) in Emacs>=24."
             (smie-indent-backward-token) ;Skip !
             (equal ":-" (car (smie-indent-backward-token))))
           (smie-rule-parent prolog-indent-width)))
-    (`(:after . ,(or `":-" `"-->")) prolog-indent-width)))
+    (`(:after . ":-")
+     (if (bolp)
+         (save-excursion
+           (smie-indent-forward-token)
+           (skip-chars-forward " \t")
+           (if (eolp)
+               prolog-indent-width
+             (min prolog-indent-width (current-column))))
+       prolog-indent-width))
+    (`(:after . "-->") prolog-indent-width)))
 
 \f
 ;;-------------------------------------------------------------------





  reply	other threads:[~2015-10-06  2:23 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-20 13:02 bug#21526: 24.5; prolog-mode: broken indentation for if-then-else construct Markus Triska
2015-09-20 18:04 ` Stefan Monnier
2015-09-20 19:33   ` Markus Triska
2015-09-21  2:34     ` Stefan Monnier
2015-09-21  3:03     ` Stefan Monnier
2015-09-21  6:02       ` Markus Triska
2015-09-21 20:22         ` Stefan Monnier
2015-09-22  6:25           ` Markus Triska
2015-09-22 15:12           ` Stefan Monnier
2015-09-22 16:38             ` Markus Triska
2015-09-22 21:04               ` Markus Triska
2015-09-23 21:08                 ` Markus Triska
2015-09-25 16:20                   ` Markus Triska
2015-09-30  2:04                     ` Stefan Monnier
2015-09-30  3:28                   ` Stefan Monnier
2015-09-30  6:38                     ` Markus Triska
2015-09-30  9:23                       ` Stefan Monnier
2015-09-30 18:35                         ` Markus Triska
2015-09-30 20:19                           ` Stefan Monnier
2015-09-30 20:40                             ` Markus Triska
2015-10-01  0:14                               ` Stefan Monnier
2015-10-01  6:22                                 ` Markus Triska
2015-10-01 14:07                                   ` Stefan Monnier
2015-10-02 16:23                                     ` Markus Triska
2015-10-02 20:47                                       ` Stefan Monnier
2015-10-05 22:38                                         ` Markus Triska
2015-10-06  2:23                                           ` Stefan Monnier [this message]
2015-09-30 18:03                     ` Markus Triska
2015-09-30 21:19                       ` Stefan Monnier
2015-09-30  3:28                 ` Stefan Monnier
2015-09-30  2:07               ` Stefan Monnier
2015-09-30  6:32                 ` Markus Triska
2015-09-30  8:55                   ` Stefan Monnier
2015-09-30 18:11                     ` Markus Triska
2015-10-05 23:49                     ` Markus Triska
2015-10-06  1:17                       ` Stefan Monnier
2015-10-06 16:45                         ` Markus Triska
2015-10-06 20:09                           ` Stefan Monnier
2015-10-20 23:47                             ` Markus Triska
2015-10-21 16:06                               ` Stefan Monnier
2015-10-21 21:58                                 ` Markus Triska
2015-10-22  1:16                                   ` Stefan Monnier
2015-10-22 19:08                                     ` Markus Triska
2015-10-25 20:01                                       ` Stefan Monnier
2015-11-23 16:36               ` Stefan Monnier
2020-08-24 18:23                 ` Lars Ingebrigtsen
2015-09-29 15:27             ` Stefan Monnier
2015-09-29 16:24               ` Markus Triska

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvd1wsu4et.fsf-monnier+emacsbugs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=21526@debbugs.gnu.org \
    --cc=triska@metalevel.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.