GNU bug report logs -
#62208
30.0.50; [PATCH] save-some-buffers repeatedly asks for saving abbrev file
Previous Next
Reported by: Filipp Gunbin <fgunbin <at> fastmail.fm>
Date: Wed, 15 Mar 2023 17:43:02 UTC
Severity: normal
Tags: patch
Found in version 30.0.50
Fixed in version 29.1
Done: Stefan Kangas <stefankangas <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
Message #17 received at submit <at> debbugs.gnu.org (full text, mbox):
On 16/03/2023 07:12 +0200, Eli Zaretskii wrote:
> Also, would it be possible to add a test for this issue?
Now added test, full patch is below.
If/when it's fine, where should I install this?
Thanks.
diff --git a/lisp/abbrev.el b/lisp/abbrev.el
index ef8ef1ab5a6..1a665efb0a5 100644
--- a/lisp/abbrev.el
+++ b/lisp/abbrev.el
@@ -1250,17 +1250,17 @@ abbrev--possibly-save
;; 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..79ec51ba4d0 100644
--- a/test/lisp/abbrev-tests.el
+++ b/test/lisp/abbrev-tests.el
@@ -305,6 +305,22 @@ test-abbrev-table-p
(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' propertly 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
This bug report was last modified 1 year and 259 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.