GNU bug report logs -
#61822
29.0.60; Ruby indentation with assignment and method calls
Previous Next
Reported by: Aaron Jensen <aaronjensen <at> gmail.com>
Date: Sun, 26 Feb 2023 18:44:01 UTC
Severity: normal
Found in version 29.0.60
Done: Dmitry Gutov <dgutov <at> yandex.ru>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 61822 in the body.
You can then email your comments to 61822 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#61822
; Package
emacs
.
(Sun, 26 Feb 2023 18:44:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Aaron Jensen <aaronjensen <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Sun, 26 Feb 2023 18:44:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
I don't recall if this was a case we talked about, but this does not
indent as I would expect/hope with ruby-mode and this set:
(setq ruby-block-indent nil
ruby-method-call-indent nil
ruby-method-params-indent nil
ruby-after-operator-indent nil)
Actual:
some_variable = some_method(
some_argument
)
Expected:
some_variable = some_method(
some_argument
)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#61822
; Package
emacs
.
(Sun, 26 Feb 2023 22:19:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 61822 <at> debbugs.gnu.org (full text, mbox):
Hi!
On 26/02/2023 20:43, Aaron Jensen wrote:
>
> I don't recall if this was a case we talked about, but this does not
> indent as I would expect/hope with ruby-mode and this set:
>
> (setq ruby-block-indent nil
> ruby-method-call-indent nil
> ruby-method-params-indent nil
> ruby-after-operator-indent nil)
>
> Actual:
>
> some_variable = some_method(
> some_argument
> )
>
> Expected:
>
> some_variable = some_method(
> some_argument
> )
Somehow, we've never tested this one. On the higher level, it might
actually be consistent, similar to the following:
foo + bar(
asdasd
)
So the fix would depend on how you want them to behave.
Does the patch below work okay for you?
BTW, ruby-ts-mode handles these cases well already, I think.
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index dba9ff0a846..6778507bc2b 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -908,7 +908,8 @@ ruby-smie-rules
"+=" "-=" "*=" "/=" "%=" "**=" "&=" "|=" "^=" "|"
"<<=" ">>=" "&&=" "||=" "and" "or"))
(cond
- ((not ruby-after-operator-indent)
+ ((and (not ruby-after-operator-indent)
+ (smie-indent--hanging-p))
(ruby-smie--indent-to-stmt ruby-indent-level))
((and (smie-rule-parent-p ";" nil)
(smie-indent--hanging-p))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#61822
; Package
emacs
.
(Sun, 26 Feb 2023 22:58:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 61822 <at> debbugs.gnu.org (full text, mbox):
On Sun, Feb 26, 2023 at 5:18 PM Dmitry Gutov <dgutov <at> yandex.ru> wrote:
>
> Hi!
>
> On 26/02/2023 20:43, Aaron Jensen wrote:
> >
> > I don't recall if this was a case we talked about, but this does not
> > indent as I would expect/hope with ruby-mode and this set:
> >
> > (setq ruby-block-indent nil
> > ruby-method-call-indent nil
> > ruby-method-params-indent nil
> > ruby-after-operator-indent nil)
> >
> > Actual:
> >
> > some_variable = some_method(
> > some_argument
> > )
> >
> > Expected:
> >
> > some_variable = some_method(
> > some_argument
> > )
>
> Somehow, we've never tested this one. On the higher level, it might
> actually be consistent, similar to the following:
>
> foo + bar(
> asdasd
> )
>
> So the fix would depend on how you want them to behave.
>
> Does the patch below work okay for you?
>
> BTW, ruby-ts-mode handles these cases well already, I think.
>
> diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
> index dba9ff0a846..6778507bc2b 100644
> --- a/lisp/progmodes/ruby-mode.el
> +++ b/lisp/progmodes/ruby-mode.el
> @@ -908,7 +908,8 @@ ruby-smie-rules
> "+=" "-=" "*=" "/=" "%=" "**=" "&=" "|=" "^=" "|"
> "<<=" ">>=" "&&=" "||=" "and" "or"))
> (cond
> - ((not ruby-after-operator-indent)
> + ((and (not ruby-after-operator-indent)
> + (smie-indent--hanging-p))
> (ruby-smie--indent-to-stmt ruby-indent-level))
> ((and (smie-rule-parent-p ";" nil)
> (smie-indent--hanging-p))
>
This seems to work for me. I'm good with this being the same too as it
is with your patch:
foo + bar(
asdasd
)
Thank you!
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#61822
; Package
emacs
.
(Sun, 26 Feb 2023 23:58:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 61822 <at> debbugs.gnu.org (full text, mbox):
On 27/02/2023 00:57, Aaron Jensen wrote:
>> diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
>> index dba9ff0a846..6778507bc2b 100644
>> --- a/lisp/progmodes/ruby-mode.el
>> +++ b/lisp/progmodes/ruby-mode.el
>> @@ -908,7 +908,8 @@ ruby-smie-rules
>> "+=" "-=" "*=" "/=" "%=" "**=" "&=" "|=" "^=" "|"
>> "<<=" ">>=" "&&=" "||=" "and" "or"))
>> (cond
>> - ((not ruby-after-operator-indent)
>> + ((and (not ruby-after-operator-indent)
>> + (smie-indent--hanging-p))
>> (ruby-smie--indent-to-stmt ruby-indent-level))
>> ((and (smie-rule-parent-p ";" nil)
>> (smie-indent--hanging-p))
>>
> This seems to work for me. I'm good with this being the same too as it
> is with your patch:
>
> foo + bar(
> asdasd
> )
Hmm, that one seems to misindent this example:
some_variable = abc + some_method(
some_argument
)
How about this patch?
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index dba9ff0a846..559b62fef54 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -909,7 +909,9 @@ ruby-smie-rules
"<<=" ">>=" "&&=" "||=" "and" "or"))
(cond
((not ruby-after-operator-indent)
- (ruby-smie--indent-to-stmt ruby-indent-level))
+ (ruby-smie--indent-to-stmt (if (smie-indent--hanging-p)
+ ruby-indent-level
+ 0)))
((and (smie-rule-parent-p ";" nil)
(smie-indent--hanging-p))
ruby-indent-level)))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#61822
; Package
emacs
.
(Mon, 27 Feb 2023 00:00:01 GMT)
Full text and
rfc822 format available.
Message #17 received at 61822 <at> debbugs.gnu.org (full text, mbox):
On Sun, Feb 26, 2023 at 6:57 PM Dmitry Gutov <dgutov <at> yandex.ru> wrote:
>
> On 27/02/2023 00:57, Aaron Jensen wrote:
> >> diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
> >> index dba9ff0a846..6778507bc2b 100644
> >> --- a/lisp/progmodes/ruby-mode.el
> >> +++ b/lisp/progmodes/ruby-mode.el
> >> @@ -908,7 +908,8 @@ ruby-smie-rules
> >> "+=" "-=" "*=" "/=" "%=" "**=" "&=" "|=" "^=" "|"
> >> "<<=" ">>=" "&&=" "||=" "and" "or"))
> >> (cond
> >> - ((not ruby-after-operator-indent)
> >> + ((and (not ruby-after-operator-indent)
> >> + (smie-indent--hanging-p))
> >> (ruby-smie--indent-to-stmt ruby-indent-level))
> >> ((and (smie-rule-parent-p ";" nil)
> >> (smie-indent--hanging-p))
> >>
> > This seems to work for me. I'm good with this being the same too as it
> > is with your patch:
> >
> > foo + bar(
> > asdasd
> > )
>
> Hmm, that one seems to misindent this example:
>
> some_variable = abc + some_method(
> some_argument
> )
>
> How about this patch?
>
> diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
> index dba9ff0a846..559b62fef54 100644
> --- a/lisp/progmodes/ruby-mode.el
> +++ b/lisp/progmodes/ruby-mode.el
> @@ -909,7 +909,9 @@ ruby-smie-rules
> "<<=" ">>=" "&&=" "||=" "and" "or"))
> (cond
> ((not ruby-after-operator-indent)
> - (ruby-smie--indent-to-stmt ruby-indent-level))
> + (ruby-smie--indent-to-stmt (if (smie-indent--hanging-p)
> + ruby-indent-level
> + 0)))
> ((and (smie-rule-parent-p ";" nil)
> (smie-indent--hanging-p))
> ruby-indent-level)))
>
Nice catch. This patch looks good to me.
Aaron
Reply sent
to
Dmitry Gutov <dgutov <at> yandex.ru>
:
You have taken responsibility.
(Mon, 27 Feb 2023 00:12:04 GMT)
Full text and
rfc822 format available.
Notification sent
to
Aaron Jensen <aaronjensen <at> gmail.com>
:
bug acknowledged by developer.
(Mon, 27 Feb 2023 00:12:04 GMT)
Full text and
rfc822 format available.
Message #22 received at 61822-done <at> debbugs.gnu.org (full text, mbox):
On 27/02/2023 01:59, Aaron Jensen wrote:
> On Sun, Feb 26, 2023 at 6:57 PM Dmitry Gutov<dgutov <at> yandex.ru> wrote:
>> On 27/02/2023 00:57, Aaron Jensen wrote:
>>>> diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
>>>> index dba9ff0a846..6778507bc2b 100644
>>>> --- a/lisp/progmodes/ruby-mode.el
>>>> +++ b/lisp/progmodes/ruby-mode.el
>>>> @@ -908,7 +908,8 @@ ruby-smie-rules
>>>> "+=" "-=" "*=" "/=" "%=" "**=" "&=" "|=" "^=" "|"
>>>> "<<=" ">>=" "&&=" "||=" "and" "or"))
>>>> (cond
>>>> - ((not ruby-after-operator-indent)
>>>> + ((and (not ruby-after-operator-indent)
>>>> + (smie-indent--hanging-p))
>>>> (ruby-smie--indent-to-stmt ruby-indent-level))
>>>> ((and (smie-rule-parent-p ";" nil)
>>>> (smie-indent--hanging-p))
>>>>
>>> This seems to work for me. I'm good with this being the same too as it
>>> is with your patch:
>>>
>>> foo + bar(
>>> asdasd
>>> )
>> Hmm, that one seems to misindent this example:
>>
>> some_variable = abc + some_method(
>> some_argument
>> )
>>
>> How about this patch?
>>
>> diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
>> index dba9ff0a846..559b62fef54 100644
>> --- a/lisp/progmodes/ruby-mode.el
>> +++ b/lisp/progmodes/ruby-mode.el
>> @@ -909,7 +909,9 @@ ruby-smie-rules
>> "<<=" ">>=" "&&=" "||=" "and" "or"))
>> (cond
>> ((not ruby-after-operator-indent)
>> - (ruby-smie--indent-to-stmt ruby-indent-level))
>> + (ruby-smie--indent-to-stmt (if (smie-indent--hanging-p)
>> + ruby-indent-level
>> + 0)))
>> ((and (smie-rule-parent-p ";" nil)
>> (smie-indent--hanging-p))
>> ruby-indent-level)))
>>
> Nice catch. This patch looks good to me.
Thanks for testing, pushed to emacs-29.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Mon, 27 Mar 2023 11:24:08 GMT)
Full text and
rfc822 format available.
This bug report was last modified 2 years and 47 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.