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

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

Re: Buffers in Dired


From: Friedrich Dominicus
Subject: Re: Buffers in Dired
Date: 02 Jun 2003 07:28:58 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Native Windows TTY Support)

Kaustuv <kaustuv@stanford.edu> writes:

> Hi all,
>    I am using dired to navigate through the files of my home. But the
>    problem is the moment i move to a subdirectory dired creates a new
>    buffer for it. So ultimetly it turns out i have just too many buffers
>    open if i am locating a file buried deep my home directory sturcture.
>    Is there some configuration variable which shall tell it not to create 
>    all these buffers but to work only from one buffer. In short all i want
>    is JUST ONE buffer for all my navigation.
> Regards,

Someone here posted this code some years? ago

;;;; dired improvements reuse existing buffer instead of generating every-time
;;;; a new one

(require 'dired)
(defun dired-follow-file ()
  "In dired, visit the file or directory on this line.
If a directory is on the current line, replace the current
dired buffer with one containing the contents of the directory.
Otherwise, invoke `dired-find-file' on the file."
  (interactive)
  (let ((filename (dired-get-filename)))
    ;; if the file is a directory, replace the buffer with the
    ;;  directories contents
    (if (file-directory-p filename)
        (find-alternate-file filename)
      ;; otherwise simply perform a normal `dired-find-file'
      (dired-find-file))))       


with this hooks.

;;;; dired improvement
(add-hook
 'dired-mode-hook
 (lambda ()
   (local-set-key [return] 'dired-follow-file)
   (local-set-key [ e ] 'dired-follow-file)
   (local-set-key [ v ] 'dired-follow-file)
   (local-set-key [ f ] 'dired-follow-file)))

Use it to your liking.

Regards
Friedrich


reply via email to

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