ada-mode-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Ada-mode-users] Indenting incomplete code during editing


From: Ludovic Brenta
Subject: [Ada-mode-users] Indenting incomplete code during editing
Date: Wed, 26 Oct 2016 16:04:35 +0200
User-agent: Roundcube Webmail/0.5.3

Hello,

We have deployed ada-mode 5.2 as an option in our office and half a
dozen people are now using it in lieu of ada-mode 4.0; we are starting
to receive negative feedback about the indentation of code being
edited.  Consider this first example:

package body P is
  procedure G (Param : in Boolean) is
  begin
    Some_Statements;
  end G;
end P;

(ada-indent has been set to 2, not the default 3, for the past 20
years)

Now, point is before the closing paren and the user types ; RET to
insert a second parameter.  They expect the new line to be indented
and point to be under the P of Param, like so with * standing for
point:

package body P is
  procedure G (Param : in Boolean;
               *) is
  begin
    Some_Statements;
  end G;
end P;

Instead they get this:

package body P is
procedure G (Param : in Boolean;
*) is
  begin
    Some_Statement;
  end G;
end P;

so that not only point is misplaced but the line with "procedure G"
has been incorrectly re-indented and is now flushed left.  Ignoring
this, our user types the new parameter name:

package body P is
procedure G (Param : in Boolean;
New_Param : in Integer) is
  begin
    Some_Statement;
  end G;
end P;

and now has to press TAB to reindent both lines:

package body P is
  procedure G (Param : in Boolean;
               New_Param : in Integer) is
  begin
    Some_Statement;
  end G;
end P;

Is there a way to avoid:
- the reindentation of the first line;
- the bad indentation the the new line;
- the requirement for an explicit TAB to reindent

I think these questions go deeper than this particular example; they
have to do with the choice of basing the indentation engine on a
parser for a complete (in fact more than complete) Ada grammar.
Continuing on the example, suppose we now want to surround
Some_Statement in an "if" statement.  The user places point before
the S and then types "if New_Param > 0 then RET" and gets:

package body P is
  procedure G (Param : in Boolean;
               New_Param : in Integer) is
  begin
  if New_Param > 0 then
  Some_Statement;
  end G;
end P;

so both the "if" line and the "Some_Statement" line are badly
indented; the "if" line in particular was properly indented before
the user typed RET, so the feeling is that RET actively breaks
formatting.  The user expects this instead, again with * denoting
point:

package body P is
  procedure G (Param : in Boolean;
               New_Param : in Integer) is
  begin
    if New_Param > 0 then
      *Some_Statement;
  end G;
end P;

I think half of the annoyance could be avoided by simply preserving
the indentation of the line where the user typed RET.  The other
half is choosing a sensible indentation for the line containing
point after the RET, based only on the previous line.  But I might
be wrong.  Any opinions? Suggestions? Solutions?

--
Ludovic Brenta.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]