I got one hour of sleep last night, but I still found time today to put together a package containing the Spotlight plugin I wrote for indexing Lisp files: Lisp Metadata Importer 0.0.2.dmg.

What does it do?

This importer plugin indexes files with .lisp, .lsp and .cl extensions using the Spotlight search engine that was introduced by Apple in OS X 10.4.

You might notice that even before you install this plugin that some of your Lisp files have already been
indexed by Spotlight. It is possible that something on your system set the type of some files as “TEXT”, in
which case the default Spotlight text indexer will process the files. This only happens on a file-by-file basis,
though, whereas the Lisp Metadata Importer instructs the system to index all files with the extensions listed
above, regardless of whether or not the system already thinks they’re text files. The Lisp importer also does
some Lisp-specific indexing that you might find more useful than the default text indexing.

How do I install it?

Copy the Lisp Metadata Importer.mdimporter file into the /Library/Spotlight folder.

How do I uninstall it?

Remove the Lisp Metadata Importer.mdimporter file from the /Library/Spotlight folder.

How do I test it once it is installed?

Try indexing a single Lisp file using the mdimport command. When you run mdimport with the -d1 flag it
will tell you which plugin it’s using, if any, to index the file. You should see a reference to the Lisp Metadata
Importer.mdimporter file.

Once you’ve run mdimport, use the mdls command to look at the metadata associated with the file. The
important things to look for are that the kMDItemContentType is “com.lemonodor.lisp-source”, and that
there are some attributes with names that begin with “org_lisp”, like “org_lisp_defmacros” or
“org_lisp_defuns”.

If you see those attributes then the importer is working correctly.
If the importer doesn’t seem to be working and you’ve double checked to make sure you copied it
to the correct folder, try the mdimport –r trick in the next question & answer; it’s the equivalent
of kicking a malfunctioning jukebox.

How do I index all my Lisp files?

Use mdimport again, this time with the -r flag, and passing it the path to the Lisp plugin.

What exactly is being indexed?

The Lisp metadata importer indexes the definitions contained in a file. This includes functions,
macros, classes, methods, generic functions, structures, defvars, defparameters and defconstants. It
also includes any object FOO defined by a form that looks like (“defsomething FOO ...)”. In
addition to definitions, the entire contents of the file are indexed for full text queries.

How do I search for something?

The GUI way is to hit Command-F in the finder to bring up a Find window. Click on one one of
the attributes and select “Other...”. to see a list of other attributes:

Choose one of the Lisp importer’s attributes from the list that comes up (you can type “lisp” into
the search field on the upper right to filter out the non-Lisp attributes):

Now enter the text you’d like to search for and watch the matching files appear:

Some people have reported that the Lisp-specific attributes weren’t available in the Find dialog until
they re-launched the Finder (to re-launch the finder, hit Command-Option-Esc and then select the
Finder in the “Force Quit Applications” dialog that pops up).

The non-GUI way to do Spotlight searches is to use the mdfind command. I did this the other day
when someone on IRC asked how to do search-and-replace on a string. I knew I had written a
function to do that, but I couldn’t remember which project the code was in.

in order to co-exist with clozure-cl/openmcl application, the keys in the info.plist need to be updated to org.lisp.lisp-source from com.lemondor.lisp-source.
With this change, a re-compiled version seems to be working on leopard.