emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C-x C-v considered harmful


From: Juri Linkov
Subject: Re: C-x C-v considered harmful
Date: Fri, 17 Jul 2009 00:57:34 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (x86_64-pc-linux-gnu)

> Looking again at `find-alternate-file' convinces me that the right
> solution is to use the `kill-buffer-query-functions' hook.

I found a better place for this piece of code.  subr.el has a special
section "Process stuff".

Also the docstring of `set-process-query-on-exit-flag' should be
modified to mention its effect on buffer killing.

Index: lisp/subr.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/subr.el,v
retrieving revision 1.641
diff -c -r1.641 subr.el
*** lisp/subr.el        14 Jul 2009 07:45:59 -0000      1.641
--- lisp/subr.el        16 Jul 2009 21:55:24 -0000
***************
*** 1722,1727 ****
--- 1722,1737 ----
      (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)

Index: src/process.c
===================================================================
RCS file: /sources/emacs/emacs/src/process.c,v
retrieving revision 1.589
diff -c -r1.589 process.c
*** src/process.c       28 Jun 2009 20:25:49 -0000      1.589
--- src/process.c       16 Jul 2009 21:55:57 -0000
***************
*** 1133,1139 ****
         2, 2, 0,
         doc: /* Specify if query is needed for PROCESS when Emacs is exited.
  If the second argument FLAG is non-nil, Emacs will query the user before
! exiting if PROCESS is running.  */)
       (process, flag)
       register Lisp_Object process, flag;
  {
--- 1133,1139 ----
         2, 2, 0,
         doc: /* Specify if query is needed for PROCESS when Emacs is exited.
  If the second argument FLAG is non-nil, Emacs will query the user before
! exiting or killing a buffer if PROCESS is running.  */)
       (process, flag)
       register Lisp_Object process, flag;
  {

-- 
Juri Linkov
http://www.jurta.org/emacs/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]