help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Browsing into Subdirectory in Dired in the Same Buffer


From: Lave
Subject: Re: Browsing into Subdirectory in Dired in the Same Buffer
Date: Wed, 29 Oct 2008 21:48:23 +0800

It's nice. I copied it, thanks.

But, I used to 'v' to view a directory, and 'q' buried it, then I can
see the previous again, although there are too many buffers. Is there
a method to go back the previous viewed directory?

On 10/29/08, Tassilo Horn <tassilo@member.fsf.org> wrote:
> "stephan.zimmer" <stephan.zimmer@googlemail.com> writes:
>
> Hi!
>
>> When browsing into a subdirectory in dired a new dired buffer is
>> opened. Is there an easy way to avoid this, i.e., to let the new
>> directory be opened in the same buffer?
>
> Yeah, use `dired-find-alternate-file'.  This will reuse the current
> buffer.  Of course, when using that on a file you'll end up with no
> dired buffer at all.
>
> Here's my local hack to make RET reusing the current dired buffer if I'm
> hitting RET on a directory or else create a new buffer.
>
> --8<---------------cut here---------------start------------->8---
> (put 'dired-find-alternate-file 'disabled nil)
>
> (defun th-dired-up-directory ()
>   "Go up one directory and don't create a new dired buffer but
> reuse the current one."
>   (interactive)
>   (find-alternate-file ".."))
>
> (defun th-dired-find-file ()
>   "Find directory reusing the current buffer and file creating a
> new buffer."
>   (interactive)
>   (if (file-directory-p (dired-get-file-for-visit))
>       (dired-find-alternate-file)
>     (dired-find-file)))
>
> (defun th-dired-mode-init ()
>   (local-set-key (kbd "^")       'th-dired-up-directory)
>   (local-set-key (kbd "RET")     'th-dired-find-file))
>
> (add-hook 'dired-mode-hook 'th-dired-mode-init)
> --8<---------------cut here---------------end--------------->8---
>
> Hope that helps,
> Tassilo
> --
> Chuck Norris has 12 moons. One of those moons is the Earth.
>
>
>
>


-- 
Regards,
Lave




reply via email to

[Prev in Thread] Current Thread [Next in Thread]