2010-03-02 41 views
8

有沒有辦法使dired在單個窗口中操作,以便當我遍歷目錄時,我沒有n個針對中間目錄的dired緩衝區?然而 - 如果我在完全獨立的目錄中啓動另一個dired緩衝區(從minibuffer而不是在已打開的dired實例的子目錄中輸入[enter]),我想保留兩個獨立的dired緩衝區...我想我我使用ido-dired,因爲我有ido模式,但我不知道解決方案會有所不同?非常感謝!直接模式單窗口? (emacs)

+0

對不起大家,我事先做過Google,我保證!沒有意識到答案無處不在。但感謝所有的迴應! – hatmatrix

+0

Duplicate question:http://stackoverflow.com/questions/1839313/how-do-i-stop-emacs-dired-mode-from-opening-so-many-buffers/1839493 – scottfrazer

回答

17

我通過敲擊降低dired-buffer雜波dired-find-alternate-file)上的子目錄,而不是RET;回收當前直接窗口。

11

http://www.emacswiki.org/emacs/dired-single.el

;;; dired-single.el --- Reuse the current dired buffer to visit another directory... 

;;; Commentary: 
;; 
;; This package provides a way to reuse the current dired buffer to visit 
;; another directory (rather than creating a new buffer for the new directory). 
;; Optionally, it allows the user to specify a name that all such buffers will 
;; have, regardless of the directory they point to... 
1

喜歡這個?

(defadvice dired-find-file (around kill-old-buffer activate) 
    "When navigate from one dired buffer to another, kill the old one." 
    (let ((old-buffer (current-buffer)) 
      (new-buffer (dired-get-filename))) 
     ad-do-it 
     (kill-buffer old-buffer) 
     (switch-to-buffer new-buffer) 
)) 
1

如果你主要是想和那都是下一個層次結構(例如,一個用於每幾個正在進行的項目dired緩衝)各子目錄每個dired緩衝區的工作,你可以使用內置的i可能插入子目錄)和kdired-do-kill-lines在插入子目錄的標題上將其從緩衝區中刪除)命令。他們將允許您在單個dired緩衝區內編輯多個目錄。如果你的肌肉記憶太深入,你可能需要一個小的自定義命令並重新映射。