Wednesday, March 14, 2007

Back To Etags

In my previous post I wrote about using exuberant-ctags for emacs and Objective-C. But for some reason exuberant-ctags failed to create tags for funcions in /usr/include/string.h on my Mac. So, I switched back to etags. Here the correspondent shell script for generating tags for system headers on Mac OS X:

#!/bin/sh
s="\t "
S="[$s]*"
w="_a-zA-Z0-9"
CN="[A-Z][$w]*"
NM="[$w][$w]*"

ETAGS="/Applications/Emacs.app/Contents/MacOS/bin/etags"

cat /dev/null > tmp.tags
find /usr/include -name "*.h" -exec \
$ETAGS -a --declarations -o tmp.tags \
"{}" ";"
mv tmp.tags include.tags

cat /dev/null > tmp.tags
find /System/Library/Frameworks -name "*.h" -exec \
$ETAGS -a --declarations -o tmp.tags \
-r "/$S[-+]$S(\($S$NM\)\{1,3\}$S\**$S)?$S\($NM\)$S[:;]/\2/" \
"{}" ";"
sed "/^@class/d" tmp.tags > Frameworks.tags
rm tmp.tags

No comments: