aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c49
1 files changed, 29 insertions, 20 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 7e4c84911bb..7ba0c8bc2a6 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1768,6 +1768,7 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1768 /* Run hooks with the buffer to be killed as the current buffer. */ 1768 /* Run hooks with the buffer to be killed as the current buffer. */
1769 { 1769 {
1770 ptrdiff_t count = SPECPDL_INDEX (); 1770 ptrdiff_t count = SPECPDL_INDEX ();
1771 bool modified;
1771 1772
1772 record_unwind_protect_excursion (); 1773 record_unwind_protect_excursion ();
1773 set_buffer_internal (b); 1774 set_buffer_internal (b);
@@ -1782,9 +1783,12 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1782 return unbind_to (count, Qnil); 1783 return unbind_to (count, Qnil);
1783 } 1784 }
1784 1785
1786 /* Is this a modified buffer that's visiting a file? */
1787 modified = !NILP (BVAR (b, filename))
1788 && BUF_MODIFF (b) > BUF_SAVE_MODIFF (b);
1789
1785 /* Query if the buffer is still modified. */ 1790 /* Query if the buffer is still modified. */
1786 if (INTERACTIVE && !NILP (BVAR (b, filename)) 1791 if (INTERACTIVE && modified)
1787 && BUF_MODIFF (b) > BUF_SAVE_MODIFF (b))
1788 { 1792 {
1789 AUTO_STRING (format, "Buffer %s modified; kill anyway? "); 1793 AUTO_STRING (format, "Buffer %s modified; kill anyway? ");
1790 tem = do_yes_or_no_p (CALLN (Fformat, format, BVAR (b, name))); 1794 tem = do_yes_or_no_p (CALLN (Fformat, format, BVAR (b, name)));
@@ -1792,6 +1796,17 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1792 return unbind_to (count, Qnil); 1796 return unbind_to (count, Qnil);
1793 } 1797 }
1794 1798
1799 /* Delete the autosave file, if requested. */
1800 if (modified
1801 && kill_buffer_delete_auto_save_files
1802 && delete_auto_save_files
1803 && !NILP (Frecent_auto_save_p ()))
1804 {
1805 tem = do_yes_or_no_p (build_string ("Delete auto-save file? "));
1806 if (!NILP (tem))
1807 call0 (intern ("delete-auto-save-file-if-necessary"));
1808 }
1809
1795 /* If the hooks have killed the buffer, exit now. */ 1810 /* If the hooks have killed the buffer, exit now. */
1796 if (!BUFFER_LIVE_P (b)) 1811 if (!BUFFER_LIVE_P (b))
1797 return unbind_to (count, Qt); 1812 return unbind_to (count, Qt);
@@ -1888,24 +1903,6 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1888 replace_buffer_in_windows_safely (buffer); 1903 replace_buffer_in_windows_safely (buffer);
1889 Vinhibit_quit = tem; 1904 Vinhibit_quit = tem;
1890 1905
1891 /* Delete any auto-save file, if we saved it in this session.
1892 But not if the buffer is modified. */
1893 if (STRINGP (BVAR (b, auto_save_file_name))
1894 && BUF_AUTOSAVE_MODIFF (b) != 0
1895 && BUF_SAVE_MODIFF (b) < BUF_AUTOSAVE_MODIFF (b)
1896 && BUF_SAVE_MODIFF (b) < BUF_MODIFF (b)
1897 && NILP (Fsymbol_value (intern ("auto-save-visited-file-name"))))
1898 {
1899 Lisp_Object delete;
1900 delete = Fsymbol_value (intern ("delete-auto-save-files"));
1901 if (! NILP (delete))
1902 internal_delete_file (BVAR (b, auto_save_file_name));
1903 }
1904
1905 /* Deleting an auto-save file could have killed our buffer. */
1906 if (!BUFFER_LIVE_P (b))
1907 return Qt;
1908
1909 if (b->base_buffer) 1906 if (b->base_buffer)
1910 { 1907 {
1911 INTERVAL i; 1908 INTERVAL i;
@@ -6366,6 +6363,18 @@ nil NORECORD argument since it may lead to infinite recursion. */);
6366 Vbuffer_list_update_hook = Qnil; 6363 Vbuffer_list_update_hook = Qnil;
6367 DEFSYM (Qbuffer_list_update_hook, "buffer-list-update-hook"); 6364 DEFSYM (Qbuffer_list_update_hook, "buffer-list-update-hook");
6368 6365
6366 DEFVAR_BOOL ("kill-buffer-delete-auto-save-files",
6367 kill_buffer_delete_auto_save_files,
6368 doc: /* If non-nil, offer to delete any autosave file when killing a buffer.
6369
6370If `delete-auto-save-files' is nil, any autosave deletion is inhibited. */);
6371 kill_buffer_delete_auto_save_files = 0;
6372
6373 DEFVAR_BOOL ("delete-auto-save-files", delete_auto_save_files,
6374 doc: /* Non-nil means delete auto-save file when a buffer is saved.
6375This is the default. If nil, auto-save file deletion is inhibited. */);
6376 delete_auto_save_files = 1;
6377
6369 defsubr (&Sbuffer_live_p); 6378 defsubr (&Sbuffer_live_p);
6370 defsubr (&Sbuffer_list); 6379 defsubr (&Sbuffer_list);
6371 defsubr (&Sget_buffer); 6380 defsubr (&Sget_buffer);