From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Markus Triska Newsgroups: gmane.emacs.bugs Subject: bug#21526: 24.5; prolog-mode: broken indentation for if-then-else construct Date: Wed, 21 Oct 2015 23:58:54 +0200 Message-ID: References: <8737xwbeo0.fsf@metalevel.at> <87a8rw27vh.fsf@metalevel.at> <87egh8rlnn.fsf@metalevel.at> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1445464830 3776 80.91.229.3 (21 Oct 2015 22:00:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 21 Oct 2015 22:00:30 +0000 (UTC) Cc: 21526@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Oct 22 00:00:20 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Zp1Qg-0007JS-TM for geb-bug-gnu-emacs@m.gmane.org; Thu, 22 Oct 2015 00:00:19 +0200 Original-Received: from localhost ([::1]:54598 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zp1Qg-0006sC-A1 for geb-bug-gnu-emacs@m.gmane.org; Wed, 21 Oct 2015 18:00:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34420) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zp1Qb-0006rf-6E for bug-gnu-emacs@gnu.org; Wed, 21 Oct 2015 18:00:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zp1QW-0005uB-BG for bug-gnu-emacs@gnu.org; Wed, 21 Oct 2015 18:00:13 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:40876) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zp1QW-0005u3-7m for bug-gnu-emacs@gnu.org; Wed, 21 Oct 2015 18:00:08 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Zp1QV-0006qE-1i for bug-gnu-emacs@gnu.org; Wed, 21 Oct 2015 18:00:07 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Markus Triska Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 21 Oct 2015 22:00:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21526 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 21526-submit@debbugs.gnu.org id=B21526.144546475726197 (code B ref 21526); Wed, 21 Oct 2015 22:00:05 +0000 Original-Received: (at 21526) by debbugs.gnu.org; 21 Oct 2015 21:59:17 +0000 Original-Received: from localhost ([127.0.0.1]:59817 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zp1Ph-0006oT-49 for submit@debbugs.gnu.org; Wed, 21 Oct 2015 17:59:17 -0400 Original-Received: from static.59.150.47.78.clients.your-server.de ([78.47.150.59]:51754 helo=metalevel.at) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zp1PM-0006na-R9 for 21526@debbugs.gnu.org; Wed, 21 Oct 2015 17:59:15 -0400 Original-Received: from dawn.meta (dawn.metalevel.at [127.0.0.1]) by metalevel.at (Postfix) with ESMTP id 47101EC107; Wed, 21 Oct 2015 23:58:55 +0200 (CEST) Original-Received: by dawn.meta (Postfix, from userid 501) id 5C55816BB393; Wed, 21 Oct 2015 23:58:54 +0200 (CEST) In-Reply-To: (Stefan Monnier's message of "Wed, 21 Oct 2015 12:06:53 -0400") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:107815 Archived-At: Stefan Monnier 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