xex
fx
" "\
-5 matches for \"x\" in buffer: *temp*<2>
+5 matches for \"x\" in buffer: *test-occur*
1:xa
3:cx
4:xd
a
a
" "\
-2 matches for \"a^Ja\" in buffer: *temp*<2>
+2 matches for \"a^Ja\" in buffer: *test-occur*
1:a
:a
3:a
a
b
" "\
-2 matches for \"a^Jb\" in buffer: *temp*<2>
+2 matches for \"a^Jb\" in buffer: *test-occur*
1:a
:b
4:a
a
" "\
-2 matches for \"a^J\" in buffer: *temp*<2>
+2 matches for \"a^J\" in buffer: *test-occur*
1:a
:
4:a
ex
fx
" "\
-2 matches for \"x^J.x^J\" in buffer: *temp*<2>
+2 matches for \"x^J.x^J\" in buffer: *test-occur*
1:ax
:bx
:c
g
hx
" "\
-3 matches for \"x\" in buffer: *temp*<2>
+3 matches for \"x\" in buffer: *test-occur*
1:ax
:b
-------
ex
f
" "\
-2 matches for \"x\" in buffer: *temp*<2>
+2 matches for \"x\" in buffer: *test-occur*
:a
2:bx
:c
j
kx
" "\
-5 matches for \"x\" in buffer: *temp*<2>
+5 matches for \"x\" in buffer: *test-occur*
1:ax
2:bx
:c
h
i
" "\
-2 matches for \"x\" in buffer: *temp*<2>
+2 matches for \"x\" in buffer: *test-occur*
:a
:b
3:cx
h
" "\
-2 matches for \"x\" in buffer: *temp*<2>
+2 matches for \"x\" in buffer: *test-occur*
:
:b
3:cx
jx
kx
" "\
-3 matches for \"x^J.x\" in buffer: *temp*<2>
+3 matches for \"x^J.x\" in buffer: *test-occur*
1:ax
:bx
:c
gx
hx
" "\
-2 matches for \"x^J.x\" in buffer: *temp*<2>
+2 matches for \"x^J.x\" in buffer: *test-occur*
1:ax
:bx
:c
h
ix
" "\
-3 matches for \"x\" in buffer: *temp*<2>
+3 matches for \"x\" in buffer: *test-occur*
:a
2:bx
-------
gx
h
" "\
-3 matches for \"x\" in buffer: *temp*<2>
+3 matches for \"x\" in buffer: *test-occur*
:a
2:bx
:c
(let ((regexp (nth 0 test))
(nlines (nth 1 test))
(input-buffer-string (nth 2 test))
- (output-buffer-string (nth 3 test)))
- (save-window-excursion
- (with-temp-buffer
- (insert input-buffer-string)
- (occur regexp nlines)
- (equal output-buffer-string
- (with-current-buffer "*Occur*"
- (buffer-string)))))))
+ (output-buffer-string (nth 3 test))
+ (temp-buffer (get-buffer-create " *test-occur*")))
+ (unwind-protect
+ (save-window-excursion
+ (with-current-buffer temp-buffer
+ (erase-buffer)
+ (insert input-buffer-string)
+ (occur regexp nlines)
+ (equal output-buffer-string
+ (with-current-buffer "*Occur*"
+ (buffer-string)))))
+ (and (buffer-name temp-buffer)
+ (kill-buffer temp-buffer)))))
(ert-deftest occur-tests ()
"Test the functionality of `occur'.