From 066f3bc3f3d024b2e10ee11e09ae6aaa1003bbda Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Sun, 6 Mar 2016 23:18:06 +0200 Subject: [PATCH] Recognize iuwu-mod after an escaped newline * lisp/progmodes/ruby-mode.el (ruby-smie--bosp): Check if the newline is escaped. (ruby-smie-rules): Indent iuwu-mod after an escaped newline correctly. --- lisp/progmodes/ruby-mode.el | 9 +++++++-- test/indent/ruby.rb | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index cebc1dc9823..fa94992ab79 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -420,7 +420,10 @@ It is used when `ruby-encoding-magic-comment-style' is set to `custom'." (defun ruby-smie--bosp () (save-excursion (skip-chars-backward " \t") - (or (bolp) (memq (char-before) '(?\; ?=))))) + (or (and (bolp) + ;; Newline is escaped. + (not (eq (char-before (1- (point))) ?\\))) + (memq (char-before) '(?\; ?=))))) (defun ruby-smie--implicit-semi-p () (save-excursion @@ -669,7 +672,7 @@ It is used when `ruby-encoding-magic-comment-style' is set to `custom'." ;; Align to the previous `when', but look up the virtual ;; indentation of `case'. (if (smie-rule-sibling-p) 0 (smie-rule-parent))) - (`(:after . ,(or "=" "iuwu-mod" "+" "-" "*" "/" "&&" "||" "%" "**" "^" "&" + (`(:after . ,(or "=" "+" "-" "*" "/" "&&" "||" "%" "**" "^" "&" "<=>" ">" "<" ">=" "<=" "==" "===" "!=" "<<" ">>" "+=" "-=" "*=" "/=" "%=" "**=" "&=" "|=" "^=" "|" "<<=" ">>=" "&&=" "||=" "and" "or")) @@ -682,6 +685,8 @@ It is used when `ruby-encoding-magic-comment-style' is set to `custom'." (if (ruby-smie--indent-to-stmt-p token) (ruby-smie--indent-to-stmt) (cons 'column (current-column))))) + (`(:before . "iuwu-mod") + (smie-rule-parent ruby-indent-level)) )) (defun ruby--at-indentation-p (&optional point) diff --git a/test/indent/ruby.rb b/test/indent/ruby.rb index dfd1c75a679..49478602e41 100644 --- a/test/indent/ruby.rb +++ b/test/indent/ruby.rb @@ -223,6 +223,9 @@ z = { foo if bar +fail "stuff" \ + unless all_fine? + if foo? bar end -- 2.11.4.GIT