diff options
| author | Juri Linkov | 2010-03-30 19:03:08 +0300 |
|---|---|---|
| committer | Juri Linkov | 2010-03-30 19:03:08 +0300 |
| commit | dc2d2590b24f7e4ee648b5d073ba744fbda7a4d8 (patch) | |
| tree | 8d15261ebed74c762df72b14eb4023534c784520 /test | |
| parent | 47c88c067f98772d5b505d7b6ad3d0909da5f68a (diff) | |
| download | emacs-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/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 @@ | |||
| 1 | 2010-03-30 Juri Linkov <juri@jurta.org> | ||
| 2 | |||
| 3 | * occur-testsuite.el (occur-tests): Add tests for context lines. | ||
| 4 | |||
| 1 | 2010-03-23 Juri Linkov <juri@jurta.org> | 5 | 2010-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 "\ | ||
| 112 | ax | ||
| 113 | b | ||
| 114 | c | ||
| 115 | d | ||
| 116 | ex | ||
| 117 | f | ||
| 118 | g | ||
| 119 | hx | ||
| 120 | " "\ | ||
| 121 | 3 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 "\ | ||
| 134 | a | ||
| 135 | bx | ||
| 136 | c | ||
| 137 | d | ||
| 138 | ex | ||
| 139 | f | ||
| 140 | " "\ | ||
| 141 | 2 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 "\ | ||
| 152 | ax | ||
| 153 | bx | ||
| 154 | c | ||
| 155 | dx | ||
| 156 | e | ||
| 157 | f | ||
| 158 | gx | ||
| 159 | h | ||
| 160 | i | ||
| 161 | j | ||
| 162 | kx | ||
| 163 | " "\ | ||
| 164 | 5 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 "\ | ||
| 179 | a | ||
| 180 | b | ||
| 181 | cx | ||
| 182 | d | ||
| 183 | e | ||
| 184 | f | ||
| 185 | gx | ||
| 186 | h | ||
| 187 | i | ||
| 188 | " "\ | ||
| 189 | 2 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 | |||
| 203 | b | ||
| 204 | cx | ||
| 205 | d | ||
| 206 | e | ||
| 207 | f | ||
| 208 | gx | ||
| 209 | h | ||
| 210 | |||
| 211 | " "\ | ||
| 212 | 2 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 "\ | ||
| 225 | ax | ||
| 226 | bx | ||
| 227 | c | ||
| 228 | d | ||
| 229 | ex | ||
| 230 | fx | ||
| 231 | g | ||
| 232 | h | ||
| 233 | i | ||
| 234 | jx | ||
| 235 | kx | ||
| 236 | " "\ | ||
| 237 | 3 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 "\ | ||
| 252 | ax | ||
| 253 | bx | ||
| 254 | c | ||
| 255 | d | ||
| 256 | e | ||
| 257 | f | ||
| 258 | gx | ||
| 259 | hx | ||
| 260 | " "\ | ||
| 261 | 2 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 "\ | ||
| 274 | a | ||
| 275 | bx | ||
| 276 | c | ||
| 277 | d | ||
| 278 | e | ||
| 279 | fx | ||
| 280 | g | ||
| 281 | h | ||
| 282 | ix | ||
| 283 | " "\ | ||
| 284 | 3 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 "\ | ||
| 298 | a | ||
| 299 | bx | ||
| 300 | c | ||
| 301 | dx | ||
| 302 | e | ||
| 303 | f | ||
| 304 | gx | ||
| 305 | h | ||
| 306 | " "\ | ||
| 307 | 3 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'. |
| 112 | Each element has the format: | 319 | Each element has the format: |
| 113 | \(REGEXP NLINES INPUT-BUFFER-STRING OUTPUT-BUFFER-STRING).") | 320 | \(REGEXP NLINES INPUT-BUFFER-STRING OUTPUT-BUFFER-STRING).") |