为什么不能在 ctags 命令中使用 exclude 参数排除文件?

Why can't exclude files with exclude argument in ctags command?

我想为 C 和 C++ 创建标签文件,排除 /usr/include/python2.7 中的所有文件,/usr/include/* 中的所有文件而不是 /usr/include/python2.7 中的所有文件都创建了标签。

ctags -R -I __THROW -I __attribute_pure__ -I __nonnull -I __attribute__ \
    --file-scope=yes --langmap=c:+.h --languages=c,c++ --links=yes --c-kinds=+p \
    --c++-kinds=+p --fields=+iaS --extra=+q  \
    -f .vim/tags/c.tag /usr/include/*  --exclude="/usr/include/python2.7"

写成

也没用
ctags -R -I __THROW -I __attribute_pure__ -I __nonnull -I __attribute__ \
    --file-scope=yes --langmap=c:+.h --languages=c,c++ --links=yes --c-kinds=+p \
    --c++-kinds=+p --fields=+iaS --extra=+q  \
    -f .vim/tags/c.tag /usr/include/*  --exclude=/usr/include/python2.7/*

为什么还有很多内容来自 /usr/include/python2.7?

grep  "python*"  /home/debian8/.vim/tags/c.tag
ysize   /usr/include/python2.7/Imaging.h    /^    int xsize, ysize, xoff, yoff;$/;" m   struct:ImagingCodecStateInstance    access:public
ysize   /usr/include/python2.7/Imaging.h    /^    int ysize;$/;"    m   struct:ImagingMemoryInstance    access:public
ystep   /usr/include/python2.7/Imaging.h    /^    int ystep;$/;"    m   struct:ImagingCodecStateInstance    access:public

您正在尝试在目标目录后添加更多选项。那不行。

这应该有效:

ctags -R -I __THROW -I __attribute_pure__ -I __nonnull -I __attribute__ \
    --file-scope=yes --langmap=c:+.h --languages=c,c++ --links=yes --c-kinds=+p \
    --c++-kinds=+p --fields=+iaS --extra=+q  \
    -f .vim/tags/c.tag --exclude=python2.7 /usr/include

这与您使用的命令相同,但有三处不同:

  1. 指定--exclude选项要索引的目标目录之前。

  2. 指定没有通配符的目标目录(/usr/include),因为 ctags 已经知道要查看里面的所有内容。

  3. 只需排除 python2.7 因为只需要那个目录名。如果它看到那个目录名,它就不会去那里索引任何东西。此处不需要完整路径。