aboutsummaryrefslogtreecommitdiffstats
path: root/test/lisp/replace-tests.el
diff options
context:
space:
mode:
authorEli Zaretskii2018-10-09 17:46:31 +0300
committerEli Zaretskii2018-10-09 17:46:31 +0300
commitcd7caee630f9425a1a16e4da31e892a2ec29ac09 (patch)
tree8c624e08350bcb6e11d085e11295424093d5abe4 /test/lisp/replace-tests.el
parent333f0bfe766185c66952c6fbd4796c6bb97c868d (diff)
downloademacs-cd7caee630f9425a1a16e4da31e892a2ec29ac09.tar.gz
emacs-cd7caee630f9425a1a16e4da31e892a2ec29ac09.zip
Unbreak 'revert-buffer' in Occur buffers
* lisp/replace.el (occur-revert-function): Use the value of occur-revert-function from the correct buffer. (Bug#32987) * test/lisp/replace-tests.el (replace-occur-revert-bug32543) (replace-occur-revert-bug32987): New tests.
Diffstat (limited to 'test/lisp/replace-tests.el')
-rw-r--r--test/lisp/replace-tests.el47
1 files changed, 46 insertions, 1 deletions
diff --git a/test/lisp/replace-tests.el b/test/lisp/replace-tests.el
index 3fcdce6704f..5a91a2cc7f6 100644
--- a/test/lisp/replace-tests.el
+++ b/test/lisp/replace-tests.el
@@ -359,6 +359,52 @@ Each element has the format:
359(dotimes (i (length replace-occur-tests)) 359(dotimes (i (length replace-occur-tests))
360 (replace-occur-test-create i)) 360 (replace-occur-test-create i))
361 361
362(ert-deftest replace-occur-revert-bug32543 ()
363 "Test `occur-revert' with non-nil `list-matching-lines-jump-to-current-line'."
364 (let ((temp-buffer (get-buffer-create " *test-occur*")))
365 (unwind-protect
366 (save-window-excursion
367 (with-current-buffer temp-buffer
368 (erase-buffer)
369 (setq list-matching-lines-jump-to-current-line t)
370 (insert
371";; This buffer is for text that is not saved, and for Lisp evaluation.
372;; To create a file, visit it with C-x C-f and enter text in its buffer.
373
374")
375 (occur "and")
376 (with-current-buffer "*Occur*"
377 (revert-buffer)
378 (goto-char (point-min))
379 (should (string-match "\\`2 matches for \"and\" in buffer: "
380 (buffer-substring-no-properties
381 (point) (line-end-position)))))))
382 (and (buffer-name temp-buffer)
383 (kill-buffer temp-buffer)))))
384
385(ert-deftest replace-occur-revert-bug32987 ()
386 "Test `occur-revert' with non-nil `list-matching-lines-jump-to-current-line'."
387 (let ((temp-buffer (get-buffer-create " *test-occur*")))
388 (unwind-protect
389 (save-window-excursion
390 (with-current-buffer temp-buffer
391 (erase-buffer)
392 (setq list-matching-lines-jump-to-current-line nil)
393 (insert
394";; This buffer is for text that is not saved, and for Lisp evaluation.
395;; To create a file, visit it with C-x C-f and enter text in its buffer.
396
397")
398 (occur "and")
399 (with-current-buffer "*Occur*"
400 (revert-buffer)
401 (goto-char (point-min))
402 (should (string-match "\\`2 matches for \"and\" in buffer: "
403 (buffer-substring-no-properties
404 (point) (line-end-position)))))))
405 (and (buffer-name temp-buffer)
406 (kill-buffer temp-buffer)))))
407
362 408
363;;; Tests for `query-replace' undo feature. 409;;; Tests for `query-replace' undo feature.
364 410
@@ -454,5 +500,4 @@ Return the last evalled form in BODY."
454 input "a" "B" ((?\s . (1 2 3)) (?E . (4)) (?U . (5))) ?q 500 input "a" "B" ((?\s . (1 2 3)) (?E . (4)) (?U . (5))) ?q
455 (string= input (buffer-string)))))) 501 (string= input (buffer-string))))))
456 502
457
458;;; replace-tests.el ends here 503;;; replace-tests.el ends here