1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-07 15:21:46 +00:00

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.
This commit is contained in:
Dmitry Gutov 2016-03-06 23:18:06 +02:00
parent 6f7a57c708
commit 066f3bc3f3
2 changed files with 10 additions and 2 deletions

View File

@ -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)

View File

@ -223,6 +223,9 @@ def foo
foo if
bar
fail "stuff" \
unless all_fine?
if foo?
bar
end