From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.help Subject: RE: Remove all directory listings buffers Date: Sat, 28 Nov 2009 11:46:55 -0800 Message-ID: References: <26511405.post@talk.nabble.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1259437728 494 80.91.229.12 (28 Nov 2009 19:48:48 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 28 Nov 2009 19:48:48 +0000 (UTC) To: "'andrea'" , Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Nov 28 20:48:41 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NETHd-0008Er-DM for geh-help-gnu-emacs@m.gmane.org; Sat, 28 Nov 2009 20:48:41 +0100 Original-Received: from localhost ([127.0.0.1]:48464 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NETHd-00036u-09 for geh-help-gnu-emacs@m.gmane.org; Sat, 28 Nov 2009 14:48:41 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NETHF-00035y-Ce for help-gnu-emacs@gnu.org; Sat, 28 Nov 2009 14:48:17 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NETHA-00033B-AQ for help-gnu-emacs@gnu.org; Sat, 28 Nov 2009 14:48:16 -0500 Original-Received: from [199.232.76.173] (port=56471 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NETHA-000333-3J for help-gnu-emacs@gnu.org; Sat, 28 Nov 2009 14:48:12 -0500 Original-Received: from rcsinet12.oracle.com ([148.87.113.124]:49538 helo=rgminet12.oracle.com) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NETH9-0003OL-Pc for help-gnu-emacs@gnu.org; Sat, 28 Nov 2009 14:48:11 -0500 Original-Received: from rgminet15.oracle.com (rcsinet15.oracle.com [148.87.113.117]) by rgminet12.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id nASJm1h4031009 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 28 Nov 2009 19:48:02 GMT Original-Received: from acsmt355.oracle.com (acsmt355.oracle.com [141.146.40.155]) by rgminet15.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id nAR8VIb0010637; Sat, 28 Nov 2009 19:48:11 GMT Original-Received: from abhmt015.oracle.com by acsmt357.oracle.com with ESMTP id 660733731259437588; Sat, 28 Nov 2009 13:46:28 -0600 Original-Received: from dradamslap1 (/24.5.185.59) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 28 Nov 2009 11:46:27 -0800 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 Thread-Index: AcpwWvAJPIlpE3j6TgytBJsloqvmXwABn14g X-Source-IP: acsmt355.oracle.com [141.146.40.155] X-Auth-Type: Internal IP X-CT-RefId: str=0001.0A090202.4B117E76.000D:SCFMA4539814,ss=1,fgs=0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 1) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:70215 Archived-At: > 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