]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/progmodes/ruby-mode.el (ruby-smie--implicit-semi-p): Split the
authorDmitry Gutov <dgutov@yandex.ru>
Fri, 11 Oct 2013 02:11:37 +0000 (05:11 +0300)
committerDmitry Gutov <dgutov@yandex.ru>
Fri, 11 Oct 2013 02:11:37 +0000 (05:11 +0300)
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.

lisp/ChangeLog
lisp/progmodes/ruby-mode.el
test/indent/ruby.rb

index 362447e651c084be266c17e74c16cb6f4c2c17bc..1c1a5701602ef1556c67318866dd6fecfa7af263 100644 (file)
@@ -1,5 +1,11 @@
 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.
index f734dc50e47db80a6e8348ec3a746befe6058352..2f9221625862d22db5fccf6d47fe8efe4607c3dd 100644 (file)
@@ -292,10 +292,11 @@ Also ignores spaces after parenthesis when 'space."
                         '(?\; ?- ?+ ?* ?/ ?: ?. ?, ?\[ ?\( ?\{ ?\\))
                   ;; 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"))
@@ -306,7 +307,7 @@ Also ignores spaces after parenthesis when 'space."
 (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
@@ -423,19 +424,7 @@ Also ignores spaces after parenthesis when 'space."
      (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
index 48275ee3e31299f02a0fdd982e79721729609a7e..b280ec93ce2d6fb623149d8cef153ac7095c5f02 100644 (file)
@@ -151,6 +151,10 @@ z = {
 foo if
   bar
 
+if foo?
+  bar
+end
+
 # Examples below still fail with `ruby-use-smie' on:
 
 foo +