diff options
| author | Lars Ingebrigtsen | 2021-08-23 15:56:50 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2021-08-23 15:56:54 +0200 |
| commit | 591b8bd87a30bda3dad680752b7f63da8b5b74bd (patch) | |
| tree | 847301e45c0c58a4242da2ba9a706277e5193e4d /test/src/buffer-tests.el | |
| parent | f00af4be3d8c14fc83925dcd244701c0dce7604a (diff) | |
| download | emacs-591b8bd87a30bda3dad680752b7f63da8b5b74bd.tar.gz emacs-591b8bd87a30bda3dad680752b7f63da8b5b74bd.zip | |
Add new variable 'kill-buffer/delete-auto-save-files'
* doc/emacs/files.texi (Auto Save Files): Document it.
* lisp/cus-start.el (standard): Add customize form.
* lisp/files.el (delete-auto-save-files): Move definition to C
(since it's used in the C layer).
* src/buffer.c (Fkill_buffer): Use the new variable (and remove
the old code that apparently didn't trigger for
kill-buffer/delete-auto-save-files.
(syms_of_buffer): Add new variable
kill-buffer-delete-auto-save-files and move definition of
delete-auto-save-files here (bug#21612).
Diffstat (limited to 'test/src/buffer-tests.el')
| -rw-r--r-- | test/src/buffer-tests.el | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/test/src/buffer-tests.el b/test/src/buffer-tests.el index 118311c4d26..059926ff46b 100644 --- a/test/src/buffer-tests.el +++ b/test/src/buffer-tests.el | |||
| @@ -1420,4 +1420,67 @@ with parameters from the *Messages* buffer modification." | |||
| 1420 | (remove-overlays) | 1420 | (remove-overlays) |
| 1421 | (should (= (length (overlays-in (point-min) (point-max))) 0)))) | 1421 | (should (= (length (overlays-in (point-min) (point-max))) 0)))) |
| 1422 | 1422 | ||
| 1423 | (ert-deftest test-kill-buffer-auto-save-default () | ||
| 1424 | (let ((file (make-temp-file "ert")) | ||
| 1425 | auto-save) | ||
| 1426 | (should (file-exists-p file)) | ||
| 1427 | ;; Always answer yes. | ||
| 1428 | (cl-letf (((symbol-function #'yes-or-no-p) (lambda (_) t))) | ||
| 1429 | (unwind-protect | ||
| 1430 | (progn | ||
| 1431 | (find-file file) | ||
| 1432 | (auto-save-mode t) | ||
| 1433 | (insert "foo\n") | ||
| 1434 | (should buffer-auto-save-file-name) | ||
| 1435 | (setq auto-save buffer-auto-save-file-name) | ||
| 1436 | (do-auto-save) | ||
| 1437 | (should (file-exists-p auto-save)) | ||
| 1438 | (kill-buffer (current-buffer)) | ||
| 1439 | (should (file-exists-p auto-save))) | ||
| 1440 | (ignore-errors (delete-file file)) | ||
| 1441 | (when auto-save | ||
| 1442 | (ignore-errors (delete-file auto-save))))))) | ||
| 1443 | |||
| 1444 | (ert-deftest test-kill-buffer-auto-save-delete () | ||
| 1445 | (let ((file (make-temp-file "ert")) | ||
| 1446 | auto-save) | ||
| 1447 | (should (file-exists-p file)) | ||
| 1448 | (setq kill-buffer-delete-auto-save-files t) | ||
| 1449 | ;; Always answer yes. | ||
| 1450 | (cl-letf (((symbol-function #'yes-or-no-p) (lambda (_) t))) | ||
| 1451 | (unwind-protect | ||
| 1452 | (progn | ||
| 1453 | (find-file file) | ||
| 1454 | (auto-save-mode t) | ||
| 1455 | (insert "foo\n") | ||
| 1456 | (should buffer-auto-save-file-name) | ||
| 1457 | (setq auto-save buffer-auto-save-file-name) | ||
| 1458 | (do-auto-save) | ||
| 1459 | (should (file-exists-p auto-save)) | ||
| 1460 | ;; This should delete the auto-save file. | ||
| 1461 | (kill-buffer (current-buffer)) | ||
| 1462 | (should-not (file-exists-p auto-save))) | ||
| 1463 | (ignore-errors (delete-file file)) | ||
| 1464 | (when auto-save | ||
| 1465 | (ignore-errors (delete-file auto-save))))) | ||
| 1466 | ;; Answer no to deletion. | ||
| 1467 | (cl-letf (((symbol-function #'yes-or-no-p) | ||
| 1468 | (lambda (prompt) | ||
| 1469 | (not (string-search "Delete auto-save file" prompt))))) | ||
| 1470 | (unwind-protect | ||
| 1471 | (progn | ||
| 1472 | (find-file file) | ||
| 1473 | (auto-save-mode t) | ||
| 1474 | (insert "foo\n") | ||
| 1475 | (should buffer-auto-save-file-name) | ||
| 1476 | (setq auto-save buffer-auto-save-file-name) | ||
| 1477 | (do-auto-save) | ||
| 1478 | (should (file-exists-p auto-save)) | ||
| 1479 | ;; This should not delete the auto-save file. | ||
| 1480 | (kill-buffer (current-buffer)) | ||
| 1481 | (should (file-exists-p auto-save))) | ||
| 1482 | (ignore-errors (delete-file file)) | ||
| 1483 | (when auto-save | ||
| 1484 | (ignore-errors (delete-file auto-save))))))) | ||
| 1485 | |||
| 1423 | ;;; buffer-tests.el ends here | 1486 | ;;; buffer-tests.el ends here |