I'm currently dealing with a very obfuscated and over-engineered codebase, with layers upon layers upon layers. There is always a silver linning though and I finally got around to learning how to use etags in emacs. I can't believe I waited this long to learn this feature, specially since it is so easy.
etags lets you quickly locate a definition by its name anywhere in your code base.
First, you need to tag the code. Go to the base directory and run
$ etags `find . -name "*.c" -o -name "*.h"`
This will generate a 'TAGS' file.
Let emacs know about the tag file
M-x visit-tag-table [location of the TAGS file]
With the cursor on a function call do the following
M-. (which is ALT-.)
This will take you to the function definition anywhere in the entire directory structure
Now if you want to go back
M-* (which is ALT-SHIFT-*)
Cool, isn't it? It gets better!
That's not all you can do with the TAGS file. Imagine that you are dealing with very long function names or can't quite remember the exact name. No problem. Type the first few characters of the name, then press M-tab. Either the full function name will appear, or a window will pop up displaying a list of possible completions.
If you like this checkout smart-tab
. It allows you to use the tab key to indent and tab complete function/variable names.
** Alternatively, you can use 'make tags' to generate the 'TAGS' file.