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: Mon, 05 Oct 2015 22:23:48 -0400 Message-ID: References: <87y4fo9zt6.fsf@metalevel.at> <87vbarwy9v.fsf@metalevel.at> <87bncjbpz4.fsf@metalevel.at> <87mvw3cdmf.fsf@metalevel.at> <87y4fltf2a.fsf@metalevel.at> <87zizxrldy.fsf@metalevel.at> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1444098264 17337 80.91.229.3 (6 Oct 2015 02:24:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 6 Oct 2015 02:24: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 Tue Oct 06 04:24:12 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 1ZjHvH-0001vx-V5 for geb-bug-gnu-emacs@m.gmane.org; Tue, 06 Oct 2015 04:24:12 +0200 Original-Received: from localhost ([::1]:48672 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjHvH-0006Vh-0x for geb-bug-gnu-emacs@m.gmane.org; Mon, 05 Oct 2015 22:24:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54830) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjHvC-0006VX-GP for bug-gnu-emacs@gnu.org; Mon, 05 Oct 2015 22:24:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZjHv8-0001y7-GG for bug-gnu-emacs@gnu.org; Mon, 05 Oct 2015 22:24:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:38544) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjHv8-0001y3-DJ for bug-gnu-emacs@gnu.org; Mon, 05 Oct 2015 22:24:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1ZjHv8-00033I-2S for bug-gnu-emacs@gnu.org; Mon, 05 Oct 2015 22:24: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: Tue, 06 Oct 2015 02:24: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.144409823211716 (code B ref 21526); Tue, 06 Oct 2015 02:24:02 +0000 Original-Received: (at 21526) by debbugs.gnu.org; 6 Oct 2015 02:23:52 +0000 Original-Received: from localhost ([127.0.0.1]:55748 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZjHuy-00032u-0O for submit@debbugs.gnu.org; Mon, 05 Oct 2015 22:23:52 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:37300) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZjHuv-00032l-Ie for 21526@debbugs.gnu.org; Mon, 05 Oct 2015 22:23:50 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0AyFgA731xV/3aQs2tcgxCEAoVVu0CHSwQCAoE8OhMBAQEBAQEBgQpBBYNdAQEDAScvIwULCzQSFBgNJIg3CM8jAQEBAQYBAQEBHos6hQUHhC0BBIZlrh8jhBQigngBAQE X-IPAS-Result: A0AyFgA731xV/3aQs2tcgxCEAoVVu0CHSwQCAoE8OhMBAQEBAQEBgQpBBYNdAQEDAScvIwULCzQSFBgNJIg3CM8jAQEBAQYBAQEBHos6hQUHhC0BBIZlrh8jhBQigngBAQE X-IronPort-AV: E=Sophos;i="5.13,465,1427774400"; d="scan'208";a="167644236" Original-Received: from 107-179-144-118.cpe.teksavvy.com (HELO fmsmemgm.homelinux.net) ([107.179.144.118]) by ironport2-out.teksavvy.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 05 Oct 2015 22:23:48 -0400 Original-Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 3F309AECF0; Mon, 5 Oct 2015 22:23:48 -0400 (EDT) In-Reply-To: <87zizxrldy.fsf@metalevel.at> (Markus Triska's message of "Tue, 06 Oct 2015 00:38:49 +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:107346 Archived-At: > 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))) ;;-------------------------------------------------------------------