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

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

bug#54702: 29.0.50; ruby-mode indentation: endless methods


From: Dmitry Gutov
Subject: bug#54702: 29.0.50; ruby-mode indentation: endless methods
Date: Wed, 27 Apr 2022 05:44:36 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0

Hi Aaron,

On 04.04.2022 05:03, Aaron Jensen wrote:

Ruby 3 and 3.1 bring us different versions of endless methods. They
currently don't indent correctly in `ruby-mode`:

Current:

```rb
class Bar
   def foo = bar

     def baz
     end
   end
```

Expected:

```rb
class Bar
   def foo = bar

   def baz
   end
end
```

Thanks for the report.

I'll work on this further, but here's a quick-and-dirty patch to fix the indentation problems.

diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index a197724634..3733603fb3 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -528,6 +528,9 @@ ruby-smie--forward-token
               (ruby-smie--forward-token)) ;Fully redundant.
              (t ";")))
            ((equal tok "&.") ".")
+           ((and (equal tok "def")
+                 (looking-at " *[a-zA-Z0-9_]* *\\(([^()]*)\\)? *="))
+            "def=")
            (t tok)))))))))

 (defun ruby-smie--backward-token ()
@@ -575,6 +578,9 @@ ruby-smie--backward-token
             (ruby-smie--backward-token)) ;Fully redundant.
            (t ";")))
          ((equal tok "&.") ".")
+         ((and (equal tok "def")
+               (looking-at "def *[a-zA-Z0-9_]* *\\(([^()]*)\\)? *="))
+          "def=")
          (t tok)))))))

 (defun ruby-smie--indent-to-stmt ()





reply via email to

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