1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 06:20:55 -08:00

ruby-method-params-indent: New user option

* lisp/progmodes/ruby-mode.el (ruby-method-params-indent):
New option (bug#60110).

(ruby-smie-rules): Use it.

* etc/NEWS: Mention it.

* test/lisp/progmodes/ruby-mode-resources/ruby.rb:
Ensure the var's value is default.

* test/lisp/progmodes/ruby-mode-resources/ruby-method-params-indent.rb:
New file.

* test/lisp/progmodes/ruby-mode-tests.el (ruby-deftest-indent):
New macro, use it to run the indentation test using the new file.
Disable the :expensive-test tag, because neither runs for "longer
than some few seconds", both take significantly below 1s.
This commit is contained in:
Dmitry Gutov 2022-12-19 21:01:27 +02:00
parent b9e813f79f
commit 2b1fdbffcb
5 changed files with 62 additions and 13 deletions

View file

@ -268,6 +268,23 @@ Only has effect when `ruby-use-smie' is t."
:safe 'booleanp
:version "24.4")
(defcustom ruby-method-params-indent t
"Indentation of multiline method parameters.
When t, the parameters list is indented to the method name.
When a number, indent the parameters list this many columns
against the beginning of the method (the \"def\" keyword).
The value nil means the same as 0.
Only has effect when `ruby-use-smie' is t."
:type '(choice (const :tag "Indent to the method name" t)
(number :tag "Indent specified number of columns against def")
(const :tag "Indent to def" nil))
:safe (lambda (val) (or (memq val '(t nil)) (numberp val)))
:version 29.1)
(defcustom ruby-deep-arglist t
"Deep indent lists in parenthesis when non-nil.
Also ignores spaces after parenthesis when `space'.
@ -660,9 +677,12 @@ This only affects the output of the command `ruby-toggle-block'."
(unless (or (eolp) (forward-comment 1))
(cons 'column (current-column)))))
('(:before . " @ ")
(save-excursion
(skip-chars-forward " \t")
(cons 'column (current-column))))
(if (or (eq ruby-method-params-indent t)
(not (smie-rule-parent-p "def" "def=")))
(save-excursion
(skip-chars-forward " \t")
(cons 'column (current-column)))
(smie-rule-parent (or ruby-method-params-indent 0))))
('(:before . "do") (ruby-smie--indent-to-stmt))
('(:before . ".")
(if (smie-rule-sibling-p)