diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2022-06-24 11:04:03 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2022-06-24 11:04:51 +0200 |
commit | e193ea3c34b01a09806cffbca2d3b5657881419b (patch) | |
tree | 465d5d1f1b70d2fc9163c7a3d48ba4b8dc8c1d97 /lisp/simple.el | |
parent | f2b7525e3875cdf5a9b01ca21bc393367ec1f703 (diff) | |
download | emacs-e193ea3c34b01a09806cffbca2d3b5657881419b.tar.gz emacs-e193ea3c34b01a09806cffbca2d3b5657881419b.tar.bz2 emacs-e193ea3c34b01a09806cffbca2d3b5657881419b.zip |
Allow `kill-buffer' query to save the buffer first
* lisp/loadup.el ("emacs-lisp/rmc"): Preload.
* lisp/simple.el (kill-buffer--possibly-save): New function to
offer to save the buffer before killing (bug#47075).
* src/buffer.c (Fkill_buffer): Call the new function to query the
user.
(syms_of_buffer): Define symbol.
Diffstat (limited to 'lisp/simple.el')
-rw-r--r-- | lisp/simple.el | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index f2b3d82a7a5..653cffae62c 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -10560,6 +10560,23 @@ If the buffer doesn't exist, create it first." (interactive) (pop-to-buffer-same-window (get-scratch-buffer-create))) +(defun kill-buffer--possibly-save (buffer) + (let ((response + (cadr + (read-multiple-choice + (format "Buffer %s modified; kill anyway?" + (buffer-name)) + '((?y "yes" "kill buffer without saving") + (?n "no" "exit without doing anything") + (?s "save and then kill" "save the buffer and then kill it")) + nil nil (not use-short-answers))))) + (if (equal response "no") + nil + (unless (equal response "yes") + (with-current-buffer buffer + (save-buffer))) + t))) + (provide 'simple) |