On 7 Mar 2016, at 00:16, Piotr Trojanek <[email protected]> wrote: > > On Sat, Mar 5, 2016 at 5:29 PM, Simon Wright <[email protected]> wrote: >> Piotr, do you have a rule to propose as to when the comment should align >> with the _next_ line? perhaps if the next line is less indented? (but what >> about "end loop"?) > > In GNAT sources the rule is, I think, to indent with the next line if > it starts with 'else' or 'elsif'. It would be great if ada-mode could > do this. > > After reading the manual I thought that I can manually indent comments > that are followed by 'else' or 'elsif', and ada-mode will not move > them when I reindent a region or a buffer. This was not the case and > so I got confused. > > Then I looked into the source code of ada-mode and did a similar > translation to Simon's :) However, to me the algorithm was not > transparent, so I decided to ask before attempting to write a patch.
I have a small patch (ada-wisi.el.diff-sal) which fixes the 'leave alone if already indented to a multiple of ada-indent' problem. I have a more extensive patch (ada-wisi.el.diff-sjw) which, with ada-indent-comment-gnat: t, If on line 1, leave indentation as-is (easy to set it to 0). If current indentation is a multiple of ada-indent (and not 0), leave as-is. If the calculated indentation of the next non-comment non-blank line is less than that of the previous non-blank line then indent to the next ncnb line, otherwise to the place that would have been used anyway (sorry about vagueness of the last part!) (I think it would have been almost as good to just use "if current indentation is a multiple of ada-indent (and not 0), leave as-is", then you could align with 'else' or 'elsif' if you wanted). Aside from the change to ada_mode-conditional_expressions.adb, the only failing test was ada_mode-parens.adb, which clearly needs more work.
ada-wisi.el.diff-sal
Description: Binary data
ada-wisi.el.diff-sjw
Description: Binary data
ada_mode-parens.adb.diff
Description: Binary data
_______________________________________________ Emacs-ada-mode mailing list [email protected] http://host114.hostmonster.com/mailman/listinfo/emacs-ada-mode_stephe-leake.org
