当前位置:  开发笔记 > 编程语言 > 正文

在Emacs dired中,如何查找/访问多个文件?

如何解决《在Emacsdired中,如何查找/访问多个文件?》经验,为你挑选了3个好方法。

如果我标记了多个文件,如何在emacs中查找/访问所有这些标记文件,除了dired-find-file在每个文件上运行?

是否有内置命令,还是需要一些额外的lisp代码?



1> xwl..:

在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在所有这些文件上运行一样.


'F'键是dired-do-find-marked-files的键盘快捷键,至少在Emacs 24.4中是这样.

2> Trey Jackson..:

如果将其添加到.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'.


谢谢你!小风格点,但在这种情况下你不需要使用`let*`(`let`就足够了).实际上我们可能只是将最后一种形式简化为`(mapc'find-file(dired-get-marked-files nil arg))`.

3> luapyad..:

您可以尝试dired +,它为dired提供了许多扩展,包括选择多个文件和查找/查看所有文件的功能.

推荐阅读
重庆制造漫画社
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有