GNU bug report logs - #64589
30.0.50; smie-config-guess can break ruby indentation

Previous Next

Package: emacs;

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

Date: Thu, 13 Jul 2023 04:21:01 UTC

Severity: normal

Found in version 30.0.50

To reply to this bug, email your comments to 64589 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#64589; Package emacs. (Thu, 13 Jul 2023 04:21:02 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. (Thu, 13 Jul 2023 04:21:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Aaron Jensen <aaronjensen <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.0.50; smie-config-guess can break ruby indentation
Date: Thu, 13 Jul 2023 00:20:17 -0400
In repro.rb:

def some_method
  return some_other_method(
    some_argument
  )
end

emacs -Q repro.rb
M-x smie-config-guess

Type:

foo(
x
)

The x will not be indented. If smie-config-guess is omitted, it indents
as expected.



In GNU Emacs 30.0.50 (build 55, aarch64-apple-darwin22.5.0, NS
 appkit-2299.60 Version 13.4.1 (Build 22F82)) of 2023-07-12 built on
 Aarons-Laptop.local
Repository revision: d861de72289464e336c772f1741016a90a2118c5
Repository branch: master
Windowing system distributor 'Apple', version 10.3.2299
System Description:  macOS 13.4.1

Configured using:
 'configure --with-ns --with-native-compilation --with-modules
 --without-dbus --without-webp --disable-ns-self-contained'





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64589; Package emacs. (Thu, 19 Oct 2023 20:07:02 GMT) Full text and rfc822 format available.

Message #8 received at 64589 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dmitry <at> gutov.dev>
To: Aaron Jensen <aaronjensen <at> gmail.com>, 64589 <at> debbugs.gnu.org
Cc: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Subject: Re: bug#64589: 30.0.50; smie-config-guess can break ruby indentation
Date: Thu, 19 Oct 2023 23:05:54 +0300
Hi Aaron,

On 13/07/2023 07:20, Aaron Jensen wrote:
> In repro.rb:
> 
> def some_method
>    return some_other_method(
>      some_argument
>    )
> end
> 
> emacs -Q repro.rb
> M-x smie-config-guess
> 
> Type:
> 
> foo(
> x
> )
> 
> The x will not be indented. If smie-config-guess is omitted, it indents
> as expected.

Sorry about the late reply.

But it seems like this feature might be incompatible with the relatively 
complex way the ruby-mode indentation is written (the comments inside 
'smie-config--guess' seem to indicate so). So while it does sound cool 
to be able to use style detection, it might only work okay for certain 
languages/indentation rules.

One thing to note, though, is that it seems to want larger files, to be 
able to "learn" from more cases. But when I provide a larger file, it 
usually ends up saying "Nothing to change", even if some lines are 
indented differently from the current config. E.g. if I just expand your 
example to:

  def some_method
    return some_other_method(
      some_argument
    )

    foo(
      bar,
      tee
    )
  end

