From: Dmitry Gutov Date: Wed, 18 Jan 2023 01:21:32 +0000 (+0200) Subject: ruby-ts-mode: Obey the option ruby-method-call-indent X-Git-Tag: emacs-29.0.90~687 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=343b9b3dfe370a7e65d499b499621f87e722ea71;p=emacs.git 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. --- diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el index 7e30ece1fd7..27e5d002881 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 be98465881f..9959de4fe71 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 1d686a2ac53..1d2cfbfb901 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)