How to use shell magic to create a recursive etags using GNU etags?

前端 未结 4 2047
遥遥无期
遥遥无期 2020-12-15 00:39

The standard GNU etags does not support a recursive walk of directories as done by exuberant ctags -R. If I only have access to the GNU etags, how

相关标签:
4条回答
  • 2020-12-15 01:02

    The Emacs Wiki is often a good source for answers to common problems or best practices. For your specific problem there is a solution for both Windows and Unixen:

    http://www.emacswiki.org/emacs/RecursiveTags#toc2

    Basically you run a command to find all .cpp and all .h files (change file selectors if you use different file endings, such as e.g., .C) and pipe the result into etags. Since Windows does not seem to have xargs, you need a more recent version of etags that can read from stdin (note the dash at the end of the line which symbolizes stdin). Of course, if you use a recent version of etags, you can use the dash parameter instead of xargs there, too.

    Windows:

    cd c:\source-root
    dir /b /s *.cpp *.h *.hpp | etags --your_options -
    

    Unix:

    cd /path/to/source-root
    find . -name "*.cpp" -print -or -name "*.h" -print | xargs etags --append
    
    0 讨论(0)
  • 2020-12-15 01:07

    Use find. man find if you need to.

    0 讨论(0)
  • 2020-12-15 01:09

    Most of the answers posted here pipe the find output to xargs. This breaks if there are spaces in filenames inside the directory tree.

    A more general solution that works if there are spaces in filenames (for .c and .h files) could be:

    find . -name "*.[cChH]" -exec etags --append {} \;
    
    0 讨论(0)
  • 2020-12-15 01:17

    This command creates etags file with default name "TAGS" for .c, .cpp, .Cpp, .hpp, .Hpp .h files recursively

    find . -regex ".*\.[cChH]\(pp\)?" -print | etags -
    
    0 讨论(0)
提交回复
热议问题