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

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

bug#61871: 29.0.60; ruby-mode indentation with destructuring assignment


From: Dmitry Gutov
Subject: bug#61871: 29.0.60; ruby-mode indentation with destructuring assignment
Date: Tue, 28 Feb 2023 20:37:19 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1

Hi!

On 28/02/2023 18:17, Aaron Jensen wrote:
I found another edge case:

foo, bar = baz.(
        some_arg
      )

Should indent to:

foo, bar = baz.(
   some_arg
)

Thanks for that. This one is caused by implicit syntax which it non-trivial for SMIE to handle. ruby-ts-mode, predictably, indents it fine.

Please try this patch out:

diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index 559b62fef54..beccb8182a7 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -916,11 +916,14 @@ ruby-smie-rules
             (smie-indent--hanging-p))
        ruby-indent-level)))
     (`(:before . "=")
-     (save-excursion
-      (and (smie-rule-parent-p " @ ")
-           (goto-char (nth 1 (smie-indent--parent)))
-           (smie-rule-prev-p "def=")
-           (cons 'column (+ (current-column) ruby-indent-level -3)))))
+     (or
+      (save-excursion
+        (and (smie-rule-parent-p " @ ")
+             (goto-char (nth 1 (smie-indent--parent)))
+             (smie-rule-prev-p "def=")
+             (cons 'column (+ (current-column) ruby-indent-level -3))))
+      (and (smie-rule-parent-p ",")
+           (smie-rule-parent))))
     (`(:after . ,(or "?" ":"))
      (if ruby-after-operator-indent
          ruby-indent-level






reply via email to

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