From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#21526: 24.5; prolog-mode: broken indentation for if-then-else construct Date: Sun, 20 Sep 2015 22:34:47 -0400 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1442802924 21087 80.91.229.3 (21 Sep 2015 02:35:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 21 Sep 2015 02:35:24 +0000 (UTC) Cc: 21526@debbugs.gnu.org To: Markus Triska Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Sep 21 04:35:14 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 1Zdqwj-0004Vf-Ak for geb-bug-gnu-emacs@m.gmane.org; Mon, 21 Sep 2015 04:35:13 +0200 Original-Received: from localhost ([::1]:55052 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zdqwh-0007OO-Du for geb-bug-gnu-emacs@m.gmane.org; Sun, 20 Sep 2015 22:35:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59565) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zdqwe-0007M2-5O for bug-gnu-emacs@gnu.org; Sun, 20 Sep 2015 22:35:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZdqwZ-0000ZF-6E for bug-gnu-emacs@gnu.org; Sun, 20 Sep 2015 22:35:08 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:47127) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZdqwY-0000Yj-Vo for bug-gnu-emacs@gnu.org; Sun, 20 Sep 2015 22:35:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1ZdqwY-0003Ew-Hu for bug-gnu-emacs@gnu.org; Sun, 20 Sep 2015 22:35:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 21 Sep 2015 02:35:02 +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.144280289212435 (code B ref 21526); Mon, 21 Sep 2015 02:35:02 +0000 Original-Received: (at 21526) by debbugs.gnu.org; 21 Sep 2015 02:34:52 +0000 Original-Received: from localhost ([127.0.0.1]:39337 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZdqwN-0003EU-Vr for submit@debbugs.gnu.org; Sun, 20 Sep 2015 22:34:52 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:54355) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZdqwL-0003EM-N2 for 21526@debbugs.gnu.org; Sun, 20 Sep 2015 22:34:50 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0AsEwA731xV/2yixEVcgxCEAoVVuzcJh0sEAgKBPDkUAQEBAQEBAYEKQQWDXQEBAwEnLyMFCws0EhQYDSSINwjPIwEBAQcCAR+LOoUFB4QtBZtkg0aUFYFFI4QUIoJ4AQEB X-IPAS-Result: A0AsEwA731xV/2yixEVcgxCEAoVVuzcJh0sEAgKBPDkUAQEBAQEBAYEKQQWDXQEBAwEnLyMFCws0EhQYDSSINwjPIwEBAQcCAR+LOoUFB4QtBZtkg0aUFYFFI4QUIoJ4AQEB X-IronPort-AV: E=Sophos;i="5.13,465,1427774400"; d="scan'208";a="165394935" Original-Received: from 69-196-162-108.dsl.teksavvy.com (HELO ceviche.home) ([69.196.162.108]) by ironport2-out.teksavvy.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 20 Sep 2015 22:34:47 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id B10FA6614D; Sun, 20 Sep 2015 22:34:47 -0400 (EDT) In-Reply-To: (Markus Triska's message of "Sun, 20 Sep 2015 21:33:00 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) 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:106753 Archived-At: > test :- > ( HERE > with point again being at the "H". In other words, the electric > parenthesis indents `prolog-paren-indent', which is typically 4. Good, thanks. I think this does work correctly, currently, right? > That is, notice in particular that this new line is NOT indented the > same amount as the immediately preceding Prolog goals. There is a clear > reason for this: The immediately preceding Prolog goal, namely c, is > NOT followed by a comma. This means that where HERE appears, only two > things can realistically follow: Right, this is a current problem in SMIE, as mentioned: it doesn't know about such "realistically". It just knows that the grammar would allow a comma at that point just as much as a semi-colon or lots of other things, and it even thinks that there are yet further possibilities (which actually aren't allowed by Prolog). I'll have to think about how to best teach SMIE about this. > To (unexpectedly) first indent the block and then only re-indent it when > "." is pressed would in my view be a regression compared to that. No doubt it's a regression. >> >> - there are two desired indentations for "b". IIUC You want >> >> (a -> >> b1, >> b2 >> ;c1, >> c2) >> >> whereas the current code tries to accommodate >> >> (a -> >> b1, >> b2; >> c1, >> c2) > The two most common ways to indent Prolog's if-then-else are: > > ( a -> > b, > c > ; d, > e > ), > > and: > > ( a > -> b, > c > ; d, > e > ) OK, the latter should be easy to support. The former might require a bit more works (or a config var). >> ( a -> >> b >> ; c >> ). > I've never seen this indentation style in a decade I'm not surprised. This indentation is only the indirect result of supporting (a -> b1, b2; c). and since indentation normally only looks at the previous lines, the indentation of "b1," can't depend on whether the following semi-colon is at the end of a line, or at the beginning of a line. Stefan