tags:

views:

231

answers:

3

I know about M-x dire, but would like to customize it. I would like to hit one key (for example F2) and get dire buffer open. When I navigate across the directory hierarchy it shouldn't open new buffers.

And when I finally open the file it also shouldn't open new buffer for it (not strictly necessary, but strongly preferred).

Of course this behavior can be global, i.e. for all dire buffers/invocations.

+3  A: 

Check out dired-single, which pretty much does what you want (except that last bit, where it reuses the dired buffer for the newly visted file).

Caveat Lector: I wrote it, so I'm biased towards its usefulness.

Joe Casadonte
No bias here, and I think dired-single.el is awesome. I've been using it for a while and it's exactly what I needed when I first looked it up.(No idea how it compares to :Texplore since I've never really used vim.)
felideon
+1  A: 

Some alternatives - EmacsWiki: DiredReuseDirectoryBuffer, and this short snippet from an awkwardly-formatted blog-entry.

caveat: haven't tried them, myself.

Michael Paulukonis
A: 

Here's what I finally used:

(require 'dired)
(global-set-key [(f2)] 'my-dired)
(defun my-dired ()
  (interactive)
  (dired (file-name-directory (buffer-file-name))))
(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 :no-error-if-not-filep t)))
  ad-do-it
  (when (not (eq (current-buffer) orig)) (kill-buffer orig))))
phjr