[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] trunk r113265: * lisp/progmodes/ruby-mode.el (ruby-move-to
From: |
Dmitry Gutov |
Subject: |
[Emacs-diffs] trunk r113265: * lisp/progmodes/ruby-mode.el (ruby-move-to-block): When we're at a |
Date: |
Wed, 03 Jul 2013 01:02:16 +0000 |
User-agent: |
Bazaar (2.6b2) |
------------------------------------------------------------
revno: 113265
revision-id: address@hidden
parent: address@hidden
committer: Dmitry Gutov <address@hidden>
branch nick: trunk
timestamp: Wed 2013-07-03 05:02:18 +0400
message:
* 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.
modified:
lisp/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1432
lisp/progmodes/ruby-mode.el
rubymode.el-20091113204419-o5vbwnq5f7feedwu-8804
test/automated/ruby-mode-tests.el
rubymodetests.el-20120720101201-mn39s4kfopdxj3ek-1
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2013-07-02 18:16:09 +0000
+++ b/lisp/ChangeLog 2013-07-03 01:02:18 +0000
@@ -1,3 +1,11 @@
+2013-07-03 Dmitry Gutov <address@hidden>
+
+ * 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 <address@hidden>
* term/ns-win.el (display-format-alist): Use .* (Bug#14765).
=== modified file 'lisp/progmodes/ruby-mode.el'
--- a/lisp/progmodes/ruby-mode.el 2013-06-30 02:23:10 +0000
+++ b/lisp/progmodes/ruby-mode.el 2013-07-03 01:02:18 +0000
@@ -990,13 +990,14 @@
(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 @@
(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)
=== modified file 'test/automated/ruby-mode-tests.el'
--- a/test/automated/ruby-mode-tests.el 2013-06-30 02:23:10 +0000
+++ b/test/automated/ruby-mode-tests.el 2013-07-03 01:02:18 +0000
@@ -546,6 +546,17 @@
(ruby-beginning-of-block))
(should (= 1 (line-number-at-pos)))))
+(ert-deftest ruby-move-to-block-moves-from-else-to-if ()
+ (ruby-with-temp-buffer (ruby-test-string
+ "if true
+ | nested_block do
+ | end
+ |else
+ |end")
+ (goto-line 4)
+ (ruby-beginning-of-block)
+ (should (= 1 (line-number-at-pos)))))
+
(ert-deftest ruby-beginning-of-defun-does-not-fold-case ()
(ruby-with-temp-buffer
(ruby-test-string
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] trunk r113265: * lisp/progmodes/ruby-mode.el (ruby-move-to-block): When we're at a,
Dmitry Gutov <=