2013-10-11 Dmitry Gutov <dgutov@yandex.ru>
+ * progmodes/ruby-mode.el (ruby-smie--implicit-semi-p): Split the
+ cases of ? and =.
+ (ruby-smie-rules): Simplify the "do" rule. The cases when the
+ predicate would return nil are almost non-existent.
+ (ruby-smie--redundant-do-p): Include "until" and "for" statements.
+
* emacs-lisp/smie.el (smie--matching-block-data): Invalidate the
cache also after commands that modify the buffer but don't move
point.
'(?\; ?- ?+ ?* ?/ ?: ?. ?, ?\[ ?\( ?\{ ?\\))
;; Make sure it's not the end of a regexp.
(not (eq (car (syntax-after (1- (point)))) 7)))
- (and (memq (char-before) '(?\? ?=))
- (let ((tok (save-excursion (ruby-smie--backward-token))))
- (or (equal tok "?")
- (string-match "\\`\\s." tok))))
+ (and (eq (char-before) ?\?)
+ (equal (save-excursion (ruby-smie--backward-token)) "?"))
+ (and (eq (char-before) ?=)
+ (string-match "\\`\\s." (save-excursion
+ (ruby-smie--backward-token))))
(and (eq (car (syntax-after (1- (point)))) 2)
(equal (save-excursion (ruby-smie--backward-token))
"iuwu-mod"))
(defun ruby-smie--redundant-do-p (&optional skip)
(save-excursion
(if skip (backward-word 1))
- (member (nth 2 (smie-backward-sexp ";")) '("while"))))
+ (member (nth 2 (smie-backward-sexp ";")) '("while" "until" "for"))))
(defun ruby-smie--opening-pipe-p ()
(save-excursion
(when (smie-rule-hanging-p)
(smie-backward-sexp 'halfsexp) (smie-indent-virtual)))
(`(:after . ,(or "=" "iuwu-mod")) 2)
- (`(:before . "do")
- (when (or (smie-rule-hanging-p)
- (save-excursion
- (forward-word 1) ;Skip "do"
- (skip-chars-forward " \t")
- (and (equal (save-excursion (ruby-smie--forward-token))
- "opening-|")
- (save-excursion (forward-sexp 1)
- (skip-chars-forward " \t")
- (or (eolp)
- (looking-at comment-start-skip))))))
- ;; `(column . ,(smie-indent-virtual))
- (smie-rule-parent)))
+ (`(:before . "do") (smie-rule-parent))
(`(:before . ,(or `"else" `"then" `"elsif" `"rescue" `"ensure")) 0)
(`(:before . ,(or `"when"))
(if (not (smie-rule-sibling-p)) 0)) ;; ruby-indent-level