From 8619323f695c733f67dad59987ca5adc3cc0a6e8 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Wed, 14 Nov 2012 10:34:17 +0400 Subject: [PATCH] * 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. --- lisp/ChangeLog | 5 +++++ lisp/progmodes/ruby-mode.el | 12 +++++++----- test/ChangeLog | 6 ++++++ test/automated/ruby-mode-tests.el | 15 ++++++++++++++- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 48eced16fe1..19623bd06b7 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2012-11-14 Dmitry Gutov + + * progmodes/ruby-mode.el (ruby-expr-beg): Make heredoc detection + more strict. Add docstring. + 2012-11-14 Stefan Monnier * emacs-lisp/gv.el (setf): Fix debug spec for multiple assignments diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index 0bc41033367..686bec89a95 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -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) diff --git a/test/ChangeLog b/test/ChangeLog index 8973a0f1d4f..5a796408a3b 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,9 @@ +2012-11-14 Dmitry Gutov + + * 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 * automated/ruby-mode-tests.el (ruby-heredoc-font-lock) diff --git a/test/automated/ruby-mode-tests.el b/test/automated/ruby-mode-tests.el index a8cdd2f3f28..7d633be0f53 100644 --- a/test/automated/ruby-mode-tests.el +++ b/test/automated/ruby-mode-tests.el @@ -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<