aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
authorLars Ingebrigtsen2022-06-24 11:04:03 +0200
committerLars Ingebrigtsen2022-06-24 11:04:51 +0200
commite193ea3c34b01a09806cffbca2d3b5657881419b (patch)
tree465d5d1f1b70d2fc9163c7a3d48ba4b8dc8c1d97 /src/buffer.c
parentf2b7525e3875cdf5a9b01ca21bc393367ec1f703 (diff)
downloademacs-e193ea3c34b01a09806cffbca2d3b5657881419b.tar.gz
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 'src/buffer.c')
-rw-r--r--src/buffer.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 7adcd22d88b..509ce51b55e 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1809,10 +1809,12 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1809 /* Query if the buffer is still modified. */ 1809 /* Query if the buffer is still modified. */
1810 if (INTERACTIVE && modified) 1810 if (INTERACTIVE && modified)
1811 { 1811 {
1812 AUTO_STRING (format, "Buffer %s modified; kill anyway? "); 1812 /* Ask whether to kill the buffer, and exit if the user says
1813 tem = do_yes_or_no_p (CALLN (Fformat, format, BVAR (b, name))); 1813 "no". */
1814 if (NILP (tem)) 1814 if (NILP (call1 (Qkill_buffer__possibly_save, buffer)))
1815 return unbind_to (count, Qnil); 1815 return unbind_to (count, Qnil);
1816 /* Recheck modified. */
1817 modified = BUF_MODIFF (b) > BUF_SAVE_MODIFF (b);
1816 } 1818 }
1817 1819
1818 /* Delete the autosave file, if requested. */ 1820 /* Delete the autosave file, if requested. */
@@ -6474,5 +6476,7 @@ will run for `clone-indirect-buffer' calls as well. */);
6474 6476
6475 DEFSYM (Qautosaved, "autosaved"); 6477 DEFSYM (Qautosaved, "autosaved");
6476 6478
6479 DEFSYM (Qkill_buffer__possibly_save, "kill-buffer--possibly-save");
6480
6477 Fput (intern_c_string ("erase-buffer"), Qdisabled, Qt); 6481 Fput (intern_c_string ("erase-buffer"), Qdisabled, Qt);
6478} 6482}