aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJuri Linkov2010-03-30 19:03:08 +0300
committerJuri Linkov2010-03-30 19:03:08 +0300
commitdc2d2590b24f7e4ee648b5d073ba744fbda7a4d8 (patch)
tree8d15261ebed74c762df72b14eb4023534c784520 /test
parent47c88c067f98772d5b505d7b6ad3d0909da5f68a (diff)
downloademacs-dc2d2590b24f7e4ee648b5d073ba744fbda7a4d8.tar.gz
emacs-dc2d2590b24f7e4ee648b5d073ba744fbda7a4d8.zip
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/ChangeLog4
-rw-r--r--test/occur-testsuite.el209
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 @@
12010-03-30 Juri Linkov <juri@jurta.org>
2
3 * occur-testsuite.el (occur-tests): Add tests for context lines.
4
12010-03-23 Juri Linkov <juri@jurta.org> 52010-03-23 Juri Linkov <juri@jurta.org>
2 6
3 * occur-testsuite.el: New file. 7 * 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
107 :fx 107 :fx
108 : 108 :
109") 109")
110 ) 110 ;; * Test non-overlapping context lines with matches at bob/eob.
111 ("x" 1 "\
112ax
113b
114c
115d
116ex
117f
118g
119hx
120" "\
1213 matches for \"x\" in buffer: *temp*
122 1:ax
123 :b
124-------
125 :d
126 5:ex
127 :f
128-------
129 :g
130 8:hx
131")
132 ;; * Test non-overlapping context lines with matches not at bob/eob.
133 ("x" 1 "\
134a
135bx
136c
137d
138ex
139f
140" "\
1412 matches for \"x\" in buffer: *temp*
142 :a
143 2:bx
144 :c
145-------
146 :d
147 5:ex
148 :f
149")
150 ;; * Test overlapping context lines with matches at bob/eob.
151 ("x" 2 "\
152ax
153bx
154c
155dx
156e
157f
158gx
159h
160i
161j
162kx
163" "\
1645 matches for \"x\" in buffer: *temp*
165 1:ax
166 2:bx
167 :c
168 4:dx
169 :e
170 :f
171 7:gx
172 :h
173 :i
174 :j
175 11:kx
176")
177 ;; * Test overlapping context lines with matches not at bob/eob.
178 ("x" 2 "\
179a
180b
181cx
182d
183e
184f
185gx
186h
187i
188" "\
1892 matches for \"x\" in buffer: *temp*
190 :a
191 :b
192 3:cx
193 :d
194 :e
195 :f
196 7:gx
197 :h
198 :i
199")
200 ;; * Test overlapping context lines with empty first and last line..
201 ("x" 2 "\
202
203b
204cx
205d
206e
207f
208gx
209h
210
211" "\
2122 matches for \"x\" in buffer: *temp*
213 :
214 :b
215 3:cx
216 :d
217 :e
218 :f
219 7:gx
220 :h
221 :
222")
223 ;; * Test multi-line overlapping context lines.
224 ("x\n.x" 2 "\
225ax
226bx
227c
228d
229ex
230fx
231g
232h
233i
234jx
235kx
236" "\
2373 matches for \"x^J.x\" in buffer: *temp*
238 1:ax
239 :bx
240 :c
241 :d
242 5:ex
243 :fx
244 :g
245 :h
246 :i
247 10:jx
248 :kx
249")
250 ;; * Test multi-line non-overlapping context lines.
251 ("x\n.x" 2 "\
252ax
253bx
254c
255d
256e
257f
258gx
259hx
260" "\
2612 matches for \"x^J.x\" in buffer: *temp*
262 1:ax
263 :bx
264 :c
265 :d
266-------
267 :e
268 :f
269 7:gx
270 :hx
271")
272 ;; * Test non-overlapping negative (before-context) lines.
273 ("x" -2 "\
274a
275bx
276c
277d
278e
279fx
280g
281h
282ix
283" "\
2843 matches for \"x\" in buffer: *temp*
285 :a
286 2:bx
287-------
288 :d
289 :e
290 6:fx
291-------
292 :g
293 :h
294 9:ix
295")
296 ;; * Test overlapping negative (before-context) lines.
297 ("x" -3 "\
298a
299bx
300c
301dx
302e
303f
304gx
305h
306" "\
3073 matches for \"x\" in buffer: *temp*
308 :a
309 2:bx
310 :c
311 4:dx
312 :e
313 :f
314 7:gx
315")
316
317)
111 "List of tests for `occur'. 318 "List of tests for `occur'.
112Each element has the format: 319Each element has the format:
113\(REGEXP NLINES INPUT-BUFFER-STRING OUTPUT-BUFFER-STRING).") 320\(REGEXP NLINES INPUT-BUFFER-STRING OUTPUT-BUFFER-STRING).")