;; 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)
(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