summaryrefslogtreecommitdiff
path: root/lisp/abbrev.el
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2022-05-23 09:45:35 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2022-05-23 09:45:35 +0200
commit1cfb89dc79b76923c1c93cb44e3e4836b6a8c2bf (patch)
tree81e7e9a50ea5edc92edacedc18e8c1f3cdb2b11e /lisp/abbrev.el
parentf471eaf44058cfec9e5f7eb53d0a66520f4d4f6d (diff)
downloademacs-1cfb89dc79b76923c1c93cb44e3e4836b6a8c2bf.tar.gz
emacs-1cfb89dc79b76923c1c93cb44e3e4836b6a8c2bf.tar.bz2
emacs-1cfb89dc79b76923c1c93cb44e3e4836b6a8c2bf.zip
Allow extending 'save-some-buffers'
* lisp/abbrev.el (abbrev--possibly-save): Separated out from `save-some-buffers'. (save-some-buffers-functions): Add to the save function. * lisp/files.el (save-some-buffers-functions): New variable. (save-some-buffers): Use it. (save-buffers-kill-emacs): Also use it to see if we have something to save (bug#55579).
Diffstat (limited to 'lisp/abbrev.el')
-rw-r--r--lisp/abbrev.el22
1 files changed, 22 insertions, 0 deletions
diff --git a/lisp/abbrev.el b/lisp/abbrev.el
index 214f7435d91..3ee972869bc 100644
--- a/lisp/abbrev.el
+++ b/lisp/abbrev.el
@@ -1197,6 +1197,28 @@ This mode is for editing abbrevs in a buffer prepared by `edit-abbrevs',
which see."
:interactive nil)
+(defun abbrev--possibly-save (query &optional arg)
+ ;; Query mode.
+ (if (eq query 'query)
+ (and save-abbrevs abbrevs-changed)
+ ;; Maybe save abbrevs, and record whether we either saved them or
+ ;; 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)))))
+
+(add-hook 'save-some-buffers-functions #'abbrev--possibly-save)
+
(provide 'abbrev)
;;; abbrev.el ends here