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:
parent
6f7a57c708
commit
066f3bc3f3
2 changed files with 10 additions and 2 deletions
|
@ -420,7 +420,10 @@ It is used when `ruby-encoding-magic-comment-style' is set to `custom'."
|
||||||
|
|
||||||
(defun ruby-smie--bosp ()
|
(defun ruby-smie--bosp ()
|
||||||
(save-excursion (skip-chars-backward " \t")
|
(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 ()
|
(defun ruby-smie--implicit-semi-p ()
|
||||||
(save-excursion
|
(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
|
;; Align to the previous `when', but look up the virtual
|
||||||
;; indentation of `case'.
|
;; indentation of `case'.
|
||||||
(if (smie-rule-sibling-p) 0 (smie-rule-parent)))
|
(if (smie-rule-sibling-p) 0 (smie-rule-parent)))
|
||||||
(`(:after . ,(or "=" "iuwu-mod" "+" "-" "*" "/" "&&" "||" "%" "**" "^" "&"
|
(`(:after . ,(or "=" "+" "-" "*" "/" "&&" "||" "%" "**" "^" "&"
|
||||||
"<=>" ">" "<" ">=" "<=" "==" "===" "!=" "<<" ">>"
|
"<=>" ">" "<" ">=" "<=" "==" "===" "!=" "<<" ">>"
|
||||||
"+=" "-=" "*=" "/=" "%=" "**=" "&=" "|=" "^=" "|"
|
"+=" "-=" "*=" "/=" "%=" "**=" "&=" "|=" "^=" "|"
|
||||||
"<<=" ">>=" "&&=" "||=" "and" "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)
|
(if (ruby-smie--indent-to-stmt-p token)
|
||||||
(ruby-smie--indent-to-stmt)
|
(ruby-smie--indent-to-stmt)
|
||||||
(cons 'column (current-column)))))
|
(cons 'column (current-column)))))
|
||||||
|
(`(:before . "iuwu-mod")
|
||||||
|
(smie-rule-parent ruby-indent-level))
|
||||||
))
|
))
|
||||||
|
|
||||||
(defun ruby--at-indentation-p (&optional point)
|
(defun ruby--at-indentation-p (&optional point)
|
||||||
|
|
|
@ -223,6 +223,9 @@ def foo
|
||||||
foo if
|
foo if
|
||||||
bar
|
bar
|
||||||
|
|
||||||
|
fail "stuff" \
|
||||||
|
unless all_fine?
|
||||||
|
|
||||||
if foo?
|
if foo?
|
||||||
bar
|
bar
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue