我知道M-x可怕,但想要自定义它。我想点击一个键(例如F2)并打开直接缓冲区。当我浏览目录层次结构时,它不应该打开新的缓冲区。
当我最终打开文件时,它也不应该为它打开新的缓冲区(不是绝对必要,但非常需要)。
当然,这种行为可以是全局的,即对于所有可靠的缓冲区/调用。
答案 0 :(得分:4)
查看dired-single,这几乎可以满足您的需求(除了最后一位,它为重新访问的文件重用了dired缓冲区)。
Caveat Lector:我写了它,所以我偏向于它的用处。
答案 1 :(得分:1)
一些替代方案 - EmacsWiki: DiredReuseDirectoryBuffer和this short snippet来自格式不合时宜的博客条目。
警告:我自己没试过。答案 2 :(得分:1)
我知道这已经很老了,但你所要做的就是在目录或文件上按'a'来获得此功能。它已经存在了。
答案 3 :(得分:0)
这是我最终使用的内容:
(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))))