[plt-scheme] indexing .ss files in (Macintosh) Spotlight.

From: Nicholas Chubrich (chubrich at cs.brandeis.edu)
Date: Sat Apr 8 02:00:52 EDT 2006

I found out today that Tiger's Spotlight search does not reach Scheme
source files.  This surprised me because .ss and .scm files are simply
text, and Spotlight generally comprises text files.  But the extension in
fact makes a difference, as is easily verified by adding a .txt extension
to a Scheme file.  Of course doing this en masse is a bad idea.  I did
find a way to make Scheme files available to Spotlight senza renaming.  
The solution is neither safe in the FDA sense nor effective in the 
Computer Science sense, but it basically works.  Pending any improvements  
I'll put it down here for the interested or the wanting:
	Pick any .scm file and .ss file.  Run the command "mdls" on each 
file.  ("mdfind" is the command-line equivalent of Spotlight.)  It returns 
a listing of metadata for the file.  The field (line) you are interested 
in is the following:
	kMDItemContentType             = "dyn.ah62d4rv4ge81g62"
	(I am not sure if this is really what Apple considers a "Uniform
Type Identifier"---at any rate it works like one---there is more on the
topic here:
) 	Get the value for both file types (it may well be different on your
system, although it should pretty much be the same from file to file.).  
Then go to /Library/Spotlight.  If you have installed XCode there will be
a SourceCode.mdimporter item.  Right-click this to Show Package Contents.  
Inside the Contents directory is the Info.plist file, which is what you
modify, inside the Property List Editor (double clicking brings this up).  
Click to expand Root; then click to expand CFBundleDocumentTypes; under
that expand 0; and under that LSItemContentTypes.  There is a list here
from 0 to (6 in my case); select the item at the end, and click the button
"New Sibling."  In the available space type the value you obtained.  
Repeat to insert the other value.  Then save from the file menu, and quit.  
Go back to the command line and type "mdimport -r
/Library/Spotlight/SourceCode.mdimporter".  This will re-run the indexing
program, which takes place in the background.  When it is done (on the
order of an hour) you will be able to search Scheme files (until then
searches hang.  You might as well do all of this before dinner, or so 
	Problems: the type identifier used here seems to be ad hoc (c.f.  
the "dyn" prefix), which suspicion is confirmed by seeing that, for
instance, modifying certain .ss files changes their kMDItemContentType
(although uniformly---in my case it always changed to
[um/rv]dyn.ah62d4rv4ge81g62).  By contrast a Word document is
com.microsoft.word.doc, and a PDF document is com.adobe.pdf.  Comparing
the Info.plist of DrScheme with some analogues (e.g. Apple's iWork)  
suggests using org.plt-scheme.DrScheme.ss, ---.scm.  This doesn't work,

Nick Chubrich.

Posted on the users mailing list.