From ce41edb426ccd6acc1c653d8a9a28aded9e9d594 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Thu, 19 Dec 2013 07:06:24 +0200 Subject: [PATCH] * lisp/progmodes/ruby-mode.el (ruby-smie-rules): Indent middle-of-block keywords to their parent. --- lisp/ChangeLog | 5 +++++ lisp/progmodes/ruby-mode.el | 5 +++-- test/indent/ruby.rb | 4 ++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 09d4cebb6f..5fd4ff56c6 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2013-12-19 Dmitry Gutov + + * progmodes/ruby-mode.el (ruby-smie-rules): Indent middle-of-block + keywords to their parent. + 2013-12-19 Dmitry Gutov * progmodes/ruby-mode.el (ruby-smie--args-separator-p): Allow the diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index e291acec32..449a10dc99 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -569,8 +569,9 @@ It is used when `ruby-encoding-magic-comment-style' is set to `custom'." (cons 'column (current-column))))) (`(:before . "do") (ruby-smie--indent-to-stmt)) (`(:before . ".") ruby-indent-level) - (`(:before . ,(or `"else" `"then" `"elsif" `"rescue" `"ensure")) 0) - (`(:before . ,(or `"when")) + (`(:before . ,(or `"else" `"then" `"elsif" `"rescue" `"ensure")) + (smie-rule-parent)) + (`(:before . "when") (if (not (smie-rule-sibling-p)) 0)) ;; ruby-indent-level (`(:after . ,(or "=" "iuwu-mod" "+" "-" "*" "/" "&&" "||" "%" "**" "^" "&" "<=>" ">" "<" ">=" "<=" "==" "===" "!=" "<<" ">>" diff --git a/test/indent/ruby.rb b/test/indent/ruby.rb index 0bf4bc14fb..1993c29efb 100644 --- a/test/indent/ruby.rb +++ b/test/indent/ruby.rb @@ -272,6 +272,8 @@ end # http://stackoverflow.com/questions/17786563/emacs-ruby-mode-if-expressions-indentation tee = if foo bar + else + tee end a = b { @@ -328,6 +330,8 @@ def qux foo ||= begin bar tee + rescue + oomph end end -- 2.20.1