如果我标记了多个文件,如何在emacs中查找/访问所有这些标记文件,除了dired-find-file
在每个文件上运行?
是否有内置命令,还是需要一些额外的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提供了许多扩展,包括选择多个文件和查找/查看所有文件的功能.