From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michal Nazarewicz Newsgroups: gmane.emacs.devel Subject: [PATCHv4 1/4] `kill-buffer' runs query functions before checking buffer modification. Date: Mon, 24 Jun 2013 14:35:45 +0200 Message-ID: <1c8f2cfbb1b7a321184c6d840763f1c60bbfc95b.1372076606.git.mina86@mina86.com> References: NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1372077400 24101 80.91.229.3 (24 Jun 2013 12:36:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 24 Jun 2013 12:36:40 +0000 (UTC) Cc: martin rudalics , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jun 24 14:36:41 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Ur60d-0003X3-AD for ged-emacs-devel@m.gmane.org; Mon, 24 Jun 2013 14:36:39 +0200 Original-Received: from localhost ([::1]:36280 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ur60c-0000G9-P8 for ged-emacs-devel@m.gmane.org; Mon, 24 Jun 2013 08:36:38 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46478) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ur60R-0008Pf-Ft for emacs-devel@gnu.org; Mon, 24 Jun 2013 08:36:34 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ur60M-0004Xn-UX for emacs-devel@gnu.org; Mon, 24 Jun 2013 08:36:27 -0400 Original-Received: from mail-la0-x229.google.com ([2a00:1450:4010:c03::229]:41074) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ur60M-0004WH-Np for emacs-devel@gnu.org; Mon, 24 Jun 2013 08:36:22 -0400 Original-Received: by mail-la0-f41.google.com with SMTP id fn20so10387528lab.28 for ; Mon, 24 Jun 2013 05:36:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:in-reply-to:references; bh=SKbPLacDUUjPJ+QwX7zTKyLZG0J9vhMu+ogt5bbOptI=; b=bJLtg0RxlEu/IqmW9dZDvRb3Vlqn1w5NENpPo5EL7wVSqC+KMd1sW99kzEo7ENT6hH fJoSREpgFNee1g5l29BN3TdjfSGY2nP4KhDnFIf5Hnf9/wWngjOJldAaprKoFMDBAUjR LywnC9CLBA1Mw8Ci2f0qDvdnfcD6ZMF2SDxzK8V6PogOHWOwOlwsFoM8+UEVltYVtbJu QXUAZWbb722C1bCsib1OVP1kDN525WgwfeqmUc1R9mO2iyg9apOOmI7xIyM0PJJsGPqk Hvm9ZzI7M/TBIP6VFCWlMHg8oIUqVmRI7yoPtCIk0+LB1FvIiT/Ul/qBP6gqFvB0D5cU tY3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:in-reply-to:references:x-gm-message-state; bh=SKbPLacDUUjPJ+QwX7zTKyLZG0J9vhMu+ogt5bbOptI=; b=AxuPZOEkD3F0MlGduRCXRotewDcO4bR9D6Pl4jd54kw4NYIg7vae8hX82aCtbdzSJG 0FaKMfarjRUwkchaMfs6DXhM7LGFu9Jeywlt50RNs0Mo6PidHrByqcCFiefgPMv2im9g y/nhLDm+vFRiJ5fufmRMEz36YLNHdPSPrX1EDSrpBKi2ejBKSeGJdlU+C8TOA+3TN4XL 9TnJMjkpHiiR89zTx0bN42veX3Y+MG9RSbZyJBPW6rDdkjIpy3Jb7PQlmqzqCA3w0kZo ilmQxRtRGuroLxd33ajOHaKbKyDIlYGp9KAPsCkM92/0Vi6Sm+bCzxUk5/cIgBmmbUGJ 6LsA== X-Received: by 10.152.25.195 with SMTP id e3mr11320007lag.76.1372077381679; Mon, 24 Jun 2013 05:36:21 -0700 (PDT) Original-Received: from mpn-glaptop.corp.google.com ([2620:0:105f:301:2ddc:c978:be37:615e]) by mx.google.com with ESMTPSA id u1sm6672296lag.5.2013.06.24.05.36.20 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 24 Jun 2013 05:36:20 -0700 (PDT) X-Mailer: git-send-email 1.8.3.1 In-Reply-To: In-Reply-To: Original-References: X-Gm-Message-State: ALoCoQkpF3ZbrYudyrINEsdVXiGyZ7PltCjdEQe4BoLpWsQsY6hOF3eTWGNTeg/DDOibgm0kMuEJddG7tNlv238P/rkAvqy5HKx9c1b3UaO87zWa6RCzjaLGYHqLDj1i2mqKIsXMkWtISlkS/eaNeCHngtPLP231TEx3f/XjPnQA1CQyPE/3QcrulkINkV92kaSO5ngxDFUz X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::229 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:160931 Archived-At: * 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 + + * 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 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