如何为多个git项目设置TAGS文件(etags)?

时间:2012-03-28 08:56:53

标签: git etag exuberant-ctags

为git项目设置emacs时,我正在使用

git ls-files | xargs -d\\n etags

在当前目录中创建TAGS文件。我经常想要包含来自另一个项目的符号,所以我用绝对路径附加它们:

etags -a /path/to/project/*.[ch]

但是,当我有两个 git 存储库

git ls-files /path/to/git_project

不起作用:git告诉我该路径在当前存储库之外。我可以进入它,但是然后在stdout上打印的路径与TAGS文件无关,因此emacs将无法找到它们。

有没有优雅的方法来解决这个问题?我想到的只是一些过于复杂的shell脚本魔术,以便在输入xargs之前将前缀添加到每一行......

2 个答案:

答案 0 :(得分:1)

抱歉,我不是emacs用户。我会告诉你我是如何在vim中这样做的,这样你就可以了解emacs的等效解决方案:

:set tags=/path/to/project1/tags,/path/to/project2/tags
:set path=/path/to/project1,/path/to/project2

这两个设置允许我跳转到两个项目中找到的标签。

答案 1 :(得分:0)

我认为你想要的是

{ git ls-files; git --git-dir=/path/to/the/other/project\'s/.git ls-files; } \
| xargs -d\\n etags

如果要将相对路径附加到名称的前面,请执行以下操作:

{ git ls-files
  git --git-dir=path/to/other/.git ls-files | sed s,^,path/to/other,
} | xargs -d\\n etags