aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
authorDmitry Gutov2025-08-09 22:40:07 +0300
committerDmitry Gutov2025-08-09 22:40:07 +0300
commit07eb39f1132ceb15e80e7912445890faa8f5b78c (patch)
treee6ab9c32a334fca746e68a9ac62728e312cfcd1c /src/buffer.c
parentc4af4b39018923fdfc22b515acc1f6ba3f2b024d (diff)
downloademacs-07eb39f1132ceb15e80e7912445890faa8f5b78c.tar.gz
emacs-07eb39f1132ceb15e80e7912445890faa8f5b78c.zip
Allow thread's buffer to be killed, by default
* src/thread.c (Fmake_thread): Add new argument (bug#76969). (thread_set_error): New function, extracted from thread-signal. (Fthread_buffer_disposition): Add getter. (Fthread_set_buffer_disposition): And setter. (thread_check_current_buffer): Check the values of threads' buffer_disposition. (thread_all_before_buffer_killed): New function. (init_threads): Set buffer_disposition to nil for the main thread. (syms_of_threads): Add new symbols and define the error. * src/thread.h (thread_state): New field buffer_disposition. (thread_all_before_buffer_killed): Declare. * src/buffer.c (Fkill_buffer): Call thread_check_current_buffer one more time after all hooks and after that call thread_all_before_buffer_killed. * src/comp.c (ABI_VERSION): Increase the value. * test/src/thread-tests.el (thread-buffer-disposition-t) (thread-buffer-disposition-nil) (thread-buffer-disposition-silently) (thread-set-buffer-disposition) (thread-set-buffer-disposition-main-thread): New tests. * doc/lispref/threads.texi (Basic Thread Functions): Document buffer-disposition in make-thread and its getter and setter. * etc/NEWS: Add entry.
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/buffer.c b/src/buffer.c
index a465153279d..e44b6daf587 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -2050,6 +2050,13 @@ cleaning up all windows currently displaying the buffer to be killed. */)
2050 return Qnil; 2050 return Qnil;
2051 } 2051 }
2052 2052
2053 /* Check all threads again, in case a hook changed something. */
2054 if (thread_check_current_buffer (b))
2055 return Qnil;
2056
2057 /* Clean up references to the buffer in threads. */
2058 thread_all_before_buffer_killed (buffer);
2059
2053 /* If the buffer now current is shown in the minibuffer and our buffer 2060 /* If the buffer now current is shown in the minibuffer and our buffer
2054 is the sole other buffer give up. */ 2061 is the sole other buffer give up. */
2055 XSETBUFFER (tem, current_buffer); 2062 XSETBUFFER (tem, current_buffer);