changeset 103970:340cbf291f8a

(process-kill-buffer-query-function): New function. (add-hook)<kill-buffer-query-functions>: Add hook `process-kill-buffer-query-function'.
author Juri Linkov <juri@jurta.org>
date Sat, 18 Jul 2009 21:05:47 +0000
parents 5d9efafcafb1
children bb9b3a319d64
files lisp/subr.el
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/subr.el	Sat Jul 18 21:04:39 2009 +0000
+++ b/lisp/subr.el	Sat Jul 18 21:05:47 2009 +0000
@@ -1722,6 +1722,16 @@
     (set-process-query-on-exit-flag process nil)
     old))
 
+(defun process-kill-buffer-query-function ()
+  "Ask before killing a buffer that has a running process."
+  (let ((process (get-buffer-process (current-buffer))))
+    (or (not process)
+        (not (memq (process-status process) '(run stop open listen)))
+        (not (process-query-on-exit-flag process))
+        (yes-or-no-p "Buffer has a running process; kill it? "))))
+
+(add-hook 'kill-buffer-query-functions 'process-kill-buffer-query-function)
+
 ;; process plist management
 
 (defun process-get (process propname)