all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michal Nazarewicz <mina86@mina86.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>,
	Juanma Barranquero <lekktu@gmail.com>
Cc: Martin Rudalics <rudalics@gmx.at>, emacs-devel@gnu.org
Subject: [PATCH 1/3] `kill-buffer' runs query functions before checking buffer modification.
Date: Fri, 21 Jun 2013 14:16:41 +0200	[thread overview]
Message-ID: <1ff58f747b3be99b515bdb0462e88ced3c80d92d.1371816337.git.mina86@mina86.com> (raw)
In-Reply-To: <cover.1371816337.git.mina86@mina86.com>
In-Reply-To: <cover.1371816337.git.mina86@mina86.com>

* 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 4e52f5b..059c1d9 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
+2013-06-21  Michal Nazarewicz  <mina86@mina86.com>
+
+	* 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-20  Paul Eggert  <eggert@cs.ucla.edu>
 
 	* syntax.c: Integer cleanups.
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	other threads:[~2013-06-21 12:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-21 12:16 [PATCHv3 0/3] Add `notes' function, take three Michal Nazarewicz
2013-06-21 12:16 ` Michal Nazarewicz [this message]
2013-06-21 12:16 ` [PATCH 2/3] `remember-append-to-file' appending to buffer bug fix Michal Nazarewicz
2013-06-21 12:16 ` [PATCH 3/3] Add `notes' function to store random notes across Emacs restarts Michal Nazarewicz
2013-06-21 15:21 ` [PATCHv3 0/3] Add `notes' function, take three Stefan Monnier
2013-06-21 17:13   ` Michal Nazarewicz
2013-06-21 19:14     ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1ff58f747b3be99b515bdb0462e88ced3c80d92d.1371816337.git.mina86@mina86.com \
    --to=mina86@mina86.com \
    --cc=emacs-devel@gnu.org \
    --cc=lekktu@gmail.com \
    --cc=monnier@iro.umontreal.ca \
    --cc=rudalics@gmx.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.