]> git.eshelyaron.com Git - emacs.git/commitdiff
don't let kill-buffer kill a buffer if it is current in any thread
authorTom Tromey <tromey@redhat.com>
Mon, 18 Mar 2013 14:48:53 +0000 (08:48 -0600)
committerTom Tromey <tromey@redhat.com>
Mon, 18 Mar 2013 14:48:53 +0000 (08:48 -0600)
src/buffer.c
src/thread.c
src/thread.h

index 4d24f9707922457b467b482985bd292884481574..b7b471d6d4625158c82fed27a5cd94027e8c69fd 100644 (file)
@@ -1726,6 +1726,9 @@ cleaning up all windows currently displaying the buffer to be killed. */)
   if (!BUFFER_LIVE_P (b))
     return Qnil;
 
+  if (thread_check_current_buffer (b))
+    return Qnil;
+
   /* Query if the buffer is still modified.  */
   if (INTERACTIVE && !NILP (BVAR (b, filename))
       && BUF_MODIFF (b) > BUF_SAVE_MODIFF (b))
index 551f3de10e45202a31662e9d7476ceda89b8da09..7de260ee3c0329d9ce71a2f422237ec51ae29eb4 100644 (file)
@@ -881,6 +881,25 @@ DEFUN ("all-threads", Fall_threads, Sall_threads, 0, 0, 0,
 
 \f
 
+int
+thread_check_current_buffer (struct buffer *buffer)
+{
+  struct thread_state *iter;
+
+  for (iter = all_threads; iter; iter = iter->next_thread)
+    {
+      if (iter == current_thread)
+       continue;
+
+      if (iter->m_current_buffer == buffer)
+       return 1;
+    }
+
+  return 0;
+}
+
+\f
+
 static void
 init_primary_thread (void)
 {
index 97bdb2c805cdad795ed8100c3b3ae2601e8aff6a..47fa87c77fa8ab70f6ed6f226ac0e3180cbe4cba 100644 (file)
@@ -248,4 +248,6 @@ int thread_select  (select_func *func, int max_fds, SELECT_TYPE *rfds,
                    SELECT_TYPE *wfds, SELECT_TYPE *efds, EMACS_TIME *timeout,
                    sigset_t *sigmask);
 
+int thread_check_current_buffer (struct buffer *);
+
 #endif /* THREAD_H */