From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Yoni Rabkin Newsgroups: gmane.emacs.help Subject: Re: Keep dired from creating new buffers. Date: Fri, 12 Dec 2003 21:44:39 +0200 Organization: NTT/Verio Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1071259744 23938 80.91.224.253 (12 Dec 2003 20:09:04 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 12 Dec 2003 20:09:04 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Dec 12 21:09:01 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AUtau-0006Dj-00 for ; Fri, 12 Dec 2003 21:09:00 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AUuUZ-0005h3-L1 for geh-help-gnu-emacs@m.gmane.org; Fri, 12 Dec 2003 16:06:31 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!newsfeed.berkeley.edu!ucberkeley!sjc-peer.news.verio.net!news.verio.net!dfw-read.news.verio.net.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux) Cancel-Lock: sha1:sTVhC/NFZu+3WQRlSq+IaUzoZEU= X-NNTP-Posting-Host: line134-129.adsl.actcom.co.il Original-Lines: 31 Original-NNTP-Posting-Host: 192.114.47.10 Original-X-Complaints-To: abuse@verio.net Original-X-Trace: dfw-read.news.verio.net 1071258257 192.114.47.10 (Fri, 12 Dec 2003 19:44:17 GMT) Original-NNTP-Posting-Date: Fri, 12 Dec 2003 19:44:17 GMT Original-Xref: shelby.stanford.edu gnu.emacs.help:119270 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:15210 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:15210 Copied verbatim from http://www.emacswiki.org/cgi-bin/wiki.pl/DiredMode: Here's the code to make dired use only one buffer: (eval-after-load "dired" '(progn (defadvice dired-advertised-find-file (around dired-subst-directory activate) "Replace current buffer if file is a directory." (interactive) (let* ((orig (current-buffer)) (filename (dired-get-filename)) (bye-p (file-directory-p filename))) ad-do-it (when (and bye-p (not (string-match "[/\\\\]\\.$" filename))) (kill-buffer orig)))))) And here is another way for achieving this: ;; we want dired not not make always a new buffer if visiting a directory ;; but using only one dired buffer for all directories. (defadvice dired-advertised-find-file (around dired-subst-directory activate) "Replace current buffer if file is a directory." (interactive) (let ((orig (current-buffer)) (filename (dired-get-filename))) ad-do-it (when (and (file-directory-p filename) (not (eq (current-buffer) orig))) (kill-buffer orig))))