emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r114619: * lisp/progmodes/ruby-mode.el (ruby-smie--i


From: Dmitry Gutov
Subject: [Emacs-diffs] trunk r114619: * lisp/progmodes/ruby-mode.el (ruby-smie--implicit-semi-p): Split the
Date: Fri, 11 Oct 2013 02:11:43 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 114619
revision-id: address@hidden
parent: address@hidden
committer: Dmitry Gutov <address@hidden>
branch nick: trunk
timestamp: Fri 2013-10-11 05:11:37 +0300
message:
  * lisp/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.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/progmodes/ruby-mode.el    
rubymode.el-20091113204419-o5vbwnq5f7feedwu-8804
  test/indent/ruby.rb            ruby.rb-20120424165921-h044139hbrd7snvw-1
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-10-11 00:45:03 +0000
+++ b/lisp/ChangeLog    2013-10-11 02:11:37 +0000
@@ -1,5 +1,11 @@
 2013-10-11  Dmitry Gutov  <address@hidden>
 
+       * 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.

=== modified file 'lisp/progmodes/ruby-mode.el'
--- a/lisp/progmodes/ruby-mode.el       2013-10-09 03:18:01 +0000
+++ b/lisp/progmodes/ruby-mode.el       2013-10-11 02:11:37 +0000
@@ -292,10 +292,11 @@
                         '(?\; ?- ?+ ?* ?/ ?: ?. ?, ?\[ ?\( ?\{ ?\\))
                   ;; 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 @@
 (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 @@
      (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

=== modified file 'test/indent/ruby.rb'
--- a/test/indent/ruby.rb       2013-10-09 03:18:01 +0000
+++ b/test/indent/ruby.rb       2013-10-11 02:11:37 +0000
@@ -151,6 +151,10 @@
 foo if
   bar
 
+if foo?
+  bar
+end
+
 # Examples below still fail with `ruby-use-smie' on:
 
 foo +


reply via email to

[Prev in Thread] Current Thread [Next in Thread]