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

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

> We could try and coerce Prolog into interpreting it the way you
> suggest,

This was the default behaviour of this mode, up until the point these
regressions were introduced. All it takes is to re-introduce the flag to
disable the, in my view, currently in many ways broken new indentation
code, and use the previous behaviour of Stefan Bruda's original mode,
which was also the default when this mode was included in GNU Emacs.

> but I think we're better off telling people to add a terminating "."
> in the previous rule, even that rule is not yet finished.

This requirement would make Prolog mode highly unusual even within
Emacs. Please try it yourself, with different languages, to see that the
way I am suggesting is very common also in other modes. In all following
examples, even though the previous form is not yet complicated, it is
completely clear what is intended here, because the user *explicitly*
re-indented the new beginning form in such a way that it is clear that a
new defun/proc/whatever is meant to start.

In the following examples, when the new defun/proc/etc. starts, the mode
still tries to indent according to the still open construct. But, with
just a few key presses that, critically, require *no changes whatsoever*
to the construct that is still open, the indentation is adjusted (please
see my previous mail for the exact key presses, used analogously):

Emacs Lisp:

   (defun test ()
     (if (test)
         (

   (defun complicated ()
     (test)
     (if (further)
         (etc.

C/C++:

   int test () {
     test();
     more(

   int complicated() {
     test();
     further(a, b);
   }

Tcl/Tk:

   proc test {} {
       test
       more

   proc complicated {} {
       test
       if {


and now the current Prolog mode, in contrast to all preceding examples:


   test :-
       test,
       more

       complicated :-
           further,

with *no way* to manually and explicitly adjust the indentation to the
level that is clearly intended in this case (i.e., to the left), because
interpreting it any other way makes absolutely no sense.

> There's no way to know that this is "what it actually is".
>
> And even if it is, the mis-indentation can be useful, in case the user
> didn't realize that she forgot to close the previous rule.

In the case I outline, the user tries, in vain, to *explicitly* and
manually set a different indentation level, so that the layout matches
the user's intention at this point. Stefan Bruda's mode allows this
explicit interaction, and the current Emacs version falls short in this
respect, instead insisting on an indentation that makes no sense. I
agree that this my be useful when pressing RET the first time, but no
longer after the user explicitly re-indented and is *clearly* asking for
a different indentation level.

> IOW, in this particular case, the ideal behavior depends on what's
> inside the user's head, so I don't think we should spend much time
> trying to fit any particular expected state of mind of the user.

Again, please reconsider the example interaction I posted: By explicitly
removing all horizontal whitespace (M-\) to adjust the indentation
level, the user is giving a very clear sign that this is the indentation
level we wish at this point.

Thank you and all the best,
Markus






  reply	other threads:[~2015-10-21 21:58 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
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 [this message]
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=m2vb9zg9y9.fsf@metalevel.at \
    --to=triska@metalevel.at \
    --cc=21526@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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.