更聪明的`ff-find-other-file` [英] Smarter `ff-find-other-file`
问题描述
./ source / include
./source/include/analysis
./source/include/tools
./source/include/utils
./source/include/utils/stream
./source/include/utils/string
[...]
./source/src
./source/ src / analysis
./source/src/tools
./source/src/utils
./source/src/utils/stream
./source/src/utils/ string
[...]
每个子目录 / source / include /
(包括 ./ source / include /
)包含头文件。同样, ./ source / src /
(包括 ./ source / src /
)中的每个子目录都包含实现文件。 / p>
在驻留在顶级的文件中使用 ff-find-other-file
./ source / include
/或 ./ source / src /
)一切正常。然而,我无法弄清楚如何配置 ff-search-directories
来更深入地搜索目录树。
SO已经有一个问题( emacs ff-find-other-file和ff-search-directories不是递归的),但是它不能解决我的问题,因为这只能用静态设置。
一个理想的解决方案是这样的(伪正则表达式解决方案,其中 DIR_REGEXP
匹配所有可能的目录名称):
../ \(DIR_REGEXP\)/ include / \1 /
../ \(DIR_REGEXP\)/ \(DIR_REGEXP\)/ include / \1 / \2 /
有没有可以提供解决方案的elisp snippet / package?
评论是相当全面,我想:
Mx find-library RET find-file RET
为 ff-search-directories
提供的示例是:
;; SEARCHING在
;;指定的一组目录中执行。 ff-search-directories变量:
;;
;; (。../../src../include/*/ usr / local / * / src / *$ PROJECT / src)
;;
;;这意味着首先在
;;中搜索相应的文件。当前目录,然后在../../src中,然后在其中一个目录
;;下../include,等等。明星是_not_一个通配符
;;字符:它只是表示这个目录的子目录
;;必须依次搜索。环境变量将在
;;中扩展ff-search-directories变量。
如果不够, ff-other-file-alist
可以包含可以动态地返回由相应文件的可能名称组成的列表的函数符号。请参阅 ff-cc-hh-converter
(在库中定义为参考)的用法。
I'm working on a project where the source is organised in the following directory structe:
./source/include
./source/include/analysis
./source/include/tools
./source/include/utils
./source/include/utils/stream
./source/include/utils/string
[...]
./source/src
./source/src/analysis
./source/src/tools
./source/src/utils
./source/src/utils/stream
./source/src/utils/string
[...]
Where each subdirectory of ./source/include/
(including ./source/include/
) contains header files. Similarly every subdir of ./source/src/
(including ./source/src/
) contains implementation files.
When using ff-find-other-file
on files which reside at the "top-level" (i.e. in ./source/include
/ or ./source/src/
) everything works fine. However I can't figure out how one can configure ff-search-directories
to search deeper up and back into the directory tree.
There's already a question on SO (emacs ff-find-other-file and ff-search-directories isn't recursive) but it does not solve my problem since this works only with a static setup.
An ideal solution would be something like this (pseudo-regexp solution, where DIR_REGEXP
matches all possible directory names):
"../\(DIR_REGEXP\)/include/\1/"
"../\(DIR_REGEXP\)/\(DIR_REGEXP\)/include/\1/\2/"
Is there any elisp snippet/package out there which can provide a solution?
The commentary is pretty comprehensive, I think:
M-x find-library RET find-file RET
The example given for ff-search-directories
is:
;; SEARCHING is carried out in a set of directories specified by the
;; ff-search-directories variable:
;;
;; ("." "../../src" "../include/*" "/usr/local/*/src/*" "$PROJECT/src")
;;
;; This means that the corresponding file will be searched for first in
;; the current directory, then in ../../src, then in one of the directories
;; under ../include, and so on. The star is _not_ a general wildcard
;; character: it just indicates that the subdirectories of this directory
;; must each be searched in turn. Environment variables will be expanded in
;; the ff-search-directories variable.
If that's insufficient, ff-other-file-alist
can contain function symbols which can act dynamically to "return a list consisting of the possible names of the corresponding file". See the usage of ff-cc-hh-converter
(which is defined in the library as a reference).
这篇关于更聪明的`ff-find-other-file`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!