From: "Drew Adams" <drew.adams@oracle.com>
To: "'andrea'" <andrea.crotti.0@gmail.com>, <help-gnu-emacs@gnu.org>
Subject: RE: Remove all directory listings buffers
Date: Sat, 28 Nov 2009 11:46:55 -0800 [thread overview]
Message-ID: <B399B46BB59D473281A63AEE926ACD0E@us.oracle.com> (raw)
In-Reply-To: <m13a3yqyqw.fsf@47-116.eduroam.rwth-aachen.de>
> But I also always end up having too many buffers, I need a better
> strategy for killing them when I don't need them anymore..
I think some people are in the habit of using `C-x 0' to remove the current
window, even when they no longer need the window's buffer.
Why? Because they don't want some other buffer taking its place (if they were to
use `C-x k' instead). IOW, what they really want is both `C-x k' and `C-x 0',
but that is too much to type each time they just want to get something out of
the way.
I use this as a replacement for `kill-buffer' interactively (only):
(defun kill-buffer-and-its-windows (buffer)
"Kill BUFFER and delete its windows.
Default is `current-buffer'.
BUFFER can be either a buffer or its name (a string)."
(interactive
(list (read-buffer "Kill buffer: "
(current-buffer) 'existing)))
(setq buffer (get-buffer buffer))
(cond ((buffer-live-p buffer)
(let ((wins (get-buffer-window-list buffer nil t)))
(when (kill-buffer buffer)
(dolist (win wins)
(when (window-live-p win)
(delete-window win))))))
((interactive-p)
(error
"Cannot kill buffer. Not a live buffer: `%s'"
buffer))))
;; This points all keys and menus that would normally use
;; `kill-buffer' to `kill-buffer-and-its-windows' instead.
(substitute-key-definition
'kill-buffer 'kill-buffer-and-its-windows global-map)
And I'm in the habit of using `C-x k' when I'm through with a buffer and its
window. I use `C-x 0' only when I explicitly want to keep the buffer around.
FWIW, this code is in library misc-cmds.el (and setup-keys.el for the key
mapping).
http://www.emacswiki.org/emacs/misc-cmds.el
http://www.emacswiki.org/emacs/setup-keys.el
next prev parent reply other threads:[~2009-11-28 19:46 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-25 11:55 Remove all directory listings buffers rotlas
2009-11-28 18:40 ` andrea
2009-11-28 19:46 ` Drew Adams [this message]
2009-11-28 22:43 ` Andreas Politz
2009-11-29 2:41 ` Drew Adams
2009-11-29 2:55 ` Drew Adams
2009-12-02 8:23 ` Andreas Politz
[not found] ` <mailman.11729.1259433914.2239.help-gnu-emacs@gnu.org>
2009-11-29 16:17 ` Colin S. Miller
[not found] <mailman.11453.1259150170.2239.help-gnu-emacs@gnu.org>
2009-11-25 12:13 ` Pascal J. Bourguignon
2009-11-25 13:09 ` Thierry Volpiatto
2009-11-25 13:20 ` aartist
2009-11-25 14:13 ` Andreas Politz
[not found] ` <mailman.11468.1259158466.2239.help-gnu-emacs@gnu.org>
2009-12-01 18:14 ` Dmitry Dzhus
2009-12-04 21:25 ` B. T. Raven
2009-12-05 7:37 ` Andreas Politz
2009-11-26 21:37 ` Tim X
2009-11-25 14:16 ` harven
2009-11-25 14:23 ` Colin S. Miller
2009-11-26 1:13 ` David Hodge
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=B399B46BB59D473281A63AEE926ACD0E@us.oracle.com \
--to=drew.adams@oracle.com \
--cc=andrea.crotti.0@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.