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

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

bug#60110: 29.0.60; ruby-mode method parameter alignment


From: Dmitry Gutov
Subject: bug#60110: 29.0.60; ruby-mode method parameter alignment
Date: Mon, 19 Dec 2022 00:32:01 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2

Hi Aaron,

Thanks for the report.

On 16/12/2022 07:04, Aaron Jensen wrote:

Currently, ruby-mode smie indents method parameters like this:

def some_method(
     some_arg,
     some_other_arg
   )
end

def self.some_method(
       some_arg,
       some_other_arg
     )
end

I'm assuming the difference in indentation between these posted cases is just an email/bug tracker bug. If they are sometimes different, please let me know. That would be another bug.

I would prefer to be able to indent them like this:

def some_method(
   some_arg,
   some_other_arg
)
end

def self.some_method(
   some_arg,
   some_other_arg
)
end

See the attached patch. (setq ruby-method-params-indent 0) should do it.

Rubocop has two rules that govern this behavior:

Layout/FirstParameterIndentation: consistent
https://docs.rubocop.org/rubocop/1.40/cops_layout.html#layoutfirstparameterindentation

Layout/ParameterAlignment: with_first_parameter and
with_fixed_indentation would both work. I don't have a strong opinion on
this, because I usually break after a ( if I am going to put parameters
on their own line. Leaving the first one on the same line as the method
name is not as scannable.
https://docs.rubocop.org/rubocop/1.40/cops_layout.html#layoutparameteralignment

All right. It doesn't seem to support many styles, only indenting the first param against the opening paren, and against the beginning of "def". But it confirmed my idea for the option name (a generic one).

Attachment: ruby-method-params-indent.diff
Description: Text Data


reply via email to

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