GNU bug report logs - #60110
29.0.60; ruby-mode method parameter alignment

Previous Next

Package: emacs;

Reported by: Aaron Jensen <aaronjensen <at> gmail.com>

Date: Fri, 16 Dec 2022 05:05:01 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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Aaron Jensen <aaronjensen <at> gmail.com>, 60110 <at> debbugs.gnu.org
Subject: bug#60110: 29.0.60; ruby-mode method parameter alignment
Date: Mon, 19 Dec 2022 00:32:01 +0200
[Message part 1 (text/plain, inline)]
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).
[ruby-method-params-indent.diff (text/x-patch, attachment)]

This bug report was last modified 2 years and 149 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.