I write a lot of perl code using BBEdit, and wanted Spotlight to index my perl files. To do this, a simple modification of the the RichText.mdimporter is needed. First find the type (according to Spotlight) of the files you want indexed using this command in the Terminal:
mdimport -n -d1 theFileName.ext
which outputs something like:
Import 'theFileName.ext' type 'someSpotlightType' no mdimporter
Now take that file type (someSpotlightType) and add it to the Info.plist file located at /System -> Library -> Spotlight -> RichText.mdimporter -> Contents -> Info.plist. Add it in the array for LSItemContentTypes:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>MDImporter</string>
<key>LSItemContentTypes</key>
<array>
<string>someSpotlighType</string>
<string>public.rtf</string>
<string>public.html</string>
<string>public.xml</string>
<string>public.plain-text</string>
<string>com.apple.traditional-mac-plain-text</string>
<string>com.apple.rtfd</string>
<string>com.apple.webarchive</string>
</array>
</dict>
</array>
Now go back to the Terminal and import the files in question (mdimport /PathToFiles/ToImport), or you can even re-import everything (sudo mdimport /). To see what is going on, add the -d1 switch to the mdimport command. Now Spotlight will be able to handle the new file types -- add as many as you like. Of course, you want to make sure that you only add files that are in fact text files!
Mac OS X Hints
http://hints.macworld.com/article.php?story=2005052015041510