如果我标记了多个文件,除了dired-find-file
在每个文件上运行之外,如何在 emacs 中查找/访问所有这些标记的文件?
是否有内置命令,或者我需要一些额外的 lisp 代码?
在 Emacs 23.2 及更高版本中,该dired-x.el
模块可用,它使您可以访问完全符合您要求的命令。加载它后((load "dired-x")
通常只是),您将能够调用该函数dired-do-find-marked-files
。这是它的内置文档:
(dired-do-find-marked-files &optional NOSELECT)
Find all marked files displaying all of them simultaneously.
With optional NOSELECT just find files but do not select them.
The current window is split across all files marked, as evenly as possible.
Remaining lines go to bottom-most window. The number of files that can be
displayed this way is restricted by the height of the current window and
`window-min-height'.
To keep dired buffer displayed, type C-x 2 first.
To display just marked files, type C-x 1 first.
因此,dired-x
加载后,您可以直接使用M-x dired-do-find-marked-files
RET,您将得到您的问题所要求的内容:所有标记的文件都将被访问,就像您dired-find-file
在所有这些文件上运行一样。
如果你将它添加到你的 .emacs 中,你将能够通过键绑定“F”打开文件。
(eval-after-load "dired"
'(progn
(define-key dired-mode-map "F" 'my-dired-find-file)
(defun my-dired-find-file (&optional arg)
"Open each of the marked files, or the file under the point, or when prefix arg, the next N files "
(interactive "P")
(let* ((fn-list (dired-get-marked-files nil arg)))
(mapc 'find-file fn-list)))))
显然,您可以根据需要覆盖内置的“f”。
您可以尝试dired+,它为 dired 提供了许多扩展,包括选择多个文件并查找/查看所有文件的能力。