aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorLars Ingebrigtsen2022-05-10 03:38:01 +0200
committerLars Ingebrigtsen2022-05-10 03:46:43 +0200
commit0bee4cda881f7db4113cba541b684c334e828c4a (patch)
tree4873dc599fb34e07c5e967ea5d91cb867c151c1b /test/src
parent0b2f550e3229c7a1b001fb1a09e7a5b4e3ecfb3e (diff)
downloademacs-0bee4cda881f7db4113cba541b684c334e828c4a.tar.gz
emacs-0bee4cda881f7db4113cba541b684c334e828c4a.zip
Reimplement recent with-silent-modifications auto-save changes
* doc/lispref/buffers.texi (Buffer Modification): Document buffer-modified-p returning `autosaved'. * lisp/subr.el (with-silent-modifications): Use restore-buffer-modified-p instead of altering the buffer modiff (since this has other side effects like not updating after async `display' changes. * src/buffer.c (Fbuffer_modified_p): Allow returning whether the buffer has been autosaved after changes. (Frestore_buffer_modified_p): Allow adjusting whether the buffer has been autosaved after changes. * src/fileio.c (Fdo_auto_save): Refill the doc string.
Diffstat (limited to 'test/src')
-rw-r--r--test/src/buffer-tests.el35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/src/buffer-tests.el b/test/src/buffer-tests.el
index c1e5d0ebed3..10dac68f9fe 100644
--- a/test/src/buffer-tests.el
+++ b/test/src/buffer-tests.el
@@ -1482,4 +1482,39 @@ with parameters from the *Messages* buffer modification."
1482 (when auto-save 1482 (when auto-save
1483 (ignore-errors (delete-file auto-save)))))))) 1483 (ignore-errors (delete-file auto-save))))))))
1484 1484
1485(ert-deftest test-buffer-modifications ()
1486 (ert-with-temp-file file
1487 (with-current-buffer (find-file file)
1488 (auto-save-mode 1)
1489 (should-not (buffer-modified-p))
1490 (insert "foo")
1491 (should (buffer-modified-p))
1492 (should-not (eq (buffer-modified-p) 'autosaved))
1493 (do-auto-save nil t)
1494 (should (eq (buffer-modified-p) 'autosaved))
1495 (with-silent-modifications
1496 (put-text-property 1 3 'face 'bold))
1497 (should (eq (buffer-modified-p) 'autosaved))
1498 (save-buffer)
1499 (should-not (buffer-modified-p))
1500 (with-silent-modifications
1501 (put-text-property 1 3 'face 'italic))
1502 (should-not (buffer-modified-p)))))
1503
1504(ert-deftest test-restore-buffer-modified-p ()
1505 (ert-with-temp-file file
1506 (with-current-buffer (find-file file)
1507 (auto-save-mode 1)
1508 (should-not (buffer-modified-p))
1509 (insert "foo")
1510 (should (buffer-modified-p))
1511 (restore-buffer-modified-p nil)
1512 (should-not (buffer-modified-p))
1513 (insert "bar")
1514 (do-auto-save nil t)
1515 (should (eq (buffer-modified-p) 'autosaved))
1516 (insert "zot")
1517 (restore-buffer-modified-p 'autosaved)
1518 (should (eq (buffer-modified-p) 'autosaved)))))
1519
1485;;; buffer-tests.el ends here 1520;;; buffer-tests.el ends here