GNU bug report logs -
#60186
29.0.60; ruby-mode indentation of multi-line expressions
Previous Next
Reported by: Aaron Jensen <aaronjensen <at> gmail.com>
Date: Mon, 19 Dec 2022 02:55:02 UTC
Severity: normal
Found in version 29.0.60
Fixed in version 29.1
Done: Dmitry Gutov <dgutov <at> yandex.ru>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
On 20/12/2022 22:05, Aaron Jensen wrote:
>> some_variable = some_number + some_other_number *
>> some_third_number +
>> some_fourth_number -
>> some_fifth_number
>
> Yeah, with this I'd probably be trying to give a name to some of the
> things (what is the name of the product there?) I don't think I've
> ever seen code like that in practice to be honest.
Sure, but if such complex structures are not used, it also doesn't
matter that the ruby-mode indents them differently from the "community
baseline".
But it could still help when prototyping code, fiddling with the
implementation (to factor pieces out into named variables later), etc.
>> One might ask why it's lined up to 'map' only after it's moved to the
>> next line, but not in the first example.
>
> It's never lined up to map, I don't think that's the right way to
> think about it. It's lined up to indent level 1. It isn't until after
> the `end' that the indent level returns to 0.
>
> Line continuation (mid-expression): +1 indent level
> Block opening (mid-block): +1 indent level
> Paren opening (mid-arguments/params): +1 indent level
> And all the closing/endings: -1 indent level
>
> Only one indent level can be added per line, so all that matters is
> where the line ends. In short, there are a set of expressions that
> require indentation if they span multiple lines:
>
> expression-start
> expression-middle
> expression-end
I think I got it. Only one indent level can be added for the duration of
a statement. Unless there are nested blocks or parens/brackets/braces.
> I haven't tried the patch yet, but I'll give it a shot.
See this new patch instead.
The code is messier than I'd like it to be, but it seems to handle all
of the cases mentioned so far and more (including the
dots-at-indentation style, thanks).
[ruby-simplified-indent-v3.diff (text/x-patch, attachment)]
This bug report was last modified 2 years and 176 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.