Commit 3d42b968 authored by Dmitry Gutov's avatar Dmitry Gutov

* lisp/progmodes/ruby-mode.el (ruby-smie--rule-parent-skip-assign): New

function, replacement for `smie-rule-parent' for when we want to
skip over our direct parent if it's an assignment token..
(ruby-smie-rules): Use it.
parent a90e5a33
2013-11-02 Dmitry Gutov <dgutov@yandex.ru>
* progmodes/ruby-mode.el (ruby-smie--rule-parent-skip-assign): New
function, replacement for `smie-rule-parent' for when we want to
skip over our direct parent if it's an assignment token..
(ruby-smie-rules): Use it.
2013-11-02 Dmitry Gutov <dgutov@yandex.ru>
* progmodes/ruby-mode.el Use `syntax-propertize-function'
......
......@@ -467,6 +467,16 @@ explicitly declared in magic comment."
(t ";")))
(t tok)))))))
(defun ruby-smie--rule-parent-skip-assign ()
(let* ((parent (smie-indent--parent))
(tok (caddr parent)))
(if (and (stringp tok) (string-match-p "[+-*&|^]?=\\'" tok))
(progn
(goto-char (cadr parent))
(let (smie--parent)
(smie-rule-parent)))
(smie-rule-parent))))
(defun ruby-smie-rules (kind token)
(pcase (cons kind token)
(`(:elem . basic) ruby-indent-level)
......@@ -489,7 +499,7 @@ explicitly declared in magic comment."
((and (equal token "{")
(not (smie-rule-prev-p "(" "{" "[" "," "=>" "=" "return" ";")))
;; Curly block opener.
(smie-rule-parent))
(ruby-smie--rule-parent-skip-assign))
((smie-rule-hanging-p)
;; Treat purely syntactic block-constructs as being part of their parent,
;; when the opening statement is hanging.
......@@ -498,7 +508,7 @@ explicitly declared in magic comment."
(cons 'column (smie-indent-virtual)))))
(`(:after . ,(or "=" "iuwu-mod")) 2)
(`(:after . " @ ") (smie-rule-parent))
(`(:before . "do") (smie-rule-parent))
(`(:before . "do") (ruby-smie--rule-parent-skip-assign))
(`(,(or :before :after) . ".")
(unless (smie-rule-parent-p ".")
(smie-rule-parent ruby-indent-level)))
......
......@@ -225,6 +225,14 @@ def bar
bar
end
a = b {
c
}
aa = bb do
cc
end
# Examples below still fail with `ruby-use-smie' on:
foo = [1, 2, 3].map do |i|
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment