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

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

Re: [h-e-w] dired in same buffer?


From: Jerome BESNARD
Subject: Re: [h-e-w] dired in same buffer?
Date: 20 Dec 2001 16:39:17 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1

I have this snippet (stolen somewhere and modified a little) in my .emacs:

;;;
(defadvice dired-up-directory (around  kill-last-buffer())
  "Kill last dired buffer when upping directories (unless upping is 
impossible...)"
  (let ((last-dired-buffer (current-buffer)))
        ad-do-it
        (let ((current-dired-buffer (current-buffer)))
          (if (not (eq current-dired-buffer last-dired-buffer))
                  (kill-buffer last-dired-buffer)))))
(ad-activate 'dired-up-directory)

(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
        ;;  directory's contents
        (if (file-directory-p filename)
                (find-alternate-file filename)
          ;; otherwise simply perform a normal `dired-find-file'
          (dired-find-file))))
;;;

And you have to redefine the keys associated with the 'traversal'. For me it's
like:

;;;
(defun jer-dired-mode-hook ()
  (local-set-key        "\C-m"          'dired-follow-file)
  (local-set-key        "e"                     'dired-follow-file)
  (local-set-key        "f"                     'dired-follow-file)
  (local-set-key        [left]          'dired-up-directory)
  (local-set-key        [right]         'dired-follow-file)
  )
;;;

Surely, advices could be even better...

-- 
Jerome BESNARD - Tél : (33) 1 56 43 18 36
------------------------------
Miriad Technologies - 8, avenue Hoche 75008 Paris
Tél : (33) 1 56 43 18 00 - Fax : (33) 1 56 43 18 28
www.miriadtech.com 






reply via email to

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