|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
| < Prev | 1 - 2 - 3 | Next > |
|
|
RE: C-x C-v considered harmful From: "Drew Adams" <drew.adams@...>
Date: Thu, 9 Jul 2009 16:21:49 -0700 > I have no opinion about a more general option. Nor I. Personally, I think I would be content if we added a query only for active process buffers. . . . FWIW, I've been taking advantage of `kill-buffer''s lack of query for process buffers as a _feature_, to avoid having to type `yes' (or is it `y'?) when I kill Emacs to confirm that I want to kill any active processes. I've gotten in the habit of using `C-x k' or `C-x C-v' when I'm through with a *shell* buffer, for instance. (Yes, I realize that's as much typing as `yes'/`y', but it somehow feels less annoying.) ;-) I just type "quit RET" to the shell. And if I'm in an SSH session with open tunneled connections, it won't exit immediately, so I'm reminded that I have other state to take care of before doing C-x C-c. -- Bob |
|
|
Re: C-x C-v considered harmful> I've just made C-x C-v obey confirm-nonexistent-file-or-buffer (as they
> should have from the beginning) which should fix the OP's problem. > I'm sorry, but you seem to have misunderstood: My problem with C-x C-v > is its behavior in killing buffers, not in how it finds files. (That is > why I did not respond to your earlier post; as one who has never > *deliberately* invoked C-x C-v, I have no opinion.) But it does fix the OP's particular case because the RET would have asked to "[Confirm]" since here was no "d" file (or directory). Stefan |
|
|
Re: C-x C-v considered harmful> 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 From: Stefan Monnier <monnier@...>
Date: Sat, 11 Jul 2009 06:06:40 -0400 > I've just made C-x C-v obey confirm-nonexistent-file-or-buffer (as they > should have from the beginning) which should fix the OP's problem. > I'm sorry, but you seem to have misunderstood: My problem with C-x C-v > is its behavior in killing buffers, not in how it finds files. (That is > why I did not respond to your earlier post; as one who has never > *deliberately* invoked C-x C-v, I have no opinion.) But it does fix the OP's particular case because the RET would have asked to "[Confirm]" since here was no "d" file (or directory). Stefan This did not occur to me. But I notice that typing "C-x C-v d RET" fails to require a "[Confirm]" if the value of confirm-nonexistent-file-or-buffer is after-completion. Since this is the default, that is no help for those who have not yet been bitten by this problem. (It would in fact have helped me, as the OP, because I do set confirm-nonexistent-file-or-buffer to t, but I have been flogging this thread in the hope of making Emacs friendlier by default.) It is also unlikely to help if you had meant to type "C-x C-f" instead of "C-x C-v"; both commands behave the same, regardless of the confirm-nonexistent-file-or-buffer setting, up until the point the previous buffer is killed. And it doesn't help at all with the fact that even "C-x k" is skimpy in the warning department. Are you rejecting Drew's argument that it is really kill-buffer that needs attention (at least when invoked interactively)? -- Bob |
|
|
Re: C-x C-v considered harmful> This did not occur to me. But I notice that typing "C-x C-v d RET"
> fails to require a "[Confirm]" if the value of > confirm-nonexistent-file-or-buffer is after-completion. Since this is Oops, indeed, I forgot about this "detail". Thanks for reminding me. > And it doesn't help at all with the fact that even "C-x k" is skimpy > in the warning department. Are you rejecting Drew's argument that it is > really kill-buffer that needs attention (at least when invoked > interactively)? I do not oppose the change to kill-buffer, no. I'm just happy that this thread pointed out the lack of support for confirm-nonexistent-file-or-buffer in C-x C-v (and did so before the release). Stefan |
|
|
Re: C-x C-v considered harmful> 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/ |
| < Prev | 1 - 2 - 3 | Next > |
| Free embeddable forum powered by Nabble | Forum Help |