Monday, June 11, 2007

Alepin with Spotlight

Aha! It's liberating to know I don't have to write a Spotlight importer for Alepin. But being told something is impossible doesn't stop me from trying; I just don't get frustrated when it doesn't work.

This is a really easy two-step process.

  1. Add Alepin to the Rich Text mdimporter.
    1. Following this hint, I ran the mdimport -n -d1 command on an Alepin file to learn that it's type 'com.macchampion.alepin.alpn'.
    2. Run this command: open /System/Library/Spotlight/RichText.mdimporter/Contents/Info.plist to open the plist file with the Property List Editor. (It's a Developer application, so you will need to have installed the Developer Tools.)
    3. In Property List Editor, expand the only triangle (Root) and then the first triangles under that (CFBundleDocumentTypes, 0, LSItemContentTypes). Select the last item (mine was com.apple.webarchive) and hit the New Sibling button. That will fill in the next number and the same String class, and all you need to do is to enter com.macchampion.alepin.alpn, the type from the first step. Save. Quit.
  2. Force Spotlight to import Alepin notebooks.
    1. find ~/Documents -name "*.alpn" -exec mdimport -f {} \;
    2. That command runs finds anything within your Documents folder that ends with the file extension alpn. The mdimport command is Spotlight indexing, -f forces indexing even of what it would normally skip (and regular Spotlight indexing does skip my Alepin notebooks), and {} means on the results of the find command. Oh, and \; just signals the end of what find should execute on the results.

Now you won't get Spotlight indexing of RTFD attachments like pictures in your Alepin notebooks yet, but I'm sure you could do a forced import of those as well. You can list them with a command like find ~/Documents -name "*.alpn" -exec ls -R {} \; | grep -v "alpn\|DocumentInfo\|rtfd\|TXT.rtf\|^$" and then move on to the next idea based on those results.

No comments:

Post a Comment