then adding foo(<RET> at the end indents predictably okay.

Perhaps Stefan as the author could tell us whether it's at all feasible 
to adjust ruby-mode to be more compatible with smie-config-guesser, or 
whether there could be some low-hanging fruit in the latter to help.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64589; Package emacs. (Thu, 19 Oct 2023 21:43:02 GMT) Full text and rfc822 format available.

Message #11 received at 64589 <at> debbugs.gnu.org (full text, mbox):

From: Aaron Jensen <aaronjensen <at> gmail.com>
To: Dmitry Gutov <dmitry <at> gutov.dev>
Cc: 64589 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#64589: 30.0.50; smie-config-guess can break ruby indentation
Date: Thu, 19 Oct 2023 17:41:19 -0400
On Thu, Oct 19, 2023 at 4:05 PM Dmitry Gutov <dmitry <at> gutov.dev> wrote:
>
> Hi Aaron,
>
> On 13/07/2023 07:20, Aaron Jensen wrote:
> > In repro.rb:
> >
> > def some_method
> >    return some_other_method(
> >      some_argument
> >    )
> > end
> >
> > emacs -Q repro.rb
> > M-x smie-config-guess
> >
> > Type:
> >
> > foo(
> > x
> > )
> >
> > The x will not be indented. If smie-config-guess is omitted, it indents
> > as expected.
>
> Sorry about the late reply.
>
> But it seems like this feature might be incompatible with the relatively
> complex way the ruby-mode indentation is written (the comments inside
> 'smie-config--guess' seem to indicate so). So while it does sound cool
> to be able to use style detection, it might only work okay for certain
> languages/indentation rules.
>
> One thing to note, though, is that it seems to want larger files, to be
> able to "learn" from more cases. But when I provide a larger file, it
> usually ends up saying "Nothing to change", even if some lines are
> indented differently from the current config. E.g. if I just expand your
> example to:
>
>    def some_method
>      return some_other_method(
>        some_argument
>      )
>
>      foo(
>        bar,
>        tee
>      )
>    end
>
> then adding foo(<RET> at the end indents predictably okay.
>
> Perhaps Stefan as the author could tell us whether it's at all feasible
> to adjust ruby-mode to be more compatible with smie-config-guesser, or
> whether there could be some low-hanging fruit in the latter to help.

Ok, thanks. The context here is that I use dtrt-indent and it invokes
this before doing its work. For now, I have disabled it in Ruby (which
I think is actually fine because I thankfully don't work with any Ruby
code that is something other than 2 spaces).

So right now, I'm not concerned about this personally, but it does
seem odd that it breaks indentation in some cases.

Thanks,

Aaron




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64589; Package emacs. (Thu, 19 Oct 2023 23:30:02 GMT) Full text and rfc822 format available.

Message #14 received at 64589 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dmitry <at> gutov.dev>
To: Aaron Jensen <aaronjensen <at> gmail.com>
Cc: 64589 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#64589: 30.0.50; smie-config-guess can break ruby indentation
Date: Fri, 20 Oct 2023 02:29:21 +0300
On 20/10/2023 00:41, Aaron Jensen wrote:
> Ok, thanks. The context here is that I use dtrt-indent and it invokes
> this before doing its work. For now, I have disabled it in Ruby (which
> I think is actually fine because I thankfully don't work with any Ruby
> code that is something other than 2 spaces).

All right.

> So right now, I'm not concerned about this personally, but it does
> seem odd that it breaks indentation in some cases.

Perhaps we'll simply end up documenting that it doesn't work for all 
SMIE modes, just for some. And dtrt-indent will have a whitelist.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64589; Package emacs. (Fri, 20 Oct 2023 02:17:01 GMT) Full text and rfc822 format available.

Message #17 received at 64589 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Dmitry Gutov <dmitry <at> gutov.dev>
Cc: 64589 <at> debbugs.gnu.org, Aaron Jensen <aaronjensen <at> gmail.com>
Subject: Re: bug#64589: 30.0.50; smie-config-guess can break ruby indentation
Date: Thu, 19 Oct 2023 22:15:52 -0400
> Perhaps we'll simply end up documenting that it doesn't work for all SMIE
> modes, just for some. And dtrt-indent will have a whitelist.

It's definitely the case that it's a "best effort" kind of tool, which
makes assumptions that don't always hold.
Using it unconditionally like `dtrt-indent` does seems ... optimistic,
but I'll take it as a compliment :-)


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64589; Package emacs. (Fri, 20 Oct 2023 03:41:02 GMT) Full text and rfc822 format available.

Message #20 received at 64589 <at> debbugs.gnu.org (full text, mbox):

From: Aaron Jensen <aaronjensen <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Dmitry Gutov <dmitry <at> gutov.dev>, 64589 <at> debbugs.gnu.org
Subject: Re: bug#64589: 30.0.50; smie-config-guess can break ruby indentation
Date: Thu, 19 Oct 2023 23:39:55 -0400
On Thu, Oct 19, 2023 at 10:15 PM Stefan Monnier
<monnier <at> iro.umontreal.ca> wrote:
>
> > Perhaps we'll simply end up documenting that it doesn't work for all SMIE
> > modes, just for some. And dtrt-indent will have a whitelist.
>
> It's definitely the case that it's a "best effort" kind of tool, which
> makes assumptions that don't always hold.
> Using it unconditionally like `dtrt-indent` does seems ... optimistic,
> but I'll take it as a compliment :-)
>
>
>         Stefan
>

Just to double check, the thing I found odd was that it broke some
indentation, but not all. I don't know anything about how it works or
what its impact is, but it wasn't like it disabled indentation across
the board. It just made much of the indentation stop working or break
in subtle ways.

This is what smie-config-buffer-local ends up as: ((-5 :elem basic 2))

Thanks,

Aaron




This bug report was last modified 1 year and 335 days ago.

Previous Next


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