aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Gutov2013-12-14 08:46:13 +0200
committerDmitry Gutov2013-12-14 08:46:13 +0200
commit276bc3337b27bcd76aa2735ed96c160c6a1b573a (patch)
tree998438a0496b773195c79bd11f9372d06497d96f
parentdc7909c40a5524af650a7d4233f393a43bf6706c (diff)
downloademacs-276bc3337b27bcd76aa2735ed96c160c6a1b573a.tar.gz
emacs-276bc3337b27bcd76aa2735ed96c160c6a1b573a.zip
Fix bug#16118
* lisp/progmodes/ruby-mode.el (ruby-smie-rules): Return nil before open-paren tokens when preceded by a open-paren, too. (ruby-smie-rules): Handle virtual indentation after open-paren tokens specially. If there is code between it and eol, return the column where is starts. * test/indent/ruby.rb: New examples.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/progmodes/ruby-mode.el17
-rw-r--r--test/ChangeLog4
-rw-r--r--test/indent/ruby.rb39
4 files changed, 61 insertions, 7 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index ce088032faa..62045b9cb64 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12013-12-14 Dmitry Gutov <dgutov@yandex.ru>
2
3 * progmodes/ruby-mode.el (ruby-smie-rules): Return nil before
4 open-paren tokens when preceded by a open-paren, too.
5 (ruby-smie-rules): Handle virtual indentation after open-paren
6 tokens specially. If there is code between it and eol, return the
7 column where is starts (Bug#16118).
8
12013-12-13 Teodor Zlatanov <tzz@lifelogs.com> 92013-12-13 Teodor Zlatanov <tzz@lifelogs.com>
2 10
3 * progmodes/cfengine.el: Fix `add-hook' doc. 11 * progmodes/cfengine.el: Fix `add-hook' doc.
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index af7a4d8c321..13f7335d042 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -549,10 +549,21 @@ It is used when `ruby-encoding-magic-comment-style' is set to `custom'."
549 (ruby-smie--indent-to-stmt)) 549 (ruby-smie--indent-to-stmt))
550 ((smie-rule-hanging-p) 550 ((smie-rule-hanging-p)
551 ;; Treat purely syntactic block-constructs as being part of their parent, 551 ;; Treat purely syntactic block-constructs as being part of their parent,
552 ;; when the opening statement is hanging. 552 ;; when the opening token is hanging and the parent is not an open-paren.
553 (let ((state (smie-backward-sexp 'halfsexp))) 553 (let ((state (smie-backward-sexp 'halfsexp)))
554 (when (eq t (car state)) (goto-char (cadr state)))) 554 (unless (and (eq t (car state))
555 (cons 'column (smie-indent-virtual))))) 555 (not (eq (cadr state) (point-min))))
556 (cons 'column (smie-indent-virtual)))))))
557 (`(:after . ,(or `"(" "[" "{"))
558 ;; FIXME: Shouldn't this be the default behavior of
559 ;; `smie-indent-after-keyword'?
560 (save-excursion
561 (forward-char 1)
562 (skip-chars-forward " \t")
563 ;; `smie-rule-hanging-p' is not good enough here,
564 ;; because we want to accept hanging tokens at bol, too.
565 (unless (or (eolp) (forward-comment 1))
566 (cons 'column (current-column)))))
556 (`(:after . " @ ") (smie-rule-parent)) 567 (`(:after . " @ ") (smie-rule-parent))
557 (`(:before . "do") (ruby-smie--indent-to-stmt)) 568 (`(:before . "do") (ruby-smie--indent-to-stmt))
558 (`(,(or :before :after) . ".") 569 (`(,(or :before :after) . ".")
diff --git a/test/ChangeLog b/test/ChangeLog
index 6f75b33af95..ffa12498de4 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,7 @@
12013-12-14 Dmitry Gutov <dgutov@yandex.ru>
2
3 * indent/ruby.rb: New examples.
4
12013-12-12 Fabián Ezequiel Gallina <fgallina@gnu.org> 52013-12-12 Fabián Ezequiel Gallina <fgallina@gnu.org>
2 6
3 * automated/python-tests.el (python-indent-dedenters-2): New test. 7 * automated/python-tests.el (python-indent-dedenters-2): New test.
diff --git a/test/indent/ruby.rb b/test/indent/ruby.rb
index 3c4d68a97bf..7b85899577c 100644
--- a/test/indent/ruby.rb
+++ b/test/indent/ruby.rb
@@ -45,10 +45,41 @@ foo = { a: b,
45 a1: b1 45 a1: b1
46 } 46 }
47 47
48foo({ 48foo({ # bug#16118
49 a: b, 49 a: b,
50 c: d 50 c: d
51 }) 51 }
52 ) # bug#16116
53
54bar = foo(
55 a, [
56 1,
57 ],
58 :qux => [
59 3
60 ]
61 )
62
63foo(
64 [
65 {
66 a: b
67 },
68 ],
69 {
70 c: d
71 }
72)
73
74foo([{
75 a: 2
76 },
77 {
78 b: 3
79 },
80 4
81 ]
82 )
52 83
53foo = [ # ruby-deep-indent-disabled 84foo = [ # ruby-deep-indent-disabled
54 1 85 1