Where can I find some thorough documentation / a specification for the Emacs ctags format? The ultimate goal here is to make it easier to generate a tags file in parallel (preferably using a tool like
xargs or GNU Parallel).
Somewhat confusingly, there are two very different formats commonly called "ctags". One of which is used by
vi and its workalikes.
example (from Perl 5 source code using
ctags -f- op.c | head -n 3):
AAS_DANGEROUS op.c /^ AAS_DANGEROUS = 0x080, \/* an op (other than the above)$/;" e enum:__anon1file: AAS_DEFAV op.c /^ AAS_DEFAV = 0x200 \/* contains just a single '@_' on RHS *\/$/;" e enum:__anon1 file: AAS_LEX_AGG op.c /^ AAS_LEX_AGG = 0x008, \/* @lexical or %lexical aggregate *\/$/;" e enum:__anon1 file:
This format has the advantage of being line-oriented and storing the symbol first, so work can be efficiently parallelized
find . -name '*.c' -o -name '*.h' \ | xargs -I% -n100 -P8 ctags -f- % \ | env LC_ALL=C sort > tags
By contrast, the Emacs variant of the ctags format is a little bit harder to decipher since, among other things, it uses non-printable characters internally.
File Edit Options Buffers Tools Hexl Help 87654321 0011 2233 4455 6677 8899 aabb ccdd eeff 0123456789abcdef 00000000: 0c0a 6f70 2e63 2c31 3935 3131 0a23 6465 ..op.c,19511.#de 00000010: 6669 6e65 2050 4552 4c5f 494e 5f4f 505f fine PERL_IN_OP_ 00000020: 437f 5045 524c 5f49 4e5f 4f50 5f43 0131 C.PERL_IN_OP_C.1
It also uses byte offsets instead of a search string. It also mentions the file name once at the start of a "stanza" corresponding to each file rather than having each line stand on its own.
The closest I was able to find to documentation of the internal format (rather than the kinds of pattern in source codes that emacs recognizes) was https://stackoverflow.com/q/1990579/931154 .