* 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.
This commit is contained in:
parent
9bd3668269
commit
3086ca2e2c
3 changed files with 28 additions and 14 deletions
|
@ -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).
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -546,6 +546,17 @@ VALUES-PLIST is a list with alternating index and value elements."
|
|||
(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
|
||||
|
|
Loading…
Add table
Reference in a new issue