diff options
author | Juri Linkov <juri@jurta.org> | 2010-03-30 19:03:08 +0300 |
---|---|---|
committer | Juri Linkov <juri@jurta.org> | 2010-03-30 19:03:08 +0300 |
commit | dc2d2590b24f7e4ee648b5d073ba744fbda7a4d8 (patch) | |
tree | 8d15261ebed74c762df72b14eb4023534c784520 /test | |
parent | 47c88c067f98772d5b505d7b6ad3d0909da5f68a (diff) | |
download | emacs-dc2d2590b24f7e4ee648b5d073ba744fbda7a4d8.tar.gz |
Make occur handle multi-line matches cleanly with context.
http://lists.gnu.org/archive/html/emacs-devel/2010-03/msg01280.html
* replace.el (occur-accumulate-lines): Add optional arg `pt'.
(occur-engine): Add local variables `ret', `prev-after-lines',
`prev-lines'. Use more arguments for `occur-context-lines'.
Set first elem of its returned list to `data', and the second elem
to `prev-after-lines'. Don't print the separator line.
In the end, print remaining context after-lines.
(occur-context-lines): Add new arguments `begpt', `endpt',
`lines', `prev-lines', `prev-after-lines'. Rewrite to combine
after-lines of the previous match with before-lines of the
current match and not overlap them. Return a list with two
values: the output line and the list of context after-lines.
* search.texi (Other Repeating Search): Remove line that `occur'
can not handle multiline matches.
* occur-testsuite.el (occur-tests): Add tests for context lines.
Diffstat (limited to 'test')
-rw-r--r-- | test/ChangeLog | 4 | ||||
-rw-r--r-- | test/occur-testsuite.el | 209 |
2 files changed, 212 insertions, 1 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index ee69172241d..87847a43ada 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,7 @@ +2010-03-30 Juri Linkov <juri@jurta.org> + + * occur-testsuite.el (occur-tests): Add tests for context lines. + 2010-03-23 Juri Linkov <juri@jurta.org> * occur-testsuite.el: New file. diff --git a/test/occur-testsuite.el b/test/occur-testsuite.el index d817805dd67..a4756c49e2a 100644 --- a/test/occur-testsuite.el +++ b/test/occur-testsuite.el @@ -107,7 +107,214 @@ fx :fx : ") - ) + ;; * Test non-overlapping context lines with matches at bob/eob. + ("x" 1 "\ +ax +b +c +d +ex +f +g +hx +" "\ +3 matches for \"x\" in buffer: *temp* + 1:ax + :b +------- + :d + 5:ex + :f +------- + :g + 8:hx +") + ;; * Test non-overlapping context lines with matches not at bob/eob. + ("x" 1 "\ +a +bx +c +d +ex +f +" "\ +2 matches for \"x\" in buffer: *temp* + :a + 2:bx + :c +------- + :d + 5:ex + :f +") + ;; * Test overlapping context lines with matches at bob/eob. + ("x" 2 "\ +ax +bx +c +dx +e +f +gx +h +i +j +kx +" "\ +5 matches for \"x\" in buffer: *temp* + 1:ax + 2:bx + :c + 4:dx + :e + :f + 7:gx + :h + :i + :j + 11:kx +") + ;; * Test overlapping context lines with matches not at bob/eob. + ("x" 2 "\ +a +b +cx +d +e +f +gx +h +i +" "\ +2 matches for \"x\" in buffer: *temp* + :a + :b + 3:cx + :d + :e + :f + 7:gx + :h + :i +") + ;; * Test overlapping context lines with empty first and last line.. + ("x" 2 "\ + +b +cx +d +e +f +gx +h + +" "\ +2 matches for \"x\" in buffer: *temp* + : + :b + 3:cx + :d + :e + :f + 7:gx + :h + : +") + ;; * Test multi-line overlapping context lines. + ("x\n.x" 2 "\ +ax +bx +c +d +ex +fx +g +h +i +jx +kx +" "\ +3 matches for \"x^J.x\" in buffer: *temp* + 1:ax + :bx + :c + :d + 5:ex + :fx + :g + :h + :i + 10:jx + :kx +") + ;; * Test multi-line non-overlapping context lines. + ("x\n.x" 2 "\ +ax +bx +c +d +e +f +gx +hx +" "\ +2 matches for \"x^J.x\" in buffer: *temp* + 1:ax + :bx + :c + :d +------- + :e + :f + 7:gx + :hx +") + ;; * Test non-overlapping negative (before-context) lines. + ("x" -2 "\ +a +bx +c +d +e +fx +g +h +ix +" "\ +3 matches for \"x\" in buffer: *temp* + :a + 2:bx +------- + :d + :e + 6:fx +------- + :g + :h + 9:ix +") + ;; * Test overlapping negative (before-context) lines. + ("x" -3 "\ +a +bx +c +dx +e +f +gx +h +" "\ +3 matches for \"x\" in buffer: *temp* + :a + 2:bx + :c + 4:dx + :e + :f + 7:gx +") + +) "List of tests for `occur'. Each element has the format: \(REGEXP NLINES INPUT-BUFFER-STRING OUTPUT-BUFFER-STRING).") |