1

I hover over stdlib:

#include <stdlib.h>

I type M-. and it asks me:

Visit tags table (default TAGS):

I don't have one of those. I see a lot of information about TAGS in the emacs documentation: https://www.emacswiki.org/emacs/TagsFile#tags_file

But what should I use, CTAGS, ETAGS, Universal CTags, Global Tags? Should I set this up in the makefile or in a key binding?

1 Answer 1

2

I'd use etags because it comes with Emacs and is what the default implementation of M-. targets.

Given a C project you can use etags *.c *.h to generate the TAGS file in that directory and select it when prompted by M-.. Some C projects already provide a Makefile target for that, for example you can run make tags in the Emacs sources to generate them for the Lisp and C parts. This is highly useful to jump to the source of a definition.

3
  • Is this something people generally do "out of band" from having a file up in the editor---done calling etags in the makefile via an external shell, versus having an emacs macro for running this process? Commented Mar 23, 2021 at 15:42
  • 1
    Matter of taste really. For the Emacs sources it's not worth it for me to automate the task because I just use them to find out where a built-in is defined and only update them after each stable Emacs release. Do whatever works for you.
    – wasamasa
    Commented Mar 23, 2021 at 16:52
  • Yes, most projects add a tags target to their Makefile, and make it a dependency of the all target. That way they can regenerate the TAGS file whenever they recompile, such as with M-x compile.
    – db48x
    Commented Mar 24, 2021 at 2:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.