emacs-bug-tracker
[Top][All Lists]
Advanced

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

bug#60321: closed (29.0.60; ruby-mode indentation of hash or array as fi


From: GNU bug Tracking System
Subject: bug#60321: closed (29.0.60; ruby-mode indentation of hash or array as first arg in multiline method call)
Date: Mon, 02 Sep 2024 19:03:02 +0000

Your message dated Mon, 2 Sep 2024 22:01:05 +0300
with message-id <79c2bec9-ceea-4bca-834e-245a9f2c756a@yandex.ru>
and subject line Re: bug#60321: 29.0.60; ruby-mode indentation of hash or array 
as first arg in multiline method call
has caused the debbugs.gnu.org bug report #60321,
regarding 29.0.60; ruby-mode indentation of hash or array as first arg in 
multiline method call
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@gnu.org.)


-- 
60321: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=60321
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- Subject: 29.0.60; ruby-mode indentation of hash or array as first arg in multiline method call Date: Sun, 25 Dec 2022 23:29:21 +0200 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2
X-Debbugs-CC: aaronjensen@gmail.com

Splitting off from debbugs#60186, second try.

Since this setting also seems orthogonal to the "simplified" preference, and it'll require some more work.

For future reference, here are the relevant Rubocop settings:

https://docs.rubocop.org/rubocop/cops_layout.html#layoutfirsthashelementindentation
https://docs.rubocop.org/rubocop/cops_layout.html#layoutfirstarrayelementindentation

On 25/12/2022 02:12, Aaron Jensen wrote:
We could also discuss cases like

    foo = bar({
                tee: 1,
                qux: 2
             })

    baz([
          1,
          2,
          3
        ])

but those would be an orthogonal feature. And I don't see them much in
the wild, for some reason.
The same logic would apply. It doesn't matter how many indent starters
there are in a line, the indentation should only increase by one:


foo = bar({
   tee: 1,
   qux: 2
})

baz([
   1,
   2,
   3
])

Of course, that begs the question what happens if you do this:

baz([
   1,
   2,
   3
]
)

Here are a couple trickier examples:

takes_multi_pairs_hash(x: {
  a: 1,
  b: 2
})

and_in_a_method_call({
  no: :difference
},
foo,
bar)

AFAICT even Rubocop doesn't have a setting which would indent the second one somewhat reasonably, while keeping two-space indent before "no".

And, I think again, the answer is a social one, rather than a technical one.

enh-ruby-mode and vim both do this this:

baz([
   1,
   2,
   3
]
    )

Yup, that looks pretty bizarre. OTOH, I don't see why a developer would put a newline between "]" and ")" in this case.




--- End Message ---
--- Begin Message --- Subject: Re: bug#60321: 29.0.60; ruby-mode indentation of hash or array as first arg in multiline method call Date: Mon, 2 Sep 2024 22:01:05 +0300 User-agent: Mozilla Thunderbird
On 02/09/2024 04:56, Aaron Jensen wrote:
It seems to me that anything other than 0 spaces would look inconsistent
with the first element (the hash), and its closing brace in particular.
Yeah, that's my sense as well, even if it looks awful, but you get what you get.

* Support for the new option in ruby-ts-mode (it's good to have parity).
Could you take the attached patch for a spin? Seems to work here, but
I'd like to have an extra confirmation.
I don't have the treesitter stuff installed at the moment, will try
this out shortly.
Thanks in advance.
I installed it and gave it a run on a few things. I didn't observe any
issues with it.

Great!

I've pushed both patches to emacs-30 (6c15b7710d4 and 24f12bdd77e) and now marking the issue as done. Thanks again for the patch.

To summarize for future readers: the default behavior doesn't change - at least not now - you need to customize the option for different indentation.


--- End Message ---

reply via email to

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