emacs - 如何使子目录中的查找文件搜索 [英] emacs - how to make find-file search in subdirectories
问题描述
我想实现像Emacs那样的Resharper的Go To File功能。当您按下提到的快捷方式时,Resharper会弹出一个接受通配符字符串的文本框,并显示一个自动填充菜单,其中列出项目中与该通配符相匹配的所有文件:
I'd like to implement something like Resharper's "Go To File" feature for Emacs. When one presses mentioned shortcut, Resharper pops a text box that accepts a wildcard string and displays an autocompletion menu that lists all files in a project that match that wildcard:
转到文件对话http://www.jetbrains.com/resharper/features/screenshots/50/navigation_gotofile.png
现在,我知道一个粗暴的方法实现一些或多或少相同的东西。它涉及使用 -lR
运行 dired
,然后调用 dired-isearch-filenames
- 将在某个根目录下的文件的整个层次结构上开始增量搜索。
For now, I know a crude way to achieve something more or less equivalent. It involves running dired
with -lR
and then invoking dired-isearch-filenames
- that will start incremental search over the entire hierarchy of files inside certain root directory.
upd。我也知道可以打开缓冲区的负载,将它们全部保存在内存中,并使用 switch-to-buffer
。这个解决方案可以很好地与 ido
一起工作,尽管它不是100%防弹(如果有些文件被添加或删除了?它也不适用于 tabbar
,因为选项卡将显示项目中包含的所有文件,而不是表示我当前上下文的项目的子集。
upd. I'm also aware about the option of opening loads of buffers, keeping them all in memory and using switch-to-buffer
. This solution works nicely with ido
, though it isn't 100% bullet-proof (what if some files get added or deleted?). It also doesn't play well with tabbar
, since tabs will display all the files that are included in the project, but not a subset of the project that represents my current context.
但是,这显示了大量不必要的信息,并且缺少自动完成。我看了一下 ido
和冰柱
,但是它们似乎只是在当前目录中。有没有Emacs插件可以帮助我实现我的目标?
However, this shows lots of unnecessary information and lacks autocompletion. I've taken a look at ido
and icicles
, but they seem to work shallowly, only within current directory. Is there a Emacs plugin that will help me to achieve my goal?
推荐答案
尽管你可能不想保持大量的缓冲区您可以将IDO挂钩到 recentf
中,跟踪最近打开的文件:
Although you might not want to keep lots of buffers open, you can hook IDO into recentf
, which tracks recently-opened files:
(recentf-mode 1)
(setq recentf-max-saved-items 300)
(defun ido-choose-from-recentf ()
"Use ido to select a recently opened file from the `recentf-list'"
(interactive)
(find-file (ido-completing-read "Open file: " recentf-list nil t)))
(global-set-key [(meta f11)] 'ido-choose-from-recentf)
我一直在使用这个技巧,这是我需要的所有文件切换的99%。
I've been using this trick for years, and it's 99% of all the file-switching I need.
除此之外,我使用 Mx rgrep
,您可能还要查看 Mx find-dired
和 Mx find-grep dired
。
Beyond that, I use M-x rgrep
, and you might also like to look at M-x find-dired
and M-x find-grep-dired
.
有关更多选项,请查看这个类似的问题。
For more options still, check out the answers to this similar question.
这篇关于emacs - 如何使子目录中的查找文件搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!