]> code.delx.au - gnu-emacs/commitdiff
* lisp/progmodes/ruby-mode.el (ruby-expr-beg): Make heredoc detection
authorDmitry Gutov <dgutov@yandex.ru>
Wed, 14 Nov 2012 06:34:17 +0000 (10:34 +0400)
committerDmitry Gutov <dgutov@yandex.ru>
Wed, 14 Nov 2012 06:34:17 +0000 (10:34 +0400)
more strict.  Add docstring.

* test/automated/ruby-mode-tests.el (ruby-indent-singleton-class): Pass.
(ruby-indent-inside-heredoc-after-operator)
(ruby-indent-inside-heredoc-after-space): New tests.

lisp/ChangeLog
lisp/progmodes/ruby-mode.el
test/ChangeLog
test/automated/ruby-mode-tests.el

index 48eced16fe1f374d709b0e60e5a06a5604c3d131..19623bd06b7ecc013762483f9d885eddb01531f7 100644 (file)
@@ -1,3 +1,8 @@
+2012-11-14  Dmitry Gutov  <dgutov@yandex.ru>
+
+       * progmodes/ruby-mode.el (ruby-expr-beg): Make heredoc detection
+       more strict.  Add docstring.
+
 2012-11-14  Stefan Monnier  <monnier@iro.umontreal.ca>
 
        * emacs-lisp/gv.el (setf): Fix debug spec for multiple assignments
index 0bc41033367434e447ecabd5df86f8c10190f336..686bec89a950934c747ad61b20cae56b8e232fe6 100644 (file)
@@ -384,7 +384,9 @@ and `\\' when preceded by `?'."
          (looking-at "class\\s *<<"))))
 
 (defun ruby-expr-beg (&optional option)
-  "TODO: document."
+  "Check if point is possibly at the beginning of an expression.
+OPTION specifies the type of the expression.
+Can be one of `heredoc', `modifier', `expr-qstr', `expr-re'."
   (save-excursion
     (store-match-data nil)
     (let ((space (skip-chars-backward " \t"))
@@ -397,10 +399,10 @@ and `\\' when preceded by `?'."
                (or (eq (char-syntax (char-before (point))) ?w)
                    (ruby-special-char-p))))
         nil)
-       ((and (eq option 'heredoc) (< space 0))
-        (not (progn (goto-char start) (ruby-singleton-class-p))))
-       ((or (looking-at ruby-operator-re)
-            (looking-at "[\\[({,;]")
+       ((looking-at ruby-operator-re))
+       ((eq option 'heredoc)
+        (and (< space 0) (not (ruby-singleton-class-p start))))
+       ((or (looking-at "[\\[({,;]")
             (and (looking-at "[!?]")
                  (or (not (eq option 'modifier))
                      (bolp)
index 8973a0f1d4fba467f590b8fb4697c1e462bab287..5a796408a3b8cb33b052d24bb79ff061e81baeb9 100644 (file)
@@ -1,3 +1,9 @@
+2012-11-14  Dmitry Gutov  <dgutov@yandex.ru>
+
+       * automated/ruby-mode-tests.el (ruby-indent-singleton-class): Pass.
+       (ruby-indent-inside-heredoc-after-operator)
+       (ruby-indent-inside-heredoc-after-space): New tests.
+
 2012-11-13  Dmitry Gutov  <dgutov@yandex.ru>
 
        * automated/ruby-mode-tests.el (ruby-heredoc-font-lock)
index a8cdd2f3f28e4c733570681a93cd97415a3b2ef4..7d633be0f53afa3c5d4a5096ab0b407e04f6427f 100644 (file)
@@ -154,7 +154,6 @@ VALUES-PLIST is a list with alternating index and value elements."
    |"))
 
 (ert-deftest ruby-indent-singleton-class ()
-  :expected-result :failed   ; Doesn't work yet, when no space before "<<".
   (ruby-should-indent-buffer
    "class<<bar
    |  foo
@@ -165,6 +164,20 @@ VALUES-PLIST is a list with alternating index and value elements."
    |   end
    |"))
 
+(ert-deftest ruby-indent-inside-heredoc-after-operator ()
+  (ruby-should-indent-buffer
+   "b=<<eos
+   |     42"
+   "b=<<eos
+   |     42"))
+
+(ert-deftest ruby-indent-inside-heredoc-after-space ()
+  (ruby-should-indent-buffer
+   "foo <<eos.gsub(' ', '*')
+   |     42"
+   "foo <<eos.gsub(' ', '*')
+   |     42"))
+
 (ert-deftest ruby-indent-array-literal ()
   (let ((ruby-deep-indent-paren nil))
     (ruby-should-indent-buffer