[Top][All Lists]
[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: |
Mon, 13 Jul 2009 23:05:18 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (x86_64-pc-linux-gnu) |
> The variable `kill-buffer-query-functions' is nil by default,
> so maybe it's better to implement this confirmation in Fkill_buffer
> instead of the hook `kill-buffer-query-functions'?
Looking again at `find-alternate-file' convinces me that the right
solution is to use the `kill-buffer-query-functions' hook.
`find-alternate-file' explicitly runs this hook as:
(run-hook-with-args-until-failure 'kill-buffer-query-functions)
and binds it to nil around killing the buffer to not ask again:
(let ((kill-buffer-query-functions))
(kill-buffer obuf))
So there is no good way to prevent asking a confirmation about a running
process in Fkill_buffer.
Asking a confirmation about a modified file buffer could be moved to the
`kill-buffer-query-functions' hook as well because this will avoid
duplicating this question in `find-alternate-file'. But at least now
I propose to add a process confirmation to `kill-buffer-query-functions':
Index: lisp/files.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/files.el,v
retrieving revision 1.1055
diff -u -r1.1055 files.el
--- lisp/files.el 5 Jul 2009 22:15:37 -0000 1.1055
+++ lisp/files.el 13 Jul 2009 20:03:47 -0000
@@ -1441,6 +1441,16 @@
(other-window 1)
(find-alternate-file filename wildcards))))
+(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)
+
(defun find-alternate-file (filename &optional wildcards)
"Find file FILENAME, select its buffer, kill previous buffer.
If the current buffer now contains an empty file that you just visited
--
Juri Linkov
http://www.jurta.org/emacs/
- Re: C-x C-v considered harmful, (continued)
- Re: C-x C-v considered harmful, Juri Linkov, 2009/07/06
- RE: C-x C-v considered harmful, Drew Adams, 2009/07/06
- Re: C-x C-v considered harmful, Juri Linkov, 2009/07/07
- Re: C-x C-v considered harmful, Juri Linkov, 2009/07/08
- RE: C-x C-v considered harmful, Drew Adams, 2009/07/09
- Re: C-x C-v considered harmful, Juri Linkov, 2009/07/09
- RE: C-x C-v considered harmful, Drew Adams, 2009/07/09
- Re: C-x C-v considered harmful, Juri Linkov, 2009/07/09
- RE: C-x C-v considered harmful, Drew Adams, 2009/07/09
- RE: C-x C-v considered harmful, Bob Rogers, 2009/07/10
- Re: C-x C-v considered harmful,
Juri Linkov <=
- Re: C-x C-v considered harmful, Juri Linkov, 2009/07/16
- Re: C-x C-v considered harmful, M Jared Finder, 2009/07/02
- Re: C-x C-v considered harmful, Miles Bader, 2009/07/02
- Re: C-x C-v considered harmful, Richard Stallman, 2009/07/03
- Re: C-x C-v considered harmful, Andreas Schwab, 2009/07/03
- Re: C-x C-v considered harmful, Miles Bader, 2009/07/03
- Re: C-x C-v considered harmful, Markus Triska, 2009/07/03
- Re: C-x C-v considered harmful, Stefan Monnier, 2009/07/05
- Re: C-x C-v considered harmful, Bob Rogers, 2009/07/05
- Re: C-x C-v considered harmful, Stefan Monnier, 2009/07/11