Using etags in emacs
- Generate tags:
in the root source directory,
find . -name "*.[ch]*" -o -name "*.cpp" -o -name "*.hpp" | xargs etags -a
- Set tags in emacs:
M-x visit-tags-table RET
- Look up tag definitions:
M-.
- Move back to last tag position:
M-*
Once you have a tags file, you can follow tags (of functions, variables, macros, whatever) to their definitions. These are the basic commands:
M-.
(find-tag
) – find a tag, that is, use the Tags file to look up a definitionM-*
(pop-tag-mark
) – jump backtags-search
– regexp-search through the source files indexed by a tags file (a bit likegrep
)tags-query-replace
– query-replace through the source files indexed by a tags fileM-,
(‘tags-loop-continue’
) – resumetags-search
ortags-query-replace
starting at point in a source filetags-apropos
– list all tags in a tags file that match a regexplist-tags
– list all tags defined in a source file
See the Emacs manual, node Tags for more information.