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

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

Re: [Ada-mode-users] inconsistent indentation of function parameter list


From: Stephen Leake
Subject: Re: [Ada-mode-users] inconsistent indentation of function parameter lists at call sites
Date: Mon, 21 Nov 2016 14:19:44 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (windows-nt)

Ludovic Brenta <address@hidden> writes:

> in the program below (indented by ada-node 5.2.1) we see that the
> opening paren is indented by ada-indent relative to the first non-
> blank character in the preceding line, not the function name.  This
> yields results that are visually inconsistent.  Our preferred style
> is always to indent the opening paren relative to the name of the
> function, as in [1bis] and [3bis]:
>
> procedure P is
>   function F (A : Boolean; B : Boolean) return Boolean is (A and B);
>   X : Boolean;
> begin
>   X
>     := F
>       (A => True,
>        B => False); -- [1]
>   X := F (A => True,
>           B => False); -- [2]
>   X := F
>     (A => True,
>      B => False); -- [3]
>   -- Below are examples not indented by ada-mode:
>   X
>     := F
>          (A => True,
>           B => True); -- [1bis]
>   X := F
>          (A => True,
>           B => True); -- [3bis]
> end P;

this will have to be an option; I definitely prefer the current
behavior. Your examples, with longer names:


   X_long_name
     := F_long_name
          (A => True,
           B => True);

To me, this looks like a double indent of (A. But I would always put
':=' on the previous line anyway.


   X_long_name := F_long_name
                   (A => True,
                    B => True); 

Here the indent depends on the length of the left hand side.

What do you do when there is no function name on the right? Current code
gives:

      X :=
        (1 + 2 + 3);

(same as when a function name is present)

do you prefer:

      X :=
            (1 + 2 + 3);

?

Hmm, in looking at the code, I see that NEWS-ada-mode.text lies; '(' is
_not_ always indented with ada-indent-broken. Apparently I wrote the
NEWS entry and then forgot to fix the code! sigh. That does not affect
this case.


Name for the new option: ada-indent-paren-rel-rhs ? (similar to
ada-indent-record-rel-type). Default nil for current behavior, t for
yours.

The new option would be handled in ada-wisi.el
ada-wisi-indent-containing. Currently that has:

       ((memq (wisi-cache-class cache)
              '(expression-start))
         ;; comments
        (+ (ada-wisi-current-indentation) offset))

I think this would work (not tested):

       ((memq (wisi-cache-class cache)
              '(expression-start))
         ;; comments
        (if ada-indent-paren-rel-rhs
           (+ (current-column) offset)
         (+ (ada-wisi-current-indentation) offset)))

-- 
-- Stephe



reply via email to

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