emacs-diffs
[Top][All Lists]
Advanced

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

emacs-29 343b9b3dfe 6/6: ruby-ts-mode: Obey the option ruby-method-call-


From: Dmitry Gutov
Subject: emacs-29 343b9b3dfe 6/6: ruby-ts-mode: Obey the option ruby-method-call-indent
Date: Tue, 17 Jan 2023 20:28:44 -0500 (EST)

branch: emacs-29
commit 343b9b3dfe370a7e65d499b499621f87e722ea71
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>

    ruby-ts-mode: Obey the option ruby-method-call-indent
    
    * lisp/progmodes/ruby-ts-mode.el
    (ruby-ts--method-call-indent-p): New function.
    (ruby-ts--indent-rules): Use it.
    
    * test/lisp/progmodes/ruby-ts-mode-tests.el:
    Run indent test for ruby-method-call-indent.rb.
    
    * test/lisp/progmodes/ruby-mode-resources/ruby-ts.rb:
    Add explicit value for ruby-method-call-indent.
---
 lisp/progmodes/ruby-ts-mode.el                     | 10 ++++++++++
 test/lisp/progmodes/ruby-mode-resources/ruby-ts.rb |  1 +
 test/lisp/progmodes/ruby-ts-mode-tests.el          |  1 +
 3 files changed, 12 insertions(+)

diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el
index 7e30ece1fd..27e5d00288 100644
--- a/lisp/progmodes/ruby-ts-mode.el
+++ b/lisp/progmodes/ruby-ts-mode.el
@@ -640,6 +640,13 @@ a statement container is a node that matches
            ;; else the second query aligns
            ;; `ruby-indent-level' spaces in from the parent.
            ((and ruby-ts--align-chain-p (match "\\." "call")) 
ruby-ts--align-chain 0)
+           ;; Obery ruby-method-call-indent, whether the dot is on
+           ;; this line or the previous line.
+           ((and (not ruby-ts--method-call-indent-p)
+                 (or
+                  (match "\\." "call")
+                  (query "(call \".\" (identifier) @indent)")))
+            parent 0)
            ((match "\\." "call") parent ruby-indent-level)
 
            ;; ruby-indent-after-block-in-continued-expression
@@ -797,6 +804,9 @@ a statement container is a node that matches
 (defun ruby-ts--after-op-indent-p (&rest _)
   ruby-after-operator-indent)
 
+(defun ruby-ts--method-call-indent-p (&rest _)
+  ruby-method-call-indent)
+
 (defun ruby-ts--class-or-module-p (node)
   "Predicate if NODE is a class or module."
   (string-match-p ruby-ts--class-or-module-regex (treesit-node-type node)))
diff --git a/test/lisp/progmodes/ruby-mode-resources/ruby-ts.rb 
b/test/lisp/progmodes/ruby-mode-resources/ruby-ts.rb
index be98465881..9959de4fe7 100644
--- a/test/lisp/progmodes/ruby-mode-resources/ruby-ts.rb
+++ b/test/lisp/progmodes/ruby-mode-resources/ruby-ts.rb
@@ -58,5 +58,6 @@ qux = foo.fee ?
 # mode: ruby-ts
 # ruby-after-operator-indent: t
 # ruby-block-indent: t
+# ruby-method-call-indent: t
 # ruby-method-params-indent: t
 # End:
diff --git a/test/lisp/progmodes/ruby-ts-mode-tests.el 
b/test/lisp/progmodes/ruby-ts-mode-tests.el
index 1d686a2ac5..1d2cfbfb90 100644
--- a/test/lisp/progmodes/ruby-ts-mode-tests.el
+++ b/test/lisp/progmodes/ruby-ts-mode-tests.el
@@ -253,6 +253,7 @@ The whitespace before and including \"|\" on each line is 
removed."
 (ruby-ts-deftest-indent "ruby-ts.rb")
 (ruby-ts-deftest-indent "ruby-after-operator-indent.rb")
 (ruby-ts-deftest-indent "ruby-block-indent.rb")
+(ruby-ts-deftest-indent "ruby-method-call-indent.rb")
 (ruby-ts-deftest-indent "ruby-method-params-indent.rb")
 
 (provide 'ruby-ts-mode-tests)



reply via email to

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