我正在开发一个项目,其中源组织在以下目录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
[...]
./source/include/
的每个子目录(包括./source/include/
)都包含头文件。类似地,./source/src/
的每个子目录(包括./source/src/
)都包含实现文件。
对位于“顶级”(即ff-find-other-file
/或./source/include
)的文件使用./source/src/
时,一切正常。但是我无法弄清楚如何配置ff-search-directories
以更深入地搜索目录树。
关于SO(emacs ff-find-other-file and ff-search-directories isn't recursive)已经存在一个问题,但它并没有解决我的问题,因为这只适用于静态设置。
理想的解决方案是这样的(伪正则表达式解决方案,其中DIR_REGEXP
匹配所有可能的目录名称):
"../\(DIR_REGEXP\)/include/\1/"
"../\(DIR_REGEXP\)/\(DIR_REGEXP\)/include/\1/\2/"
有没有可以提供解决方案的elisp片段/包?
答案 0 :(得分:2)
我认为评论非常全面:
M-x find-library RET find-file RET
ff-search-directories
的示例是:
;; 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.
如果不够,ff-other-file-alist
可以包含可以动态行动的函数符号,并返回一个由相应文件的可能名称组成的列表"。请参阅ff-cc-hh-converter
的用法(在库中定义为参考)。