all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: Vitalie Spinu <spinuvit@gmail.com>
Cc: 11665@debbugs.gnu.org
Subject: bug#11665: kill-buffer gives an error on killing dead buffers
Date: Sun, 10 Jun 2012 19:49:29 +0200	[thread overview]
Message-ID: <4FD4DE29.9040207@gmx.at> (raw)
In-Reply-To: <4FD49946.2040402@gmx.at>

[-- Attachment #1: Type: text/plain, Size: 204 bytes --]

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

[-- Attachment #2: buffer.c.diff --]
[-- Type: text/plain, Size: 3296 bytes --]

*** 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.


  reply	other threads:[~2012-06-10 17:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-10 10:57 bug#11665: kill-buffer gives an error on killing dead buffers Vitalie Spinu
2012-06-10 12:55 ` martin rudalics
2012-06-10 17:49   ` martin rudalics [this message]
2012-06-18  7:24     ` martin rudalics

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=4FD4DE29.9040207@gmx.at \
    --to=rudalics@gmx.at \
    --cc=11665@debbugs.gnu.org \
    --cc=spinuvit@gmail.com \
    /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.