emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCHv4 1/4] `kill-buffer' runs query functions before checking buffer


From: Michal Nazarewicz
Subject: [PATCHv4 1/4] `kill-buffer' runs query functions before checking buffer modification.
Date: Mon, 24 Jun 2013 14:35:45 +0200

* buffer.c (FKill_buffer): Run `kill-buffer-query-functions'
before checking whether buffer is modified.  This lets
`kill-buffer-query-functions' cancel killing of the buffer or save
its content before `kill-buffer' asks user the "Buffer %s
modified; kill anyway?" question.
---
 src/ChangeLog |  8 ++++++++
 src/buffer.c  | 24 ++++++++++++------------
 2 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 6357491..50802fc 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
+2013-06-24  Michal Nazarewicz  <address@hidden>
+
+       * buffer.c (FKill_buffer): Run `kill-buffer-query-functions'
+       before checking whether buffer is modified.  This lets
+       `kill-buffer-query-functions' cancel killing of the buffer or save
+       its content before `kill-buffer' asks user the "Buffer %s
+       modified; kill anyway?" question.
+
 2013-06-23  Paul Eggert  <address@hidden>
 
        A more-conservative workaround for Cygwin SIGCHLD issues (Bug#14569).
diff --git a/src/buffer.c b/src/buffer.c
index 08299da..066b31d 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1734,18 +1734,6 @@ cleaning up all windows currently displaying the buffer 
to be killed. */)
   if (!BUFFER_LIVE_P (b))
     return Qnil;
 
-  /* Query if the buffer is still modified.  */
-  if (INTERACTIVE && !NILP (BVAR (b, filename))
-      && BUF_MODIFF (b) > BUF_SAVE_MODIFF (b))
-    {
-      GCPRO1 (buffer);
-      tem = do_yes_or_no_p (format2 ("Buffer %s modified; kill anyway? ",
-                                    BVAR (b, name), make_number (0)));
-      UNGCPRO;
-      if (NILP (tem))
-       return Qnil;
-    }
-
   /* Run hooks with the buffer to be killed the current buffer.  */
   {
     ptrdiff_t count = SPECPDL_INDEX ();
@@ -1761,6 +1749,18 @@ cleaning up all windows currently displaying the buffer 
to be killed. */)
     if (NILP (tem))
       return unbind_to (count, Qnil);
 
+    /* Query if the buffer is still modified.  */
+    if (INTERACTIVE && !NILP (BVAR (b, filename))
+       && BUF_MODIFF (b) > BUF_SAVE_MODIFF (b))
+      {
+        GCPRO1 (buffer);
+        tem = do_yes_or_no_p (format2 ("Buffer %s modified; kill anyway? ",
+                                      BVAR (b, name), make_number (0)));
+       UNGCPRO;
+       if (NILP (tem))
+         return unbind_to (count, Qnil);
+      }
+
     /* Then run the hooks.  */
     Frun_hooks (1, &Qkill_buffer_hook);
     unbind_to (count, Qnil);
-- 
1.8.3.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]