首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >更聪明的-找到-其他-文件‘

更聪明的-找到-其他-文件‘
EN

Stack Overflow用户
提问于 2014-05-14 16:51:41
回答 1查看 875关注 0票数 1

我正在进行一个项目,该项目将源代码组织在以下目录结构中:

代码语言:javascript
复制
./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/)都包含实现文件。

当对驻留在“顶层”(即在./source/include/或./source/src/中)的文件使用./source/include时,一切都很好。但是,我不知道如何配置ff-search-directories以深入搜索并返回到目录树中。

关于SO (emacs ff-find-other-file and ff-search-directories isn't recursive)已经有一个问题,但它不能解决我的问题,因为这只适用于静态设置。

理想的解决方案应该是这样的(伪regexp解决方案,其中DIR_REGEXP匹配所有可能的目录名):

代码语言:javascript
复制
"../\(DIR_REGEXP\)/include/\1/"
"../\(DIR_REGEXP\)/\(DIR_REGEXP\)/include/\1/\2/"

有没有任何可以提供解决方案的elisp片段/包?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-05-14 18:55:34

评论相当全面,我认为:

M-x find-library RET find-file RET

给出的ff-search-directories示例如下:

代码语言:javascript
复制
;; 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的用法(它在库中定义为引用)。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23660637

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档