GNU bug report logs -
#21526
24.5; prolog-mode: broken indentation for if-then-else construct
Previous Next
Reported by: Markus Triska <triska <at> metalevel.at>
Date: Sun, 20 Sep 2015 16:21:01 UTC
Severity: minor
Found in version 24.5
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
> 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)))
;;-------------------------------------------------------------------
This bug report was last modified 4 years and 269 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.