unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#61822: 29.0.60; Ruby indentation with assignment and method calls
@ 2023-02-26 18:43 Aaron Jensen
  2023-02-26 22:18 ` Dmitry Gutov
  0 siblings, 1 reply; 6+ messages in thread
From: Aaron Jensen @ 2023-02-26 18:43 UTC (permalink / raw)
  To: 61822; +Cc: dgutov


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
)





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#61822: 29.0.60; Ruby indentation with assignment and method calls
  2023-02-26 18:43 bug#61822: 29.0.60; Ruby indentation with assignment and method calls Aaron Jensen
@ 2023-02-26 22:18 ` Dmitry Gutov
  2023-02-26 22:57   ` Aaron Jensen
  0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Gutov @ 2023-02-26 22:18 UTC (permalink / raw)
  To: Aaron Jensen, 61822

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))






^ permalink raw reply related	[flat|nested] 6+ messages in thread

* bug#61822: 29.0.60; Ruby indentation with assignment and method calls
  2023-02-26 22:18 ` Dmitry Gutov
@ 2023-02-26 22:57   ` Aaron Jensen
  2023-02-26 23:57     ` Dmitry Gutov
  0 siblings, 1 reply; 6+ messages in thread
From: Aaron Jensen @ 2023-02-26 22:57 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 61822

On Sun, Feb 26, 2023 at 5:18 PM Dmitry Gutov <dgutov@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!





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#61822: 29.0.60; Ruby indentation with assignment and method calls
  2023-02-26 22:57   ` Aaron Jensen
@ 2023-02-26 23:57     ` Dmitry Gutov
  2023-02-26 23:59       ` Aaron Jensen
  0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Gutov @ 2023-02-26 23:57 UTC (permalink / raw)
  To: Aaron Jensen; +Cc: 61822

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)))






^ permalink raw reply related	[flat|nested] 6+ messages in thread

* bug#61822: 29.0.60; Ruby indentation with assignment and method calls
  2023-02-26 23:57     ` Dmitry Gutov
@ 2023-02-26 23:59       ` Aaron Jensen
  2023-02-27  0:10         ` Dmitry Gutov
  0 siblings, 1 reply; 6+ messages in thread
From: Aaron Jensen @ 2023-02-26 23:59 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 61822

On Sun, Feb 26, 2023 at 6:57 PM Dmitry Gutov <dgutov@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





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#61822: 29.0.60; Ruby indentation with assignment and method calls
  2023-02-26 23:59       ` Aaron Jensen
@ 2023-02-27  0:10         ` Dmitry Gutov
  0 siblings, 0 replies; 6+ messages in thread
From: Dmitry Gutov @ 2023-02-27  0:10 UTC (permalink / raw)
  To: Aaron Jensen; +Cc: 61822-done

On 27/02/2023 01:59, Aaron Jensen wrote:
> On Sun, Feb 26, 2023 at 6:57 PM Dmitry Gutov<dgutov@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.





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-02-27  0:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-26 18:43 bug#61822: 29.0.60; Ruby indentation with assignment and method calls Aaron Jensen
2023-02-26 22:18 ` Dmitry Gutov
2023-02-26 22:57   ` Aaron Jensen
2023-02-26 23:57     ` Dmitry Gutov
2023-02-26 23:59       ` Aaron Jensen
2023-02-27  0:10         ` Dmitry Gutov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).