David Wolever
David Wolever

Reputation: 154504

How can I ask Emacs to use different tags for different source files?

If I've got two different projects open in Emacs — proj1/foo.c and proj2/bar.py — how can I ask Emacs to use proj1/TAGS when looking up tags for files under proj1, and proj2/TAGS when looking up tags for files under proj2?

Upvotes: 4

Views: 612

Answers (1)

phils
phils

Reputation: 73274

I think the simplest DIY approach is directory-local variables.

$ cat proj1/.dir-locals.el
((nil . ((tags-file-name . "~/projects/proj1/TAGS"))))

$ cat proj2/.dir-locals.el
((nil . ((tags-file-name . "~/projects/proj2/TAGS"))))

If Emacs asks you whether to "Keep current list of tags tables also?" you should reply 'no' to avoid mixing the tables within a given project. (It shouldn't ask you this frequently, and answering 'no' won't cause Emacs to forget which TAGS to use for the files from the other project.)

Upvotes: 3

Related Questions