Skip to content

Instantly share code, notes, and snippets.

@zakandrewking
Last active August 29, 2015 14:06
Show Gist options
  • Save zakandrewking/e4779d44b6d824009ac0 to your computer and use it in GitHub Desktop.
Save zakandrewking/e4779d44b6d824009ac0 to your computer and use it in GitHub Desktop.
etags.sh for windows
# http://ck.kennt-wayne.de/2013/sep/emacs-using-ctags-for-javascript-and-rails
--langdef=js
--langmap=js:.js
--regex-js=/([A-Za-z0-9._$]+)[ \t]*[:=][ \t]*\{/\1/,object/
--regex-js=/([A-Za-z0-9._$()]+)[ \t]*[:=][ \t]*function[ \t]*\(/\1/,function/
--regex-js=/function[ \t]+([A-Za-z0-9._$]+)[ \t]*\(([^)])\)/\1/,function/
--regex-js=/([A-Za-z0-9._$]+)[ \t]*[:=][ \t]*\[/\1/,array/
--regex-js=/([^= ]+)[ \t]*=[ \t]*[^"]'[^']*/\1/,string/
--regex-js=/([^= ]+)[ \t]*=[ \t]*[^']"[^"]*/\1/,string/
--exclude=*.min.js
--langdef=js
--langmap=js:.js
--regex-js=/function[ t]+([A-Za-z0-9._$]+)[ t]*(([^)]))/1/,function/
#!/usr/bin/python
# Example usage.
# Place the following in file called post-checkout in .git/hooks/
#
# #!/bin/bash
# /Users/zaking/.emacs.d/etags.sh -py -m -js -!/env/
#
# Ignores the /env/ directory anywhere in the path.
from sys import argv
from subprocess import call
# for windows:
types = "\|".join([('\(.*\.%s\)' % a.strip('-')) for a in argv[1:] if not "!" in a])
ignore = " ".join(['\! -path "*%s*"' % a.strip('-!') for a in argv[1:] if "!" in a])
cmd = 'rm TAGS;find . %s \! -path "*/.*" -regex "%s$" -exec etags -a {} \;' % (ignore, types)
status = call(cmd, shell=True)
print "generated TAGS file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment