【问题标题】:Smarter `ff-find-other-file`更智能的`ff-find-other-file`
【发布时间】:2014-05-14 16:51:41
【问题描述】:

我正在开发一个项目,其中源代码组织在以下目录结构中:

./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/)的文件上使用ff-find-other-file 时,一切正常。但是我不知道如何配置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 sn-p/package 可以提供解决方案?

【问题讨论】:

    标签: emacs elisp


    【解决方案1】:

    评论很全面,我认为:

    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 的用法(在库中定义为参考)。

    【讨论】:

    • 不知何故我错过了这个......我使用一个/多个通配符让它工作。但是,这可能会增加搜索时间,因为它必须搜索所有子目录。
    猜你喜欢
    • 2013-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-09
    • 1970-01-01
    • 2013-01-02
    相关资源
    最近更新 更多