[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 045404d1aa 5/6: ruby-ts-mode: Obey the option ruby-after-operat
From: |
Dmitry Gutov |
Subject: |
emacs-29 045404d1aa 5/6: ruby-ts-mode: Obey the option ruby-after-operator-indent |
Date: |
Tue, 17 Jan 2023 20:28:44 -0500 (EST) |
branch: emacs-29
commit 045404d1aac1a9bd4ad2a3af8db577d7f05b9d03
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>
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.
---
lisp/progmodes/ruby-ts-mode.el | 7 +++++++
test/lisp/progmodes/ruby-mode-resources/ruby-ts.rb | 3 +++
test/lisp/progmodes/ruby-ts-mode-tests.el | 3 ++-
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el
index e629ff1967..7e30ece1fd 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 92d62f92e5..be98465881 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 d7b6258385..1d686a2ac5 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)
- emacs-29 updated (c4f0b6ccea -> 343b9b3dfe), Dmitry Gutov, 2023/01/17
- emacs-29 343b9b3dfe 6/6: ruby-ts-mode: Obey the option ruby-method-call-indent, Dmitry Gutov, 2023/01/17
- emacs-29 045404d1aa 5/6: ruby-ts-mode: Obey the option ruby-after-operator-indent,
Dmitry Gutov <=
- emacs-29 9ed9ff4690 1/6: ruby-ts-mode: Fix the rules for hanging arrays and hashes, Dmitry Gutov, 2023/01/17
- emacs-29 5e2e68a0c2 2/6: ruby-ts-mode: Fix indent inside parenthesized_expr and else/end after unless, Dmitry Gutov, 2023/01/17
- emacs-29 ac5516bd7d 3/6: ruby-ts-mode: Fix/change indentation of a continuation method call, Dmitry Gutov, 2023/01/17
- emacs-29 300ca6ac37 4/6: ruby-ts-mode: Fix indent after operator or conditional, Dmitry Gutov, 2023/01/17