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

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

Re: [Ada-mode-users] indentation of consecutive comment lines


From: Stephen Leake
Subject: Re: [Ada-mode-users] indentation of consecutive comment lines
Date: Mon, 21 Nov 2016 15:05:30 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (windows-nt)

Ludovic Brenta <address@hidden> writes:

> Hello,
>
> In the example below, ada-mode indents the second comment line
> ("Intention to create...") relative to the start of the comment on the
> preceding line.
>
>     procedure Explicit_Raise is
>     begin
>       Debug.Trace (Me, "EXPLICIT_RAISE");
>       raise Constraint_Error;
>     exception
>       when Constraint_Error => --## rule line off Invisible_Exception
>                                -- Intention to create core-dump on
> Constraint_Error, and continuation of the tests after-wards.
>         null;
>     end Explicit_Raise;
>
> I understand that this is an explicit design decision that mimicks a
> similar decision in lisp-mode.  In other words, it's not a bug, it's a
> feature :)  The problem is that gnat disagrees:
>
> param_test_p.adb:757:32: (style) bad column
>

That's what ada-indent-comment-gnat is for; it's supposed to override
other rules so gnat is happy.

But doing (setq ada-indent-comment-gnat t) doesn't help here.
ada-wisi-comment should check ada-indent-comment-gnat in the 'comment is
after a comment' case.

Fixing that to be:

      (t
       ;; comment is after a comment
       (forward-comment -1)
       (let ((indent (current-column)))
         (if ada-indent-comment-gnat
             (cond
              ((= 0 (% indent ada-indent))
               indent)

              (t ;; probably after comment that follows code on the same line
               (+ indent (% indent ada-indent)))
              )
           indent)))

gives:

   when Constraint_Error => --## rule line off Invisible_Exception
                             -- Intention to create core-dump on

You can then manually change the first line to line up.

-- 
-- Stephe



reply via email to

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