GNU bug report logs - #60186
29.0.60; ruby-mode indentation of multi-line expressions

Previous Next

Package: emacs;

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


Message #47 received at 60186 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Aaron Jensen <aaronjensen <at> gmail.com>
Cc: 60186 <at> debbugs.gnu.org
Subject: Re: bug#60186: 29.0.60; ruby-mode indentation of multi-line
 expressions
Date: Sat, 24 Dec 2022 00:26:00 +0200
On 23/12/2022 06:12, Aaron Jensen wrote:

>> See the new one attached.
> 
> Seems to work well with everything I threw at it.

Thank you. I think I'll tinker with it and then push to master sometime 
later. Maybe after 29 RC is cut, or if I get to a nicer rewrite earlier.

>> BTW, I'm surprised you haven't mentioned the case of parenless calls:
>>
>> foo bar,
>>       baz,
>>       tee
>>
>> IUUC the Rails core has decided to forgo this indentation style. Not
>> sure about the statistics across other popular projects.
> 
> I try to avoid this style in general.

Is that also true for the other "codebases you've seen" referred to in 
the first message here?

> The simplified style with the 2
> spaces means the first argument is on a different plane than the rest
> which negatively impacts scanning.

Makes sense.

> With either indentation style, the
> first argument (which is the most significant one when a method is
> properly designed) will have the least presence when scanning. It's
> just not a good format in my experience. In our code we take it a step
> further and always use parentheses except for in class level "macros".

That's also my preference and true of the code I've seen. But "class 
level macros" are often an important part of projects, be that 
ActiveRecord validations, or DSL-like calls in Grape (routes, params, etc).

So I wonder whether we should alter parenless calls' indentation for the 
"simplified" style.

I checked out some popular projects out there. Rails' style is 
inconsistent, with class-level parenless calls lined up vertically and 
the rare use of them inside methods seem to go the "simplified" route. 
I'm not sure if that's intentional, or whether it's just written by 
different people.

Redmine mixes styles, but mostly on the side of lining up.

Spree lines up and overall seems to vindicate the default "lispy" 
indentation style, e.g. here:

https://github.com/spree/spree/blob/main/core/app/models/spree/zone.rb
https://github.com/spree/spree/blob/main/core/app/models/spree/tax_rate.rb

Though they also like to line up the keyword arguments according to 
Rubocop's defaults 
(https://github.com/spree/spree/blob/main/core/app/models/spree/product.rb#L63), 
something we don't support yet.

Do you have a source-available example of a project in your preferred 
coding style?

Chef, perhaps?

https://github.com/chef/chef/blob/main/lib/chef/application/base.rb
https://github.com/chef/chef/blob/main/lib/chef/application/client.rb

> This means that any time we decide to split a method invocation on
> multiple lines we use the basic newline after ( style.

For "class-level macros" as well?




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.