GNU bug report logs -
#54702
29.0.50; ruby-mode indentation: endless methods
Previous Next
Reported by: Aaron Jensen <aaronjensen <at> gmail.com>
Date: Mon, 4 Apr 2022 02:04:02 UTC
Severity: normal
Found in version 29.0.50
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
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 ()
This bug report was last modified 2 years and 214 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.