From: Dmitry Gutov Date: Wed, 18 Jan 2023 00:55:09 +0000 (+0200) Subject: ruby-ts-mode: Obey the option ruby-after-operator-indent X-Git-Tag: emacs-29.0.90~688 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=045404d1aac;p=emacs.git ruby-ts-mode: Obey the option ruby-after-operator-indent * lisp/progmodes/ruby-ts-mode.el (ruby-ts--after-op-indent-p): New function. (ruby-ts--indent-rules): Use it. * test/lisp/progmodes/ruby-ts-mode-tests.el: Run indent test for ruby-after-operator-indent.rb. * test/lisp/progmodes/ruby-mode-resources/ruby-ts.rb: Make sure indentation vars are at their default values. --- diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el index e629ff19672..7e30ece1fd7 100644 --- a/lisp/progmodes/ruby-ts-mode.el +++ b/lisp/progmodes/ruby-ts-mode.el @@ -685,6 +685,10 @@ a statement container is a node that matches ;; Old... probably too simple ((parent-is "block_parameters") first-sibling 1) + ((and (not ruby-ts--after-op-indent-p) + (parent-is "binary\\|conditional")) + (ruby-ts--bol ruby-ts--statement-ancestor) ruby-indent-level) + ((parent-is "binary") ruby-ts--binary-indent-anchor 0) @@ -790,6 +794,9 @@ a statement container is a node that matches (forward-char ruby-indent-level)) (point))) +(defun ruby-ts--after-op-indent-p (&rest _) + ruby-after-operator-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 92d62f92e52..be98465881f 100644 --- a/test/lisp/progmodes/ruby-mode-resources/ruby-ts.rb +++ b/test/lisp/progmodes/ruby-mode-resources/ruby-ts.rb @@ -56,4 +56,7 @@ qux = foo.fee ? # Local Variables: # mode: ruby-ts +# ruby-after-operator-indent: t +# ruby-block-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 d7b6258385b..1d686a2ac53 100644 --- a/test/lisp/progmodes/ruby-ts-mode-tests.el +++ b/test/lisp/progmodes/ruby-ts-mode-tests.el @@ -251,8 +251,9 @@ The whitespace before and including \"|\" on each line is removed." (kill-buffer buf))))) (ruby-ts-deftest-indent "ruby-ts.rb") -(ruby-ts-deftest-indent "ruby-method-params-indent.rb") +(ruby-ts-deftest-indent "ruby-after-operator-indent.rb") (ruby-ts-deftest-indent "ruby-block-indent.rb") +(ruby-ts-deftest-indent "ruby-method-params-indent.rb") (provide 'ruby-ts-mode-tests)