Login

Build tags files for emacs and vim

Author:
ramen
Posted:
November 19, 2009
Language:
Python
Version:
1.1
Score:
0 (after 0 ratings)

Save this shell script to the root of your Django project as "tags.sh", make it executable with "chmod +x tags.sh", and run it from the project root with "./tags.sh", and you will have a "tags" file for vim and a "TAGS" file for emacs.

Tags will be created for Python, JavaScript, and block names found in HTML templates. You may need to change "/usr/share/pyshared/django" to the location of your Django installation.

Documentation on Tags in emacs | Tags in vim

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#!/bin/sh
:>TAGS
:>tags
for dir in . /usr/share/pyshared/django; do
  find $dir -name '*.py' | etags -a -
  find $dir -name '*.py' | ctags -a -
  find $dir -name '*.js' | etags -a -
  find $dir -name '*.js' | ctags -a -
  find $dir -name '*.html' | etags -a --regex='/.*{%[ \t]+block[ \t]+\([^ \t%]+\)/\1/' -
  find $dir -name '*.html' | ctags -a --regex='/.*{%[ \t]+block[ \t]+\([^ \t%]+\)/\1/' -
done

More like this

  1. Template tag - list punctuation for a list of items by shapiromatron 3 months ago
  2. JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 3 months, 1 week ago
  3. Serializer factory with Django Rest Framework by julio 10 months, 1 week ago
  4. Image compression before saving the new model / work with JPG, PNG by Schleidens 10 months, 3 weeks ago
  5. Help text hyperlinks by sa2812 11 months, 3 weeks ago

Comments

Scanner (on November 19, 2009):

I do something like that, but instead of hardcoding '.' and '/usr/share/pyshared/django' for every project I am working on I tend to have 'PYTHONPATH' set up so I use this pattern:

for dir in `echo $PYTHONPATH | sed 's/:/ /g'`; do

#

Please login first before commenting.