* Browsing into Subdirectory in Dired in the Same Buffer
@ 2008-10-29 8:46 stephan.zimmer
2008-10-29 11:17 ` Tassilo Horn
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: stephan.zimmer @ 2008-10-29 8:46 UTC (permalink / raw
To: help-gnu-emacs
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?
Stephan
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Browsing into Subdirectory in Dired in the Same Buffer
2008-10-29 8:46 Browsing into Subdirectory in Dired in the Same Buffer stephan.zimmer
@ 2008-10-29 11:17 ` Tassilo Horn
2008-10-29 11:40 ` Paul R
` (2 more replies)
2008-10-29 13:35 ` Drew Adams
2008-10-30 2:01 ` Joe Casadonte
2 siblings, 3 replies; 10+ messages in thread
From: Tassilo Horn @ 2008-10-29 11:17 UTC (permalink / raw
To: help-gnu-emacs
"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.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Browsing into Subdirectory in Dired in the Same Buffer
2008-10-29 11:17 ` Tassilo Horn
@ 2008-10-29 11:40 ` Paul R
2008-10-29 13:48 ` Lave
[not found] ` <mailman.2367.1225288108.25473.help-gnu-emacs@gnu.org>
2 siblings, 0 replies; 10+ messages in thread
From: Paul R @ 2008-10-29 11:40 UTC (permalink / raw
To: Tassilo Horn; +Cc: help-gnu-emacs
Tassilo> Here's my local hack to make RET reusing the current dired
Tassilo> buffer if I'm hitting RET on a directory or else create a new
Tassilo> buffer.
I think this behaviour is what most people expect, so it should be the
default. I'm not sure if it fits in current stabilisation phase of
emacs 23, but I'd like it to.
--
Paul
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: Browsing into Subdirectory in Dired in the Same Buffer
2008-10-29 8:46 Browsing into Subdirectory in Dired in the Same Buffer stephan.zimmer
2008-10-29 11:17 ` Tassilo Horn
@ 2008-10-29 13:35 ` Drew Adams
2008-10-30 2:01 ` Joe Casadonte
2 siblings, 0 replies; 10+ messages in thread
From: Drew Adams @ 2008-10-29 13:35 UTC (permalink / raw
To: 'stephan.zimmer', help-gnu-emacs
> 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?
`C-x C-v' is your friend, for both files and directories.
It is always the way to "open in the same buffer", if by that you mean replace
(kill) the original buffer.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Browsing into Subdirectory in Dired in the Same Buffer
2008-10-29 11:17 ` Tassilo Horn
2008-10-29 11:40 ` Paul R
@ 2008-10-29 13:48 ` Lave
2008-10-29 14:49 ` Tassilo Horn
[not found] ` <mailman.2367.1225288108.25473.help-gnu-emacs@gnu.org>
2 siblings, 1 reply; 10+ messages in thread
From: Lave @ 2008-10-29 13:48 UTC (permalink / raw
To: Tassilo Horn; +Cc: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Browsing into Subdirectory in Dired in the Same Buffer
[not found] ` <mailman.2367.1225288108.25473.help-gnu-emacs@gnu.org>
@ 2008-10-29 14:37 ` Xah
0 siblings, 0 replies; 10+ messages in thread
From: Xah @ 2008-10-29 14:37 UTC (permalink / raw
To: help-gnu-emacs
Thanks for the tip on dired-find-alternate-file. This is something
i've desired.
Now i put it into a hook:
(add-hook 'dired-mode-hook
(lambda ()
(define-key dired-mode-map (kbd "<return>") 'dired-find-alternate-
file) ; was dired-advertised-find-file
(define-key dired-mode-map (kbd "^") (lambda () (interactive) (find-
alternate-file ".."))) ; was dired-up-directory
))
On Oct 29, 6:48 am, Lave <lave.wan...@gmail.com> wrote:
> 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?
i think that having too many buffers is a usability problem. As far as
i know, many old emacs users typically adapted the habit of leaving
hundreds of buffers open.
The reason that people leave buffers open in emacs is because, in my
opinion, emacs lacks a easy way to close buffer. Specifically, the
command kill-buffer (Ctrl+x k) will prompt the user whether he wants
to kill for sure, even though the bufer is not modified. Then, there's
the menu command “Close”, which calls kill-this-buffer. But it doesn't
have a keyboard shortcut.
My own solution to this is to create a keyboard shortcut for Close,
when called, it prompt to save only if file is modified. This way, it
works around kill-buffer's extraneous prompting.
Related to this is that kill-buffer and kill-this-buffer both do not
prompt to save when the buffer is not associated with a file. This
easily cause data lose. So, i modified my close command so that it
will prompt to save if it is a buffer not associated with file but has
content.
Related is that, now you easily close a buffer, but when you close
one, often the one shown is one of the emacs's buffers (e.g.
*Messages*, shell output, comman completion, lossage, info, man page,
dictionary lookup, word spelling suggestions, etc those starting with
“*”. A user can easily have tens of these buffers after a day's use of
emacs.) Typically user don't care about these buffers after having
viewed them once. So, i think it's beffer that the next buffer shown
after a Close buffer call should be one of user's buffers.
i have implemented the above code here:
http://xahlee.org/emacs/ergonomic_emacs_keybinding.html
Xah
∑ http://xahlee.org/
☄
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Browsing into Subdirectory in Dired in the Same Buffer
2008-10-29 13:48 ` Lave
@ 2008-10-29 14:49 ` Tassilo Horn
2008-10-29 15:03 ` Paul R
0 siblings, 1 reply; 10+ messages in thread
From: Tassilo Horn @ 2008-10-29 14:49 UTC (permalink / raw
To: Lave; +Cc: help-gnu-emacs
Lave <lave.wang.w@gmail.com> writes:
Hi!
> 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?
In my code I use `^' to go up one directory. Or can there be a
difference between the previous and the parent directory?
Bye,
Tassilo
--
* delYsid has mortgage, opportunity and penis in his score file.
<delYsid> thats pretty effective against spam
<Luke> aren't you worried about missing opportunities to mortgage
your penis?
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Browsing into Subdirectory in Dired in the Same Buffer
2008-10-29 14:49 ` Tassilo Horn
@ 2008-10-29 15:03 ` Paul R
2008-10-29 23:01 ` Lave
0 siblings, 1 reply; 10+ messages in thread
From: Paul R @ 2008-10-29 15:03 UTC (permalink / raw
To: Tassilo Horn; +Cc: help-gnu-emacs
On Wed, 29 Oct 2008 15:49:09 +0100, Tassilo Horn <tassilo@member.fsf.org> said:
Tassilo> Or can there be a difference between the previous and the
Tassilo> parent directory?
I guess immediatly after pressing '^', previous directory is not
parent directory :)
--
Paul
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Browsing into Subdirectory in Dired in the Same Buffer
2008-10-29 15:03 ` Paul R
@ 2008-10-29 23:01 ` Lave
0 siblings, 0 replies; 10+ messages in thread
From: Lave @ 2008-10-29 23:01 UTC (permalink / raw
To: Paul R; +Cc: Tassilo Horn, help-gnu-emacs
Previous is dynamic, not always the up directory. But forget about it
please. I will get used to '^' and 'v', thanks.
On 10/29/08, Paul R <paul.r.ml@gmail.com> wrote:
> On Wed, 29 Oct 2008 15:49:09 +0100, Tassilo Horn <tassilo@member.fsf.org>
> said:
>
> Tassilo> Or can there be a difference between the previous and the
> Tassilo> parent directory?
>
> I guess immediatly after pressing '^', previous directory is not
> parent directory :)
>
> --
> Paul
>
--
Regards,
Lave
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Browsing into Subdirectory in Dired in the Same Buffer
2008-10-29 8:46 Browsing into Subdirectory in Dired in the Same Buffer stephan.zimmer
2008-10-29 11:17 ` Tassilo Horn
2008-10-29 13:35 ` Drew Adams
@ 2008-10-30 2:01 ` Joe Casadonte
2 siblings, 0 replies; 10+ messages in thread
From: Joe Casadonte @ 2008-10-30 2:01 UTC (permalink / raw
To: help-gnu-emacs
On 29 Oct 2008, stephan zimmer wrote:
> 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?
I wrote dired-single for this very purpose. You can find it here:
http://www.northbound-train.com/emacs/dired-single.el
Let me know if you have any problems with it.
--
Regards,
joe
Joe Casadonte
jcasadonte@northbound-train.com
------------------------------------------------------------------------------
Llama Fresh Farms => http://www.northbound-train.com
Ramblings of a Gay Man => http://www.northbound-train.com/ramblings
Emacs Stuff => http://www.northbound-train.com/emacs.html
Music CD Trading => http://www.northbound-train.com/cdr.html
------------------------------------------------------------------------------
Live Free, that's the message!
------------------------------------------------------------------------------
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2008-10-30 2:01 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-29 8:46 Browsing into Subdirectory in Dired in the Same Buffer stephan.zimmer
2008-10-29 11:17 ` Tassilo Horn
2008-10-29 11:40 ` Paul R
2008-10-29 13:48 ` Lave
2008-10-29 14:49 ` Tassilo Horn
2008-10-29 15:03 ` Paul R
2008-10-29 23:01 ` Lave
[not found] ` <mailman.2367.1225288108.25473.help-gnu-emacs@gnu.org>
2008-10-29 14:37 ` Xah
2008-10-29 13:35 ` Drew Adams
2008-10-30 2:01 ` Joe Casadonte
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.