+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'
(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)
((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.
(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)))