GNU bug report logs - #33744
26.1; ada-mode 6.0.0 indentation of operators starting a line in a multi-line expression

Previous Next

Packages: emacs, ada-mode;

Reported by: Ludovic Brenta <ludovic <at> ludovic-brenta.org>

Date: Fri, 14 Dec 2018 15:58:02 UTC

Severity: minor

Found in version 26.1

To reply to this bug, email your comments to 33744 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#33744; Package emacs, ada-mode. (Fri, 14 Dec 2018 15:58:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ludovic Brenta <ludovic <at> ludovic-brenta.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 14 Dec 2018 15:58:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Brenta <ludovic <at> ludovic-brenta.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 26.1; ada-mode 6.0.0 indentation of operators starting a line in a
 multi-line expression
Date: Fri, 14 Dec 2018 16:57:17 +0100
Package: emacs, ada-mode
X-Debbug-CC: ada-mode-users <at> nongnu.org

Hello, consider the line marked "incorrectly indented" below:

procedure Operator_Indentation is
begin
  if B
       or else C
       > 2 -- incorrectly indented
  then
    null;
  end if;
end Operator_Indentation;

We think the indentation performed by ada-mode 6.0.0 is incorrect.
Of course we understand that the line is indented relative to B
but as this line is part of a sub-expression, we think it should be
indented relative to the sub-expression instead.  We cannot decide
which of the two following alternatives is the most "correct":

procedure Operator_Indentation is
begin
  if B
       or else C
         > 2 -- indented relative to "or else"
  then
    null;
  end if;
end Operator_Indentation;

procedure Operator_Indentation is
begin
  if B
       or else C
                 > 2 -- indented relative to C, which starts the 
sub-expression
  then
    null;
  end if;
end Operator_Indentation;

(we set ada-indent to 2).

Of course, these examples are overly simplified; in our real code base,
we don't write our operators on a separate line unless the previous line
("C" in these examples) is very long.  To illustrate this, our actual 
code
looks more like:

procedure Operator_Indentation is
begin
  if Blarg_Meets_Preconditions_For_Subsequent_Test (Blarg)
       or else Critical_Cruising_Configuration_Condition_Code 
(Blarg.Blurp)
         > 2
  then
    null;
  end if;
end Operator_Indentation;

PS. The value of ada-indent-hanging-rel-exp has no effect in this
particular case.

-- 
Ludovic Brenta.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#33744; Package emacs, ada-mode. (Fri, 21 Dec 2018 23:15:01 GMT) Full text and rfc822 format available.

Message #8 received at 33744 <at> debbugs.gnu.org (full text, mbox):

From: Stephen Leake <stephen_leake <at> stephe-leake.org>
To: 33744 <at> debbugs.gnu.org
Subject: effect of ada-indent-hanging-rel-exp
Date: Fri, 21 Dec 2018 15:14:23 -0800
Ludovic writes:

> The value of ada-indent-hanging-rel-exp has no effect in this
> particular case.

Actually, it does. With ada-indent = 2, ada-indent-hanging-rel-exp =
nil, the indentation is:

procedure Operator_Indentation is
begin
  if B
    or else C
    > 2 -- indented relative to "or else"
  then
    null;
  end if;
end Operator_Indentation;

Changing an indentation parameter does not force a reparse, so calling
'indent-region' does not use the new parameter value. Use M-x
wisi-parse-buffer to force a reparse and reindent.

-- 
-- Stephe




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#33744; Package emacs, ada-mode. (Fri, 21 Dec 2018 23:19:02 GMT) Full text and rfc822 format available.

Message #11 received at 33744 <at> debbugs.gnu.org (full text, mbox):

From: Stephen Leake <stephen_leake <at> stephe-leake.org>
To: 33744 <at> debbugs.gnu.org
Subject: bug#33744: effect of ada-indent-hanging-rel-exp
Date: Fri, 21 Dec 2018 15:18:24 -0800
Ludovic writes:

> The value of ada-indent-hanging-rel-exp has no effect in this
> particular case.

Actually, it does. With ada-indent = 2, ada-indent-hanging-rel-exp =
nil, the indentation is:

procedure Operator_Indentation is
begin
  if B
    or else C
    > 2 -- indented relative to "or else"
  then
    null;
  end if;
end Operator_Indentation;

Changing an indentation parameter does not force a reparse, so calling
'indent-region' does not use the new parameter value. Use M-x
wisi-parse-buffer to force a reparse and reindent.

-- 
-- Stephe




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#33744; Package emacs, ada-mode. (Sun, 23 Dec 2018 17:41:02 GMT) Full text and rfc822 format available.

Message #14 received at 33744 <at> debbugs.gnu.org (full text, mbox):

From: Stephen Leake <stephen_leake <at> stephe-leake.org>
To: 33744 <at> debbugs.gnu.org
Cc: Ludovic Brenta <ludovic.brenta.ext <at> eurocontrol.int>
Subject: Re: effect of ada-indent-hanging-rel-exp
Date: Sun, 23 Dec 2018 09:39:53 -0800
Is the fact that the first token on a line is an operator significant?
In other words, would this indentation be correct:

procedure Operator_Indentation is
begin
  if B or else
       C >
         2
  then
    null;
  end if;
end Operator_Indentation;

-- 
-- Stephe




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#33744; Package emacs, ada-mode. (Tue, 08 Jan 2019 11:48:02 GMT) Full text and rfc822 format available.

Message #17 received at 33744 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Brenta <ludovic <at> ludovic-brenta.org>
To: 33744 <at> debbugs.gnu.org
Subject: Re: 26.1; ada-mode 6.0.0 indentation of operators starting a line in
 a multi-line expression
Date: Tue, 08 Jan 2019 12:47:49 +0100
Hello,

Our coding standard forbids operators at end of line, so in our case
we would always place the operator at the beginning of the next line.
Were it not for that coding standard, I think your example would be
correct.  But this does not solve our problem :)

-- 
Ludovic Brenta.




This bug report was last modified 6 years and 215 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.