diff options
| author | Dmitry Gutov | 2013-02-14 07:33:55 +0400 |
|---|---|---|
| committer | Dmitry Gutov | 2013-02-14 07:33:55 +0400 |
| commit | 53ca88c478b773f2b56084442c8d17e83577f52c (patch) | |
| tree | 53c4a4346dd423000de81ed52bd14b2d104f5237 | |
| parent | 6b26f14f789112bb929f65a8d44caeda11418432 (diff) | |
| download | emacs-53ca88c478b773f2b56084442c8d17e83577f52c.tar.gz emacs-53ca88c478b773f2b56084442c8d17e83577f52c.zip | |
* 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.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/progmodes/ruby-mode.el | 18 | ||||
| -rw-r--r-- | test/ChangeLog | 7 | ||||
| -rw-r--r-- | test/automated/ruby-mode-tests.el | 19 |
4 files changed, 41 insertions, 10 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index eb3f4f833f5..fd520361889 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2013-02-14 Dmitry Gutov <dgutov@yandex.ru> | ||
| 2 | |||
| 3 | * progmodes/ruby-mode.el (ruby-parse-partial): Don't increase | ||
| 4 | depth for unfinished percent literal. Not using it in the caller. | ||
| 5 | (ruby-move-to-block): Jump over multiline literals of all types, | ||
| 6 | ignoring code-looking contents inside them. | ||
| 7 | |||
| 1 | 2013-02-13 Michael Albinus <michael.albinus@gmx.de> | 8 | 2013-02-13 Michael Albinus <michael.albinus@gmx.de> |
| 2 | 9 | ||
| 3 | Use ControlMaster where applicable. (Bug#13677) | 10 | Use ControlMaster where applicable. (Bug#13677) |
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index b1017bb6302..453d08fc47b 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el | |||
| @@ -519,12 +519,6 @@ Can be one of `heredoc', `modifier', `expr-qstr', `expr-re'." | |||
| 519 | (concat "[^\\]\\(\\\\\\\\\\)*" w)) | 519 | (concat "[^\\]\\(\\\\\\\\\\)*" w)) |
| 520 | end t))) | 520 | end t))) |
| 521 | (setq in-string (point)) | 521 | (setq in-string (point)) |
| 522 | (when (eq (char-syntax (string-to-char w)) ?\() | ||
| 523 | ;; The rest of the literal, when parsed separately, will | ||
| 524 | ;; have the depth of -1. So in the rare case when this | ||
| 525 | ;; number is used despite the in-string status, the | ||
| 526 | ;; depths will balance. | ||
| 527 | (setq depth (1+ depth))) | ||
| 528 | (goto-char end))) | 522 | (goto-char end))) |
| 529 | (t | 523 | (t |
| 530 | (goto-char pnt)))) | 524 | (goto-char pnt)))) |
| @@ -913,10 +907,16 @@ current block, a sibling block, or an outer block. Do that (abs N) times." | |||
| 913 | (re-search-forward "^=end\\>")) | 907 | (re-search-forward "^=end\\>")) |
| 914 | ((and backward (looking-at "^=end\\>")) | 908 | ((and backward (looking-at "^=end\\>")) |
| 915 | (re-search-backward "^=begin\\>")) | 909 | (re-search-backward "^=begin\\>")) |
| 910 | ;; Jump over a multiline literal. | ||
| 911 | ((ruby-in-ppss-context-p 'string) | ||
| 912 | (goto-char (nth 8 (syntax-ppss))) | ||
| 913 | (unless backward | ||
| 914 | (forward-sexp) | ||
| 915 | (when (bolp) (forward-char -1)))) ; After a heredoc. | ||
| 916 | (t | 916 | (t |
| 917 | (incf depth (or (nth 2 (ruby-parse-region (point) | 917 | (let ((state (ruby-parse-region (point) (line-end-position)))) |
| 918 | (line-end-position))) | 918 | (unless (car state) ; Line ends with unfinished string. |
| 919 | 0)) | 919 | (setq depth (+ (nth 2 state) depth)))) |
| 920 | (cond | 920 | (cond |
| 921 | ;; Deeper indentation, we found a block. | 921 | ;; Deeper indentation, we found a block. |
| 922 | ;; FIXME: We can't recognize empty blocks this way. | 922 | ;; FIXME: We can't recognize empty blocks this way. |
diff --git a/test/ChangeLog b/test/ChangeLog index f508209008e..7e08eccc2e3 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2013-02-14 Dmitry Gutov <dgutov@yandex.ru> | ||
| 2 | |||
| 3 | * automated/ruby-mode-tests.el | ||
| 4 | (ruby-move-to-block-skips-percent-literal): Add depth-affecting | ||
| 5 | bits inside the examples. | ||
| 6 | (ruby-move-to-block-skips-heredoc): New test. | ||
| 7 | |||
| 1 | 2013-02-13 Dmitry Gutov <dgutov@yandex.ru> | 8 | 2013-02-13 Dmitry Gutov <dgutov@yandex.ru> |
| 2 | 9 | ||
| 3 | * automated/ruby-mode-tests.el | 10 | * automated/ruby-mode-tests.el |
diff --git a/test/automated/ruby-mode-tests.el b/test/automated/ruby-mode-tests.el index 6798a49d53c..9ee6462f6ad 100644 --- a/test/automated/ruby-mode-tests.el +++ b/test/automated/ruby-mode-tests.el | |||
| @@ -449,20 +449,37 @@ VALUES-PLIST is a list with alternating index and value elements." | |||
| 449 | (dolist (s (list (ruby-test-string | 449 | (dolist (s (list (ruby-test-string |
| 450 | "foo do | 450 | "foo do |
| 451 | | a = %%w( | 451 | | a = %%w( |
| 452 | | def yaa | ||
| 452 | | ) | 453 | | ) |
| 453 | |end") | 454 | |end") |
| 454 | (ruby-test-string | 455 | (ruby-test-string |
| 455 | "foo do | 456 | "foo do |
| 456 | | a = %%w| | 457 | | a = %%w| |
| 458 | | end | ||
| 457 | | | | 459 | | | |
| 458 | |end"))) | 460 | |end"))) |
| 459 | (ruby-with-temp-buffer s | 461 | (ruby-with-temp-buffer s |
| 460 | (goto-line 1) | 462 | (goto-line 1) |
| 461 | (ruby-end-of-block) | 463 | (ruby-end-of-block) |
| 462 | (should (= 4 (line-number-at-pos))) | 464 | (should (= 5 (line-number-at-pos))) |
| 463 | (ruby-beginning-of-block) | 465 | (ruby-beginning-of-block) |
| 464 | (should (= 1 (line-number-at-pos)))))) | 466 | (should (= 1 (line-number-at-pos)))))) |
| 465 | 467 | ||
| 468 | (ert-deftest ruby-move-to-block-skips-heredoc () | ||
| 469 | (ruby-with-temp-buffer | ||
| 470 | (ruby-test-string | ||
| 471 | "if something_wrong? | ||
| 472 | | ActiveSupport::Deprecation.warn(<<-eowarn) | ||
| 473 | | boo hoo | ||
| 474 | | end | ||
| 475 | | eowarn | ||
| 476 | |end") | ||
| 477 | (goto-line 1) | ||
| 478 | (ruby-end-of-block) | ||
| 479 | (should (= 6 (line-number-at-pos))) | ||
| 480 | (ruby-beginning-of-block) | ||
| 481 | (should (= 1 (line-number-at-pos))))) | ||
| 482 | |||
| 466 | (provide 'ruby-mode-tests) | 483 | (provide 'ruby-mode-tests) |
| 467 | 484 | ||
| 468 | ;;; ruby-mode-tests.el ends here | 485 | ;;; ruby-mode-tests.el ends here |