[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 c54bda15e35: Reset abbrevs-changed after saving abbrevs (bug#62
From: |
Filipp Gunbin |
Subject: |
emacs-29 c54bda15e35: Reset abbrevs-changed after saving abbrevs (bug#62208) |
Date: |
Fri, 17 Mar 2023 10:11:57 -0400 (EDT) |
branch: emacs-29
commit c54bda15e35a6e9e2232997e805ef017a15e78c8
Author: Filipp Gunbin <fgunbin@fastmail.fm>
Commit: Filipp Gunbin <fgunbin@fastmail.fm>
Reset abbrevs-changed after saving abbrevs (bug#62208)
* lisp/abbrev.el (abbrev--possibly-save): Reset abbrevs-changed after
saving abbrevs.
* test/lisp/abbrev-tests.el (abbrev--possibly-save-test): New test.
---
lisp/abbrev.el | 22 +++++++++++-----------
test/lisp/abbrev-tests.el | 16 ++++++++++++++++
2 files changed, 27 insertions(+), 11 deletions(-)
diff --git a/lisp/abbrev.el b/lisp/abbrev.el
index 550d956fb7b..e1311dbc83b 100644
--- a/lisp/abbrev.el
+++ b/lisp/abbrev.el
@@ -1250,17 +1250,17 @@ which see."
;; asked to.
(and save-abbrevs
abbrevs-changed
- (progn
- (if (or arg
- (eq save-abbrevs 'silently)
- (y-or-n-p (format "Save abbrevs in %s? " abbrev-file-name)))
- (progn
- (write-abbrev-file nil)
- nil)
- ;; Don't keep bothering user if they say no.
- (setq abbrevs-changed nil)
- ;; Inhibit message in `save-some-buffers'.
- t)))))
+ (prog1
+ (if (or arg
+ (eq save-abbrevs 'silently)
+ (y-or-n-p (format "Save abbrevs in %s? "
abbrev-file-name)))
+ (progn
+ (write-abbrev-file nil)
+ nil)
+ ;; Inhibit message in `save-some-buffers'.
+ t)
+ ;; Don't ask again whether saved or user said no.
+ (setq abbrevs-changed nil)))))
(add-hook 'save-some-buffers-functions #'abbrev--possibly-save)
diff --git a/test/lisp/abbrev-tests.el b/test/lisp/abbrev-tests.el
index ecca21df4bc..7b2780309b0 100644
--- a/test/lisp/abbrev-tests.el
+++ b/test/lisp/abbrev-tests.el
@@ -305,6 +305,22 @@
(should-not (abbrev-table-p translation-table-vector))
(should (abbrev-table-p (make-abbrev-table))))
+(ert-deftest abbrev--possibly-save-test ()
+ "Test that `abbrev--possibly-save' properly resets
+`abbrevs-changed'."
+ (ert-with-temp-file temp-test-file
+ (let ((abbrev-file-name temp-test-file)
+ (save-abbrevs t))
+ ;; Save
+ (let ((abbrevs-changed t))
+ (should-not (abbrev--possibly-save nil t))
+ (should-not abbrevs-changed))
+ ;; Don't save
+ (let ((abbrevs-changed t))
+ (ert-simulate-keys '(?n)
+ (should (abbrev--possibly-save nil)))
+ (should-not abbrevs-changed)))))
+
(provide 'abbrev-tests)
;;; abbrev-tests.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- emacs-29 c54bda15e35: Reset abbrevs-changed after saving abbrevs (bug#62208),
Filipp Gunbin <=