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

The standard GNU etagsdoes not support directory recursion, as exuberant does ctags -R. If I only have access to GNU etags, how can I use bash shell magic to get etags to create a TAGS table for all C ++ files *.cppand *.hin the current directory, and all directories below the current one recursively create a TAGS table in the current directory, which has the correct path name for emacsto allow TAGS table entries.

+8
source share
4 answers

The Emacs Wiki is often a good source of 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 the command to find all files .cppand everything .h(change the file selector if you use different file endings, for example .C), and transfer the result to etags. Since Windows does not seem to have xargs, you need a newer version of etags that can read from stdin (note the dash at the end of the line that stands for stdin). Of course, if you are using the latest version of etags, you can also use the dash option instead of xargs.

Window

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
+17
source

etags "TAGS" .c,.cpp,.Cpp,.hpp,.Hpp.h

find . -regex ".*\.[cChH]\(pp\)?" -print | etags -
+4

Use find. man will find if you need.

0
source

Most of the answers posted here are xargsresults findin xargs. This is interrupted if there are spaces in the file name in the directory tree.

A more general solution that works if there are spaces in the file names (for .cand files .h) might be:

find . -name "*.[cChH]" -exec etags --append {} \;
0
source

All Articles