Question "kill-buffer"
Gary Sabot
gary at sabot.com
Thu Feb 15 16:09:43 CET 2001
To: r.e.darnell at ncl.ac.uk (R.E. Darnell)
Cc: ess-help at stat.math.ethz.ch
Subject: Re: Question "kill-buffer"
From: rossini at blindglobe.net (A.J. Rossini)
Date: 15 Feb 2001 06:42:46 -0800
>>>>> "RED" == R E Darnell <r.e.darnell at ncl.ac.uk> writes:
RED> Would introducing a "Are you sure?" question after kill the
RED> *R* ( or whatever) buffer with a hasty C-x k be a popular
RED> default "feature". How can I include this for my own use?
Can I suggest that you generally DON'T kill the buffer? (I'm not sure
what the rationale for killing it is?)
(if we can't work around a usage issue, I'll look at how you might
change it -- probably re-defining a system function to query, or maybe
even something like:
(defun ajr:kill-buffer ()
"AJR: Prevent self-stupidity."
(interactive)
(if (yes-or-no-p "Do you really but really want to kill a buffer ")
(kill-buffer)))
(global-set-key "\C-x k" 'ajr:kill-buffer)
This doesn't do the right thing, but it's close. Probably, you want a
(second? only?) question asking which buffer to kill, and pass that to
kill-buffer.
At least with XEmacs, 'kill-buffer' is a primitive (C implemented)
function, and not readily available.
best,
-tony
Perhaps this will help: Here is what I have been doing for my emacs
for a few years now. It double checks on the killing of any buffer
with an attached process, i.e. *S*, *shell*, *telnet*, etc:
(defun my-kill-buffer (buf)
(interactive "bKill buffer: ")
(setq buf (get-buffer buf)) ; make arg be buffer, not string
(if (or
(not (get-buffer-process buf))
(memq (process-status (get-buffer-process buf)) '(signal exit))
(string-equal "tail" (substring
(process-name (get-buffer-process (current-buffer)))
0 4))
(yes-or-no-p "Buffer has an active process; kill anyway? "))
(kill-buffer buf)))
(global-set-key "\C-xk" 'my-kill-buffer)
--gary
P.S. I also have a filter on the comint-input-filter-functions list that
looks for q(), and intercepts it and asks you to stop and do it
properly (and doing it properly means C-c C-q and automatically writes
out the comint command history ring. But that is probably overkill!
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
ess-help mailing list -- To (un)subscribe, send
subscribe or unsubscribe
(in the "body", not the subject !) To: ess-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the ESS-help
mailing list