如何在Emacs Dired快速上传文件? [英] How to go to a file quickly in Emacs Dired?

查看:107
本文介绍了如何在Emacs Dired快速上传文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果一个目录包含很多文件,而我想转到名称以字母(或字符串)开头的文件(或子目录),那么有什么好办法吗?我知道在远程文件管理器中,人们可以按Alt并开始输入名称,光标将在您输入时移动,我想知道Emacs是否有类似的东西。

解决方案

回答这个问题的最快方法是从emacs信息文件中复制一个部分。
要获取此文本类型 Ch d m emacs ret ,然后 isearch 为适当的子字符串忽略第一个失败的I-search 或者直接转到 Ch i 的信息,然后直接转到 g 下面提到的信息节点,然后键入节点名字后跟 ret



第一个来自info-node (emacs)Dired and Find 工作是否在一个可怕的缓冲区中:

 要搜索名称匹配通配符模式的文件使用` Mx 
find-name-dired'。它读取参数DIRECTORY和PATTERN,
选择DIRECTORY或其
个人名称与PATTERN匹配的子目录中的所有文件。

第二个来自info-node (emacs)Dired Navigation 在dired缓冲区中工作,但仅适用于当前列出的文件。但是,请注意,您可以列出 i 之前的子目录。

 `f C-s' (`dired-isearch-filenames')在Dired缓冲区中执行前向
增量搜索,只在文件名中查找匹配
,忽略缓冲区中的其余文本。
`M-s f M-C-s'(`dired-isearch-filenames-regexp')执行相同的操作,使用
正则表达式搜索。如果您将变量
`dired-isearch-filenames'更改为t,则通常的搜索命令
将自己限制在文件名中;例如,`C-s'表现得像
`M-s f C-s'。如果值为dwim,则搜索命令只有在起始位于文件名时才匹配
文件名。 *注意
搜索::,有关增量搜索的信息。

编辑:
要递归搜索目录,您可以先递归地列出它。 >

您可以使用prefix-arg调用 dired 递归地列出子目录,并添加 R 到开关列表。



以下为emacs初始化文件的片段甚至可以简化此任务:

 (defun dired-noselect-maybe-recursive(dir-or-list&可选开关)
喜欢`dired-noselect',但列出子目录最后一个字符是?/。
(if(and(null switches))
(=(aref dir-or-list(1-(length dir-or-list))?
(dired-noselect dir-or-list-alR)
(dired-noselect dir-or-list switches)
))

(setq find -directory-functions(subst'dired-noselect-maybe-recursive'dired-noselect find-directory-functions)

如果您使用此代码段,您可以获得正常的目录列表对于最后没有斜杠的目录的ind-file( C-x C-f ),如果最后用斜线调用它,您将获得一个递归列表。
但要小心递归目录列表可以花费时间。如果紧张,可以随时使用 C-g 退出。


If a directory contains many files and I want to go to files(or subdirectories) with name starting with a letter (or a string), is there any good way to do it? I know in Far File Manager people can press Alt and start typing the name and the cursor will move as you type, I am wondering if Emacs has something similar.

解决方案

The fastest way to answer this question is copying a section from the emacs info files. To get to this text type C-h i d m emacs ret and then isearch for an appropriate substring ignoring the first Failing I-search or just go to info with C-h i and then directly go to the info node mentioned below with g and then typing the node name followed by ret.

The first from the info-node (emacs) Dired and Find works whether one is in a dired buffer or not:

   To search for files with names matching a wildcard pattern use `M-x
find-name-dired'.  It reads arguments DIRECTORY and PATTERN, and
chooses all the files in DIRECTORY or its subdirectories whose
individual names match PATTERN.

The second from the info-node (emacs) Dired Navigation works in dired buffers but only applies to the currently listed files. But, note that you can list subdirectories with i before.

   `M-s f C-s' (`dired-isearch-filenames') performs a forward
incremental search in the Dired buffer, looking for matches only
amongst the file names and ignoring the rest of the text in the buffer.
`M-s f M-C-s' (`dired-isearch-filenames-regexp') does the same, using a
regular expression search.  If you change the variable
`dired-isearch-filenames' to `t', then the usual search commands also
limit themselves to the file names; for instance, `C-s' behaves like
`M-s f C-s'.  If the value is `dwim', then search commands match the
file names only when point was on a file name initially.  *Note
Search::, for information about incremental search.

EDIT: To isearch a directory recursively you may first list it recursively.

You can list sub-directories recursively by calling dired with prefix-arg and adding R to the list of switches.

The following snippet for the emacs initialization file would even simplify this task:

(defun dired-noselect-maybe-recursive (dir-or-list &optional switches)
  "Like `dired-noselect' but lists sub-directories when last character is ?/."
  (if (and (null switches)
       (= (aref dir-or-list (1- (length dir-or-list))) ?/))
      (dired-noselect dir-or-list "-alR")
    (dired-noselect dir-or-list switches)
    ))

(setq find-directory-functions (subst 'dired-noselect-maybe-recursive 'dired-noselect find-directory-functions))

With this snippet you get a normal listing of directories if you call find-file (C-x C-f) for a directory without a slash at the end and you get a recursive listing if you call it with a slash at the end. But be careful. Recursive directory listing can take its time. If you get nervous you can always quit with C-g.

这篇关于如何在Emacs Dired快速上传文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