diff options
| author | Dmitry Gutov | 2016-03-15 03:12:19 +0200 |
|---|---|---|
| committer | Dmitry Gutov | 2016-03-15 03:16:27 +0200 |
| commit | 040362001d66fd721d3a85cddfadf8041cc23f7f (patch) | |
| tree | 3a4a11905728e90916dd2be93be148d2c07ca707 | |
| parent | e6776f8362bbf6466c671cc8d381ba7da9e95301 (diff) | |
| download | emacs-040362001d66fd721d3a85cddfadf8041cc23f7f.tar.gz emacs-040362001d66fd721d3a85cddfadf8041cc23f7f.zip | |
Don't misindent arguments of a method call inside continuation
* lisp/progmodes/ruby-mode.el (ruby-smie-rules):
Use smie-indent-virtual instead of smie-rule-parent (bug#23015).
Simplify the traversal loop.
| -rw-r--r-- | lisp/progmodes/ruby-mode.el | 20 | ||||
| -rw-r--r-- | test/indent/ruby.rb | 11 |
2 files changed, 18 insertions, 13 deletions
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index 1c9f0f43086..35d0cc44ed8 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el | |||
| @@ -629,19 +629,13 @@ It is used when `ruby-encoding-magic-comment-style' is set to `custom'." | |||
| 629 | ;; because when `.' is inside the line, the | 629 | ;; because when `.' is inside the line, the |
| 630 | ;; additional indentation from it looks out of place. | 630 | ;; additional indentation from it looks out of place. |
| 631 | ((smie-rule-parent-p ".") | 631 | ((smie-rule-parent-p ".") |
| 632 | (let (smie--parent) | 632 | ;; Traverse up the call chain until the parent is not `.', |
| 633 | (save-excursion | 633 | ;; or `.' at indentation, or at eol. |
| 634 | ;; Traverse up the parents until the parent is "." at | 634 | (while (and (not (ruby-smie--bosp)) |
| 635 | ;; indentation, or any other token. | 635 | (equal (nth 2 (smie-backward-sexp ".")) ".") |
| 636 | (while (and (let ((parent (smie-indent--parent))) | 636 | (not (ruby-smie--bosp))) |
| 637 | (goto-char (cadr parent)) | 637 | (forward-char -1)) |
| 638 | (save-excursion | 638 | (smie-indent-virtual)) |
| 639 | (unless (integerp (car parent)) (forward-char -1)) | ||
| 640 | (not (ruby-smie--bosp)))) | ||
| 641 | (progn | ||
| 642 | (setq smie--parent nil) | ||
| 643 | (smie-rule-parent-p ".")))) | ||
| 644 | (smie-rule-parent)))) | ||
| 645 | (t (smie-rule-parent)))))) | 639 | (t (smie-rule-parent)))))) |
| 646 | (`(:after . ,(or `"(" "[" "{")) | 640 | (`(:after . ,(or `"(" "[" "{")) |
| 647 | ;; FIXME: Shouldn't this be the default behavior of | 641 | ;; FIXME: Shouldn't this be the default behavior of |
diff --git a/test/indent/ruby.rb b/test/indent/ruby.rb index 6ab814a4214..6793bfdec2a 100644 --- a/test/indent/ruby.rb +++ b/test/indent/ruby.rb | |||
| @@ -405,6 +405,17 @@ zoo | |||
| 405 | a.records().map(&:b).zip( | 405 | a.records().map(&:b).zip( |
| 406 | foo) | 406 | foo) |
| 407 | 407 | ||
| 408 | foo1 = | ||
| 409 | subject.update( | ||
| 410 | 1 | ||
| 411 | ) | ||
| 412 | |||
| 413 | foo2 = | ||
| 414 | subject. | ||
| 415 | update( | ||
| 416 | 2 | ||
| 417 | ) | ||
| 418 | |||
| 408 | # FIXME: This is not consistent with the example below it, but this | 419 | # FIXME: This is not consistent with the example below it, but this |
| 409 | # offset only happens if the colon is at eol, which wouldn't be often. | 420 | # offset only happens if the colon is at eol, which wouldn't be often. |
| 410 | # Tokenizing `bar:' as `:bar =>' would be better, but it's hard to | 421 | # Tokenizing `bar:' as `:bar =>' would be better, but it's hard to |