[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r110892: * lisp/progmodes/ruby-mode.e
From: |
Dmitry Gutov |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r110892: * lisp/progmodes/ruby-mode.el (ruby-expr-beg): Make heredoc detection |
Date: |
Wed, 14 Nov 2012 10:34:17 +0400 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 110892
committer: Dmitry Gutov <address@hidden>
branch nick: trunk
timestamp: Wed 2012-11-14 10:34:17 +0400
message:
* lisp/progmodes/ruby-mode.el (ruby-expr-beg): Make heredoc detection
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.
modified:
lisp/ChangeLog
lisp/progmodes/ruby-mode.el
test/ChangeLog
test/automated/ruby-mode-tests.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2012-11-14 01:12:52 +0000
+++ b/lisp/ChangeLog 2012-11-14 06:34:17 +0000
@@ -1,3 +1,8 @@
+2012-11-14 Dmitry Gutov <address@hidden>
+
+ * progmodes/ruby-mode.el (ruby-expr-beg): Make heredoc detection
+ more strict. Add docstring.
+
2012-11-14 Stefan Monnier <address@hidden>
* emacs-lisp/gv.el (setf): Fix debug spec for multiple assignments
=== modified file 'lisp/progmodes/ruby-mode.el'
--- a/lisp/progmodes/ruby-mode.el 2012-11-14 05:07:33 +0000
+++ b/lisp/progmodes/ruby-mode.el 2012-11-14 06:34:17 +0000
@@ -384,7 +384,9 @@
(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 @@
(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)
=== modified file 'test/ChangeLog'
--- a/test/ChangeLog 2012-11-13 18:57:26 +0000
+++ b/test/ChangeLog 2012-11-14 06:34:17 +0000
@@ -1,3 +1,9 @@
+2012-11-14 Dmitry Gutov <address@hidden>
+
+ * 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 <address@hidden>
* automated/ruby-mode-tests.el (ruby-heredoc-font-lock)
=== modified file 'test/automated/ruby-mode-tests.el'
--- a/test/automated/ruby-mode-tests.el 2012-11-13 18:57:26 +0000
+++ b/test/automated/ruby-mode-tests.el 2012-11-14 06:34:17 +0000
@@ -154,7 +154,6 @@
|"))
(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 @@
| 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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r110892: * lisp/progmodes/ruby-mode.el (ruby-expr-beg): Make heredoc detection,
Dmitry Gutov <=