From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.bugs Subject: bug#11665: kill-buffer gives an error on killing dead buffers Date: Sun, 10 Jun 2012 19:49:29 +0200 Message-ID: <4FD4DE29.9040207@gmx.at> References: <87r4tn4eoi.fsf@gmail.com> <4FD49946.2040402@gmx.at> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------010303080202030903070507" X-Trace: dough.gmane.org 1339350579 18431 80.91.229.3 (10 Jun 2012 17:49:39 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 10 Jun 2012 17:49:39 +0000 (UTC) Cc: 11665@debbugs.gnu.org To: Vitalie Spinu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jun 10 19:49:38 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1SdmGf-0002jq-Gg for geb-bug-gnu-emacs@m.gmane.org; Sun, 10 Jun 2012 19:49:37 +0200 Original-Received: from localhost ([::1]:40439 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SdmGf-0005M9-A0 for geb-bug-gnu-emacs@m.gmane.org; Sun, 10 Jun 2012 13:49:37 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:43946) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SdmGb-0005KZ-J3 for bug-gnu-emacs@gnu.org; Sun, 10 Jun 2012 13:49:34 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SdmGZ-0005MR-O8 for bug-gnu-emacs@gnu.org; Sun, 10 Jun 2012 13:49:33 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:55595) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SdmGZ-0005MG-KI for bug-gnu-emacs@gnu.org; Sun, 10 Jun 2012 13:49:31 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1SdmJ0-0004II-Fm for bug-gnu-emacs@gnu.org; Sun, 10 Jun 2012 13:52:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: martin rudalics Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 10 Jun 2012 17:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11665 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 11665-submit@debbugs.gnu.org id=B11665.133935069816477 (code B ref 11665); Sun, 10 Jun 2012 17:52:02 +0000 Original-Received: (at 11665) by debbugs.gnu.org; 10 Jun 2012 17:51:38 +0000 Original-Received: from localhost ([127.0.0.1]:36908 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SdmIb-0004Hh-Ni for submit@debbugs.gnu.org; Sun, 10 Jun 2012 13:51:38 -0400 Original-Received: from mailout-de.gmx.net ([213.165.64.23]:50460) by debbugs.gnu.org with smtp (Exim 4.72) (envelope-from ) id 1SdmIZ-0004HZ-0o for 11665@debbugs.gnu.org; Sun, 10 Jun 2012 13:51:36 -0400 Original-Received: (qmail invoked by alias); 10 Jun 2012 17:49:01 -0000 Original-Received: from 62-47-53-240.adsl.highway.telekom.at (EHLO [62.47.53.240]) [62.47.53.240] by mail.gmx.net (mp017) with SMTP; 10 Jun 2012 19:49:01 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX1/v44dFELPvV16T66guJ2SqFOWoXruCLPRjcBQ/2e +pvt4IKRnkOYCv In-Reply-To: <4FD49946.2040402@gmx.at> X-Y-GMX-Trusted: 0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:60844 Archived-At: This is a multi-part message in MIME format. --------------010303080202030903070507 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit There seem more occasions where this problem could strike. Also, we should return t when we find out that the buffer name has been reset to nil under our feet. Patch attached, comments welcome. martin --------------010303080202030903070507 Content-Type: text/plain; name="buffer.c.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="buffer.c.diff" *** src/buffer.c 2012-05-29 16:13:38 +0000 --- src/buffer.c 2012-06-10 17:33:15 +0000 *************** *** 1493,1498 **** --- 1493,1502 ---- unbind_to (count, Qnil); } + /* If the hooks have killed the buffer, exit now. */ + if (NILP (BVAR (b, name))) + return Qt; + /* We have no more questions to ask. Verify that it is valid to kill the buffer. This must be done after the questions since anything can happen within do_yes_or_no_p. */ *************** *** 1501,1509 **** if (EQ (buffer, XWINDOW (minibuf_window)->buffer)) return Qnil; - if (NILP (BVAR (b, name))) - return Qnil; - /* When we kill a base buffer, kill all its indirect buffers. We do it at this stage so nothing terrible happens if they ask questions or their hooks get errors. */ --- 1505,1510 ---- *************** *** 1526,1540 **** UNGCPRO; } /* Run replace_buffer_in_windows before making another buffer current since set-window-buffer-start-and-point will refuse to make another buffer current if the selected window does not show the current buffer. (Bug#10114) */ replace_buffer_in_windows (buffer); ! /* Make this buffer not be current. ! In the process, notice if this is the sole visible buffer ! and give up if so. */ if (b == current_buffer) { tem = Fother_buffer (buffer, Qnil, Qnil); --- 1527,1549 ---- UNGCPRO; } + /* If killing the indirect buffers has killed our buffer, return. */ + if (NILP (BVAR (b, name))) + return Qt; + /* Run replace_buffer_in_windows before making another buffer current since set-window-buffer-start-and-point will refuse to make another buffer current if the selected window does not show the current buffer. (Bug#10114) */ replace_buffer_in_windows (buffer); ! /* If replacing the buffer in windows has killed our buffer, ! return. */ ! if (NILP (BVAR (b, name))) ! return Qt; ! ! /* Make this buffer not be current. In the process, notice if this is ! the sole visible buffer and give up if so. */ if (b == current_buffer) { tem = Fother_buffer (buffer, Qnil, Qnil); *************** *** 1564,1574 **** kill_buffer_processes (buffer); UNGCPRO; ! /* Killing buffer processes may run sentinels which may ! have called kill-buffer. */ ! if (NILP (BVAR (b, name))) ! return Qnil; /* These may run Lisp code and into infinite loops (if someone insisted on circular lists) so allow quitting here. */ --- 1573,1582 ---- kill_buffer_processes (buffer); UNGCPRO; ! /* Killing buffer processes may run sentinels which may have called ! kill-buffer. */ if (NILP (BVAR (b, name))) ! return Qt; /* These may run Lisp code and into infinite loops (if someone insisted on circular lists) so allow quitting here. */ *************** *** 1599,1604 **** --- 1607,1616 ---- internal_delete_file (BVAR (b, auto_save_file_name)); } + /* Deleting a file could have killed our buffer. */ + if (NILP (BVAR (b, name))) + return Qt; + if (b->base_buffer) { /* Unchain all markers that belong to this indirect buffer. --------------010303080202030903070507--