* lisp/progmodes/ruby-mode.el (ruby-parse-partial): Don't increase
depth for unfinished percent literal. Not using it in the caller. (ruby-move-to-block): Jump over multiline literals of all types, ignoring code-looking contents inside them. * test/automated/ruby-mode-tests.el (ruby-move-to-block-skips-percent-literal): Add depth-affecting bits inside the examples. (ruby-move-to-block-skips-heredoc): New test.
This commit is contained in:
parent
6b26f14f78
commit
53ca88c478
4 changed files with 41 additions and 10 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2013-02-14 Dmitry Gutov <dgutov@yandex.ru>
|
||||||
|
|
||||||
|
* progmodes/ruby-mode.el (ruby-parse-partial): Don't increase
|
||||||
|
depth for unfinished percent literal. Not using it in the caller.
|
||||||
|
(ruby-move-to-block): Jump over multiline literals of all types,
|
||||||
|
ignoring code-looking contents inside them.
|
||||||
|
|
||||||
2013-02-13 Michael Albinus <michael.albinus@gmx.de>
|
2013-02-13 Michael Albinus <michael.albinus@gmx.de>
|
||||||
|
|
||||||
Use ControlMaster where applicable. (Bug#13677)
|
Use ControlMaster where applicable. (Bug#13677)
|
||||||
|
|
|
@ -519,12 +519,6 @@ Can be one of `heredoc', `modifier', `expr-qstr', `expr-re'."
|
||||||
(concat "[^\\]\\(\\\\\\\\\\)*" w))
|
(concat "[^\\]\\(\\\\\\\\\\)*" w))
|
||||||
end t)))
|
end t)))
|
||||||
(setq in-string (point))
|
(setq in-string (point))
|
||||||
(when (eq (char-syntax (string-to-char w)) ?\()
|
|
||||||
;; The rest of the literal, when parsed separately, will
|
|
||||||
;; have the depth of -1. So in the rare case when this
|
|
||||||
;; number is used despite the in-string status, the
|
|
||||||
;; depths will balance.
|
|
||||||
(setq depth (1+ depth)))
|
|
||||||
(goto-char end)))
|
(goto-char end)))
|
||||||
(t
|
(t
|
||||||
(goto-char pnt))))
|
(goto-char pnt))))
|
||||||
|
@ -913,10 +907,16 @@ current block, a sibling block, or an outer block. Do that (abs N) times."
|
||||||
(re-search-forward "^=end\\>"))
|
(re-search-forward "^=end\\>"))
|
||||||
((and backward (looking-at "^=end\\>"))
|
((and backward (looking-at "^=end\\>"))
|
||||||
(re-search-backward "^=begin\\>"))
|
(re-search-backward "^=begin\\>"))
|
||||||
|
;; Jump over a multiline literal.
|
||||||
|
((ruby-in-ppss-context-p 'string)
|
||||||
|
(goto-char (nth 8 (syntax-ppss)))
|
||||||
|
(unless backward
|
||||||
|
(forward-sexp)
|
||||||
|
(when (bolp) (forward-char -1)))) ; After a heredoc.
|
||||||
(t
|
(t
|
||||||
(incf depth (or (nth 2 (ruby-parse-region (point)
|
(let ((state (ruby-parse-region (point) (line-end-position))))
|
||||||
(line-end-position)))
|
(unless (car state) ; Line ends with unfinished string.
|
||||||
0))
|
(setq depth (+ (nth 2 state) depth))))
|
||||||
(cond
|
(cond
|
||||||
;; Deeper indentation, we found a block.
|
;; Deeper indentation, we found a block.
|
||||||
;; FIXME: We can't recognize empty blocks this way.
|
;; FIXME: We can't recognize empty blocks this way.
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
2013-02-14 Dmitry Gutov <dgutov@yandex.ru>
|
||||||
|
|
||||||
|
* automated/ruby-mode-tests.el
|
||||||
|
(ruby-move-to-block-skips-percent-literal): Add depth-affecting
|
||||||
|
bits inside the examples.
|
||||||
|
(ruby-move-to-block-skips-heredoc): New test.
|
||||||
|
|
||||||
2013-02-13 Dmitry Gutov <dgutov@yandex.ru>
|
2013-02-13 Dmitry Gutov <dgutov@yandex.ru>
|
||||||
|
|
||||||
* automated/ruby-mode-tests.el
|
* automated/ruby-mode-tests.el
|
||||||
|
|
|
@ -449,20 +449,37 @@ VALUES-PLIST is a list with alternating index and value elements."
|
||||||
(dolist (s (list (ruby-test-string
|
(dolist (s (list (ruby-test-string
|
||||||
"foo do
|
"foo do
|
||||||
| a = %%w(
|
| a = %%w(
|
||||||
|
| def yaa
|
||||||
| )
|
| )
|
||||||
|end")
|
|end")
|
||||||
(ruby-test-string
|
(ruby-test-string
|
||||||
"foo do
|
"foo do
|
||||||
| a = %%w|
|
| a = %%w|
|
||||||
|
| end
|
||||||
| |
|
| |
|
||||||
|end")))
|
|end")))
|
||||||
(ruby-with-temp-buffer s
|
(ruby-with-temp-buffer s
|
||||||
(goto-line 1)
|
(goto-line 1)
|
||||||
(ruby-end-of-block)
|
(ruby-end-of-block)
|
||||||
(should (= 4 (line-number-at-pos)))
|
(should (= 5 (line-number-at-pos)))
|
||||||
(ruby-beginning-of-block)
|
(ruby-beginning-of-block)
|
||||||
(should (= 1 (line-number-at-pos))))))
|
(should (= 1 (line-number-at-pos))))))
|
||||||
|
|
||||||
|
(ert-deftest ruby-move-to-block-skips-heredoc ()
|
||||||
|
(ruby-with-temp-buffer
|
||||||
|
(ruby-test-string
|
||||||
|
"if something_wrong?
|
||||||
|
| ActiveSupport::Deprecation.warn(<<-eowarn)
|
||||||
|
| boo hoo
|
||||||
|
| end
|
||||||
|
| eowarn
|
||||||
|
|end")
|
||||||
|
(goto-line 1)
|
||||||
|
(ruby-end-of-block)
|
||||||
|
(should (= 6 (line-number-at-pos)))
|
||||||
|
(ruby-beginning-of-block)
|
||||||
|
(should (= 1 (line-number-at-pos)))))
|
||||||
|
|
||||||
(provide 'ruby-mode-tests)
|
(provide 'ruby-mode-tests)
|
||||||
|
|
||||||
;;; ruby-mode-tests.el ends here
|
;;; ruby-mode-tests.el ends here
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue