diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index 1f3e9b6ae7b..ecd88527aeb 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -608,10 +608,10 @@ ruby-smie--backward-token "def=") (t tok))))))) -(defun ruby-smie--indent-to-stmt () +(defun ruby-smie--indent-to-stmt (&optional offset) (save-excursion (smie-backward-sexp ";") - (cons 'column (smie-indent-virtual)))) + (cons 'column (+ (smie-indent-virtual) (or offset 0))))) (defun ruby-smie--indent-to-stmt-p (keyword) (or (eq t ruby-align-to-stmt-keywords) @@ -696,7 +696,7 @@ ruby-smie-rules (not (smie-rule-bolp))))) (cons 'column (current-column))) (smie-backward-sexp ".") - (cons 'column (+ (current-column) + (cons 'column (+ (smie-indent-virtual) ruby-indent-level)))) (`(:before . ,(or "else" "then" "elsif" "rescue" "ensure")) (smie-rule-parent)) @@ -708,9 +708,10 @@ ruby-smie-rules "<=>" ">" "<" ">=" "<=" "==" "===" "!=" "<<" ">>" "+=" "-=" "*=" "/=" "%=" "**=" "&=" "|=" "^=" "|" "<<=" ">>=" "&&=" "||=" "and" "or")) - (and (smie-rule-parent-p ";" nil) - (smie-indent--hanging-p) - ruby-indent-level)) + (if (and (smie-rule-parent-p ";" nil) + (smie-indent--hanging-p)) + ruby-indent-level + (ruby-smie--indent-to-stmt ruby-indent-level))) (`(:before . "=") (save-excursion (and (smie-rule-parent-p " @ ") @@ -725,6 +726,8 @@ ruby-smie-rules (cons 'column (current-column))))) ('(:before . "iuwu-mod") (smie-rule-parent ruby-indent-level)) + ('(:after . _) + (ruby-smie--indent-to-stmt ruby-indent-level)) )) (defun ruby--at-indentation-p (&optional point)