generating python tags with

for file in $(find -type f -regex ".+\\.\(py\)"); do etags -a $file; done

doesn't load at emacs with error

path/TAGS is not a valid tags file

although other language i.e c works just fine, and syntax of generated TAGS doesn't look odd!

3 Answers 3


You can generate the TAG file like this:

find . -name "*.py" | xargs etags -a

Then in .emacs file:

(setq tags-table-list (list "/path/to/TAG/file/dir/"))


the problem was with emacs configuration, it worked after re-installation.

with general regex

cd $1
rm -rf TAGS
for file in $(find $1 -type f -regex ".+\\.c?h?S?\(cpp\)?\(cxx\)?\(cc\)?\(hpp\)?\(hxx\)?\(hh\)?\(rb\)?\(go\)?\(js\)?\(py\)?\(java\)?" ); do
    echo "adding $file"
    etags -a $file

It may depend on which application is being used to generate the tags. Most, I belief, support an option specifically for use with Emacs. For Universal Ctags, there is the -e flag:

-e   Output tag file for use with Emacs.

To generate,

# -R to recurse, -e for Emacs
ctags -Re .

Load the result into Emacs with M-x visit-tags-table.

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.