mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2025-01-30 19:53:09 +00:00
Change ruby-align-chained-calls indendation
* lisp/progmodes/ruby-mode.el (ruby-smie-rules): Align with the first sibling on the previous line instead of the last (bug#32496). That is, before it used to be one.two.three .four and now it is one.two.three .four
This commit is contained in:
parent
e27385ec37
commit
8c023e5ea1
18
etc/NEWS
18
etc/NEWS
@ -2785,6 +2785,19 @@ different timezone causing a difference in the date.
|
||||
Instead you need to do "emacs -f dun-batch" to start the game in
|
||||
batch mode.
|
||||
|
||||
** Ruby Mode
|
||||
|
||||
---
|
||||
** 'ruby-use-smie' is declared obsolete.
|
||||
SMIE is now always enabled and 'ruby-use-smie' only controls whether
|
||||
indentation is done using SMIE or with the old ad-hoc code.
|
||||
|
||||
---
|
||||
** Indentation has changed when 'ruby-align-chained-calls' is non-nil.
|
||||
This previously used to align subsequent lines with the last sibling,
|
||||
but it now aligns with the first sibling (which is the preferred style
|
||||
in Ruby).
|
||||
|
||||
|
||||
* New Modes and Packages in Emacs 28.1
|
||||
|
||||
@ -3108,11 +3121,6 @@ back in Emacs 23.1. The affected functions are: 'make-obsolete',
|
||||
'replace-regexp-in-string', 'catch', 'throw', 'error', 'signal'
|
||||
and 'play-sound-file'.
|
||||
|
||||
---
|
||||
** 'ruby-use-smie' is declared obsolete.
|
||||
SMIE is now always enabled and 'ruby-use-smie' only controls whether
|
||||
indentation is done using SMIE or with the old ad-hoc code.
|
||||
|
||||
---
|
||||
** 'sql-*-statement-starters' are no longer user options.
|
||||
These variables describe facts about the SQL standard and
|
||||
|
@ -640,7 +640,15 @@ It is used when `ruby-encoding-magic-comment-style' is set to `custom'."
|
||||
('(:before . "do") (ruby-smie--indent-to-stmt))
|
||||
('(:before . ".")
|
||||
(if (smie-rule-sibling-p)
|
||||
(and ruby-align-chained-calls 0)
|
||||
(when ruby-align-chained-calls
|
||||
(while
|
||||
(let ((pos (point))
|
||||
(parent (smie-backward-sexp ".")))
|
||||
(if (not (equal (nth 2 parent) "."))
|
||||
(progn (goto-char pos) nil)
|
||||
(goto-char (nth 1 parent))
|
||||
(not (smie-rule-bolp)))))
|
||||
(cons 'column (current-column)))
|
||||
(smie-backward-sexp ".")
|
||||
(cons 'column (+ (current-column)
|
||||
ruby-indent-level))))
|
||||
@ -828,6 +836,7 @@ The style of the comment is controlled by `ruby-encoding-magic-comment-style'."
|
||||
;; `ruby-calculate-indent' in user init files still call it.
|
||||
(defun ruby-current-indentation ()
|
||||
"Return the indentation level of current line."
|
||||
(declare (obsolete nil "28.1"))
|
||||
(save-excursion
|
||||
(beginning-of-line)
|
||||
(back-to-indentation)
|
||||
|
@ -357,7 +357,7 @@ VALUES-PLIST is a list with alternating index and value elements."
|
||||
(let ((ruby-align-chained-calls t))
|
||||
(ruby-should-indent-buffer
|
||||
"one.two.three
|
||||
| .four
|
||||
| .four
|
||||
|
|
||||
|my_array.select { |str| str.size > 5 }
|
||||
| .map { |str| str.downcase }"
|
||||
@ -908,6 +908,33 @@ VALUES-PLIST is a list with alternating index and value elements."
|
||||
(should (equal (buffer-string) orig))))
|
||||
(kill-buffer buf))))
|
||||
|
||||
(ert-deftest ruby--test-chained-indentation ()
|
||||
(with-temp-buffer
|
||||
(ruby-mode)
|
||||
(setq-local ruby-align-chained-calls t)
|
||||
(insert "some_variable.where
|
||||
.not(x: nil)
|
||||
.where(y: 2)
|
||||
")
|
||||
(indent-region (point-min) (point-max))
|
||||
(should (equal (buffer-string)
|
||||
"some_variable.where
|
||||
.not(x: nil)
|
||||
.where(y: 2)
|
||||
")))
|
||||
|
||||
(with-temp-buffer
|
||||
(ruby-mode)
|
||||
(setq-local ruby-align-chained-calls t)
|
||||
(insert "some_variable.where.not(x: nil)
|
||||
.where(y: 2)
|
||||
")
|
||||
(indent-region (point-min) (point-max))
|
||||
(should (equal (buffer-string)
|
||||
"some_variable.where.not(x: nil)
|
||||
.where(y: 2)
|
||||
"))))
|
||||
|
||||
(provide 'ruby-mode-tests)
|
||||
|
||||
;;; ruby-mode-tests.el ends here
|
||||
|
Loading…
Reference in New Issue
Block a user