emacs ff-find-other-file找不到我的标题 [英] emacs ff-find-other-file does not find my header
问题描述
不知怎的,我无法使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中提示:
查找或创建a.hpp:〜/ tmp / test / src / a / b /
cc-search-directories ,并在cc-search-directories
我得到上面的列表。
我希望
ff-find-other-file
查找../../../ inc / *
,并找到a.hpp
。为什么不这样?
编辑:似乎是递归部分
之后:
cp inc / a /b/a.hpp inc /
a.hpp
从a.cpp
中找到。
有关
ff-search的帮助说明:
星星是不通配符:他们被搜索加上
以前的斜线。该星代表除
`..'之外的所有子目录,这些子目录将依次搜索。
请注意,如果从
ff-search-directories
的帮助中引用该引号,而我修改的列表是cc-search-directories
。我不明白为什么这会有所作为。
这个和其他线程使我相信
*
将递归搜索目录树。错误?解决方案
*
表示其父级的每个直接子目录;
评论的措辞稍微更清楚:
明星是不是一般通配符:它只是表示这个目录的子目录必须依次搜索。
ie对于这个具体的例子,我会期望
../../../ inc / * / b
工作。或者确实../../../ inc / * / *
(正如你最终使用的那样)。
另请参阅 https://stackoverflow.com/a/23662870/324105 ,并特别注意到您可以定义函数来动态生成目标文件路径。
我怀疑你想要
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 withC-x C-e
:(setq cc-search-directories '("." "../inc" "../inc/*" "../../inc/*" "../../../inc/*" "/usr/include"))
and running
ff-find-other-file
in buffera.cpp
, only results in a prompt in the minibuffer:
Find or create a.hpp in: ~/tmp/test/src/a/b/
C-h v
onff-search-directories
returnscc-search-directories
, and oncc-search-directories
I get the list above.I expect
ff-find-other-file
to look in../../../inc/*
, and finda.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 froma.cpp
.The help about
ff-search-directories
says:The stars are not wildcards: they are searched for together with the preceding slash. The star represents all the subdirectories except `..', and each of these subdirectories will be searched in turn.
Note that this quote if from the help for
ff-search-directories
, while the list I modified iscc-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:
The star is not a general wildcard character: it just indicates that the subdirectories of this directory must each be searched in turn.
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找不到我的标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!