本文介绍了emacs ff-find-other-file找不到我的标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不知怎的,我无法使emacs' ff-find-other-file 来获取我的头文件。这是我有的(最小例子):

  cd〜/ tmp 
mkdir test
cd test
mkdir -p src / a / b inc / a / b
echoaaaa> src / a / b / a.cpp
echobbbb> inc / a / b / a.hpp
tree

给出:

 
├──inc
│└──a
│└──b
│└──a.hpp
└──src
└ ──a
└──b
└──a.cpp

这与我的项目结构类似。






  emacs -Q src / a / b / a.cpp 

然后在 * scratch * 并执行它与 Cx Ce

 (setq cc-search-directories'(。../inc../inc/*../../inc/*../../../inc/* / usr / include))

并运行 ff-find-other-文件在缓冲区 a.cpp 中,仅在minibuffer中提示:

请注意,如果从 ff-search-directories 的帮助中引用该引号,而我修改的列表是 cc-search-directories 。我不明白为什么这会有所作为。



这个和其他线程使我相信 * 将递归搜索目录树。错误?

解决方案

* 表示其父级的每个直接子目录;



评论的措辞稍微更清楚:

ie对于这个具体的例子,我会期望../../../ inc / * / b工作。或者确实../../../ inc / * / *(正如你最终使用的那样)。



另请参阅,并特别注意到您可以定义函数来动态生成目标文件路径。



我怀疑你想要 a / b 根据原始路径确定,所以返回相应路径到另一个文件的功能将是您最好的解决方案。


Somehow I can't make emacs' ff-find-other-file to get my header file. Here is what I have (minimal example):

cd ~/tmp
mkdir test
cd test
mkdir -p src/a/b inc/a/b
echo "aaaa" > src/a/b/a.cpp
echo "bbbb" > inc/a/b/a.hpp
tree

gives:

.
├── inc
│   └── a
│       └── b
│           └── a.hpp
└── src
    └── a
        └── b
            └── a.cpp

This is similar to my project structure.


emacs -Q src/a/b/a.cpp

Then copying this in *scratch* and executing it with C-x C-e:

(setq cc-search-directories '("." "../inc" "../inc/*" "../../inc/*" "../../../inc/*" "/usr/include"))

and running ff-find-other-file in buffer a.cpp, only results in a prompt in the minibuffer:

C-h v on ff-search-directories returns cc-search-directories, and on cc-search-directories I get the list above.

I expect ff-find-other-file to look in ../../../inc/*, and find a.hpp. Why doesn't it?


Edit: it seems to be the recursive part that doesn't work here.

After:

cp inc/a/b/a.hpp inc/

a.hpp is found from a.cpp.

The help about ff-search-directories says:

Note that this quote if from the help for ff-search-directories, while the list I modified is cc-search-directories. I can't see why that would make a difference though.

This and other threads on SO made me believe * would recursively search the directory tree. Wrong?

解决方案

* represents every immediate sub-directory of its parent; nothing more.

The commentary has it worded slightly more clearly:

i.e. For this specific example I would expect "../../../inc/*/b" to work. Or indeed "../../../inc/*/*" (as you've ended up using).

See also https://stackoverflow.com/a/23662870/324105 and note in particular that you can define functions to dynamically generate the target file path(s).

I suspect you want the a/b to be determined based on the original path, so a function to return the appropriate path to the other file would be your best solution here.

这篇关于emacs ff-find-other-file找不到我的标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 05:33