From: Stefan Monnier Date: Wed, 23 Oct 2013 17:55:53 +0000 (-0400) Subject: * lisp/progmodes/ruby-mode.el (ruby-smie-rules): Only align with parent of X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~1171 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=03d44565bbbea492e5280e153150a768ca7f2c45;p=emacs.git * lisp/progmodes/ruby-mode.el (ruby-smie-rules): Only align with parent of { if it is hanging. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 63156bb18a1..6210bbeabae 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2013-10-23 Stefan Monnier + * progmodes/ruby-mode.el (ruby-smie-rules): Only align with parent of + { if it is hanging. + * progmodes/ruby-mode.el (ruby-smie-rules): Don't return 0 for :before ";". diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index 7b9dcd44b24..88820a4a942 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -449,7 +449,7 @@ explicitly declared in magic comment." ((smie-rule-parent-p "def" "begin" "do" "class" "module" "for" "while" "until" "unless" "if" "then" "elsif" "else" "when" - "rescue" "ensure" "{") + "rescue" "ensure") (smie-rule-parent ruby-indent-level)) ;; For (invalid) code between switch and case. ;; (if (smie-parent-p "switch") 4) @@ -457,7 +457,9 @@ explicitly declared in magic comment." (`(:before . ,(or `"(" `"[" `"{")) (cond ((and (equal token "{") - (not (smie-rule-prev-p "(" "{" "[" "," "=>"))) + (not (smie-rule-prev-p "(" "{" "[" "," "=>")) + (or (smie-rule-hanging-p) + (smie-rule-next-p "opening-|"))) ;; Curly block opener. (smie-rule-parent)) ((smie-rule-hanging-p) diff --git a/test/indent/ruby.rb b/test/indent/ruby.rb index 7ce60f5f58b..7601738dc76 100644 --- a/test/indent/ruby.rb +++ b/test/indent/ruby.rb @@ -40,6 +40,10 @@ foo = { # ruby-deep-indent-disabled a: b } +foo = { a: b + a1: b1 + } + foo({ a: b, c: d