summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorDmitry Gutov <dgutov@yandex.ru>2013-07-03 05:02:18 +0400
committerDmitry Gutov <dgutov@yandex.ru>2013-07-03 05:02:18 +0400
commit3086ca2e2cf739cc7fd667b16c676522aecf4112 (patch)
treee49bfa18fae35f17ed64096e8d9d2c02e5e84de5 /lisp
parent9bd3668269180bb28ee33ded00010ab1f5ae6dd6 (diff)
downloademacs-3086ca2e2cf739cc7fd667b16c676522aecf4112.tar.gz
emacs-3086ca2e2cf739cc7fd667b16c676522aecf4112.tar.bz2
emacs-3086ca2e2cf739cc7fd667b16c676522aecf4112.zip
* lisp/progmodes/ruby-mode.el (ruby-move-to-block): When we're at a
middle of block statement initially, lower the depth. Remove FIXME comment, not longer valid. Remove middle of block statement detection, no need to do that anymore since we've been using `ruby-parse-region' here.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/progmodes/ruby-mode.el23
2 files changed, 17 insertions, 14 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 86a27f9b5bd..9a5af5e31d2 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
+2013-07-03 Dmitry Gutov <dgutov@yandex.ru>
+
+ * progmodes/ruby-mode.el (ruby-move-to-block): When we're at a
+ middle of block statement initially, lower the depth. Remove
+ FIXME comment, not longer valid. Remove middle of block statement
+ detection, no need to do that anymore since we've been using
+ `ruby-parse-region' here.
+
2013-07-02 Jan Djärv <jan.h.d@swipnet.se>
* term/ns-win.el (display-format-alist): Use .* (Bug#14765).
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index 0292e40b986..f5f829ce0e8 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -990,13 +990,14 @@ calculating indentation on the lines after it."
(defun ruby-move-to-block (n)
"Move to the beginning (N < 0) or the end (N > 0) of the
current block, a sibling block, or an outer block. Do that (abs N) times."
+ (back-to-indentation)
(let ((signum (if (> n 0) 1 -1))
(backward (< n 0))
- (depth (or (nth 2 (ruby-parse-region (line-beginning-position)
- (line-end-position)))
- 0))
+ (depth (or (nth 2 (ruby-parse-region (point) (line-end-position))) 0))
case-fold-search
down done)
+ (when (looking-at ruby-block-mid-re)
+ (setq depth (+ depth signum)))
(when (< (* depth signum) 0)
;; Moving end -> end or beginning -> beginning.
(setq depth 0))
@@ -1033,22 +1034,16 @@ current block, a sibling block, or an outer block. Do that (abs N) times."
(unless (car state) ; Line ends with unfinished string.
(setq depth (+ (nth 2 state) depth))))
(cond
- ;; Deeper indentation, we found a block.
- ;; FIXME: We can't recognize empty blocks this way.
+ ;; Increased depth, we found a block.
((> (* signum depth) 0)
(setq down t))
- ;; Block found, and same indentation as when started, stop.
+ ;; We're at the same depth as when we started, and we've
+ ;; encountered a block before. Stop.
((and down (zerop depth))
(setq done t))
- ;; Shallower indentation, means outer block, can stop now.
+ ;; Lower depth, means outer block, can stop now.
((< (* signum depth) 0)
- (setq done t)))))
- (if done
- (save-excursion
- (back-to-indentation)
- ;; Not really at the first or last line of the block, move on.
- (if (looking-at (concat "\\<\\(" ruby-block-mid-re "\\)\\>"))
- (setq done nil))))))
+ (setq done t)))))))
(back-to-indentation)))
(defun ruby-beginning-of-block (&optional arg)