all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#33744: 26.1; ada-mode 6.0.0 indentation of operators starting a line in a multi-line expression
@ 2018-12-14 15:57 Ludovic Brenta
  2018-12-21 23:14 ` bug#33744: effect of ada-indent-hanging-rel-exp Stephen Leake
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Ludovic Brenta @ 2018-12-14 15:57 UTC (permalink / raw)
  To: 33744

Package: emacs, ada-mode
X-Debbug-CC: ada-mode-users@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.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#33744: effect of ada-indent-hanging-rel-exp
  2018-12-14 15:57 bug#33744: 26.1; ada-mode 6.0.0 indentation of operators starting a line in a multi-line expression Ludovic Brenta
@ 2018-12-21 23:14 ` Stephen Leake
  2018-12-23 17:39   ` Stephen Leake
  2018-12-21 23:18 ` Stephen Leake
  2019-01-08 11:47 ` bug#33744: 26.1; ada-mode 6.0.0 indentation of operators starting a line in a multi-line expression Ludovic Brenta
  2 siblings, 1 reply; 5+ messages in thread
From: Stephen Leake @ 2018-12-21 23:14 UTC (permalink / raw)
  To: 33744

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





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#33744: effect of ada-indent-hanging-rel-exp
  2018-12-14 15:57 bug#33744: 26.1; ada-mode 6.0.0 indentation of operators starting a line in a multi-line expression Ludovic Brenta
  2018-12-21 23:14 ` bug#33744: effect of ada-indent-hanging-rel-exp Stephen Leake
@ 2018-12-21 23:18 ` Stephen Leake
  2019-01-08 11:47 ` bug#33744: 26.1; ada-mode 6.0.0 indentation of operators starting a line in a multi-line expression Ludovic Brenta
  2 siblings, 0 replies; 5+ messages in thread
From: Stephen Leake @ 2018-12-21 23:18 UTC (permalink / raw)
  To: 33744

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





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#33744: effect of ada-indent-hanging-rel-exp
  2018-12-21 23:14 ` bug#33744: effect of ada-indent-hanging-rel-exp Stephen Leake
@ 2018-12-23 17:39   ` Stephen Leake
  0 siblings, 0 replies; 5+ messages in thread
From: Stephen Leake @ 2018-12-23 17:39 UTC (permalink / raw)
  To: 33744; +Cc: Ludovic Brenta

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





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#33744: 26.1; ada-mode 6.0.0 indentation of operators starting a line in a multi-line expression
  2018-12-14 15:57 bug#33744: 26.1; ada-mode 6.0.0 indentation of operators starting a line in a multi-line expression Ludovic Brenta
  2018-12-21 23:14 ` bug#33744: effect of ada-indent-hanging-rel-exp Stephen Leake
  2018-12-21 23:18 ` Stephen Leake
@ 2019-01-08 11:47 ` Ludovic Brenta
  2 siblings, 0 replies; 5+ messages in thread
From: Ludovic Brenta @ 2019-01-08 11:47 UTC (permalink / raw)
  To: 33744

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.





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-01-08 11:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-14 15:57 bug#33744: 26.1; ada-mode 6.0.0 indentation of operators starting a line in a multi-line expression Ludovic Brenta
2018-12-21 23:14 ` bug#33744: effect of ada-indent-hanging-rel-exp Stephen Leake
2018-12-23 17:39   ` Stephen Leake
2018-12-21 23:18 ` Stephen Leake
2019-01-08 11:47 ` bug#33744: 26.1; ada-mode 6.0.0 indentation of operators starting a line in a multi-line expression Ludovic Brenta

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.