Sunday, August 28, 2005

 

September British LinuxUser reviews LispWorks Personal

I had a look at it in the bookstore, didn't buy it. Overall favorable, although they didn't like CAPI built on just Motif, they mentioned it uses Aqua under Mac. Nothing the Planet Lispers don't already know; I just mention it because I think it's interesting that a Common Lisp environment is mentioned in a more "mainstream" computer magazine.

Sunday, August 21, 2005

 

A Spotlight Lisp plugin in a day, or I never metadata I never liked

While planning my approach into CLSQL to add Fuzzy SQL, I found myself wanting to just search for keywords, Spotlight-style. Well, how hard can it be? Not that hard, as it turns out. I basically just want to throw the text of a file to Spotlight and have it index the contents. Even if you have no Objective C or Cocoa experience like me, copying and modifying code is pretty straightforward.

I started with this article on Creating Spotlight Plugins. In the info.plist, I substituted his type of "com.apple.stickies.aaa" with "com.lisp.lisp", and "lisp" as the file extension. In the schema.xml, I made a custom metata for lisp files called com_lisp_lisp_data.

The XCode project makes a file called 'GetMetaDataForFile.c', which gets renamed to 'GetMetaDataForFile.m' since we use Objective C and Cocoa. The meat of this file is a callback function called 'GetMetaDataForFile'. All I do in this function is read the entire file into a NSString and add it to the 'mutable dictionary'.

Here's the function:

Boolean GetMetadataForFile(
void* thisInterface,
CFMutableDictionaryRef attributes,
CFStringRef contentTypeUTI,
CFStringRef pathToFile)
{
Boolean success=NO;
NSAutoreleasePool *pool;

// Don't assume that there is an autorelease pool
//around the calling of this function.
pool = [[NSAutoreleasePool alloc] init];

/* Pull any available metadata from the file */

NSString *fileText = [NSString stringWithContentsOfFile:pathToFile];

[(NSMutableDictionary *)attributes setObject:fileText
forKey:@"com_lisp_lisp_data"];

// return YES so that the attributes are imported and
// add more resilient error handling at your own discretion
success=YES;

//memory management
[pool release];

return success;
}

Build this in XCode, then:

My-Computer:~/LispImporter/build rrc$ sudo cp -r LispImporter.mdimporter /Library/Spotlight

We start with a small lisp file:
My-Computer:~/LispImporter/build rrc$ cat ~/small.lisp
;; A small lisp file
(format t "This is a small lisp file")

Index this file:
My-Computer:~/LispImporter/build rrc$ mdimport -d1 ~/small.lisp
2005-08-21 20:41:05.624 mdimport[630] Import '/Users/rrc/small.lisp' type 'com.lisp.lisp' using 'file://localhost/Library/Spotlight/LispImporter.mdimporter/'

See what Spotlight thinks about this file. Note the 'com_lisp_lisp_data' attribute:
My-Computer:~/LispImporter/build rrc$ mdls ~/small.lisp
/Users/rrc/small.lisp -------------
com_lisp_lisp_data = ";; A small lisp file (format t "This is a small lisp file") "
kMDItemAttributeChangeDate = 2005-08-21 20:41:05 -0400
kMDItemContentCreationDate = 2005-08-21 20:37:33 -0400
kMDItemContentModificationDate = 2005-08-21 20:37:33 -0400
kMDItemContentType = "com.lisp.lisp"
kMDItemContentTypeTree = ("com.lisp.lisp", "public.data", "public.item", "public.content")
kMDItemDisplayName = "small.lisp"
kMDItemFSContentChangeDate = 2005-08-21 20:37:33 -0400
kMDItemFSCreationDate = 2005-08-21 20:37:33 -0400
kMDItemFSCreatorCode = 0
kMDItemFSFinderFlags = 0
kMDItemFSInvisible = 0
kMDItemFSLabel = 0
kMDItemFSName = "small.lisp"
kMDItemFSNodeCount = 0
kMDItemFSOwnerGroupID = 501
kMDItemFSOwnerUserID = 501
kMDItemFSSize = 60
kMDItemFSTypeCode = 0
kMDItemID = 1604367
kMDItemKind = "Document"
kMDItemLastUsedDate = 2005-08-21 20:37:33 -0400
kMDItemUsedDates = (2005-08-21 20:37:33 -0400)

Great! Now tell Spotlight to do all the lisp files:
My-Computer:~/LispImporter/build rrc$ mdimport -r /Library/Spotlight/LispImporter.mdimporter
2005-08-21 20:43:47.750 mdimport[633] Asking server to reimport files with UTIs: ("dyn.ah62d4rv4gk8y2wnxna", "dyn.ah62d4rv4ge8024pxsa", "com.lisp.lisp")

Go away for a while...
Then give it a try.



Sunday, August 14, 2005

 

Refresh, renew, refill the Kool-Aid

My wife and I went on a vacation to the mountains of Highlands, NC. The place had no Internet access, so I thought I'd take along "Hackers and Painters" to reread and get re-inspired. I have drunk the Paul Graham Kool-Aid; I got a Mac to have an easy-to-use Unix to work on Lisps, I suggest his essays to friends, yada yada.

What Paul probably got real right - page 56, where he starts talking about web apps taking over most of software. This was before Google showing us the AJAX way.

What Paul may have gotten wrong - page 164, "parallelism will be something that is available if you ask for it explicitly, but ordinarily not used". Lately we've been hearing that we're hitting the limits on a particular core, mulitcore chips are going to be more common and we'll have to write our software for it.

The big open question I came away with was Paul talking about "Good design comes in chunks". He compares 15th century Florence (mentions 10 famous artists from there and then) vs 15th century Milan (mentions 0).

"Nothing is more powerful than a community of talented people working on related problems". Can virtual communities serve this purpose today? I can't move to this era's "15th century Florence", even if I could find it. But would I need to? Do I just need to keep up with Planet Lisp or comp.lang.lisp or common-lisp.net? Is is something broader, like Ruby On Rails/Trails/Lisp on Lines communities? It would be pretty damn cool if anyone could just surf to "a community of talented people working on related problems". All we need to do is find it, or define it ourselves.

P.S. Paul - If you're reading this, RELEASE ARC ALREADY. Thank you.

Sunday, August 07, 2005

 

Holy Crap! or, I didn't know you could do that

As a lower priority project I've been looking for a "universal UI" for any Lisp projects I may do. I've been restricting it to Web clients backed by Lisp on the server, no unusual installs, etc. I also want to keep it to something that would work with most browsers and OS's today (ruling out Safari's canvas tag, SVG, etc.) but that would allow some graphics, probably charts.

I was originally thinking of Laszlo, which with version 3.0 you can take your Laszlo client and compile it into Flash. The standalone Flash app can send requests back to the server, get data in the form of XML and use XPath strings to get to the data.

Then I found this article on JavaScript Graphics.

This is just browser, no Flash, Java or plugins. Basically, you can use pure JavaScript, DOM and CSS to make graphcs in browsers. All the tricks work with standards compliant browsers, and some work with IE. I've tried them with Safari and Firefox.

I was going to go Laszlo, but I won't mind going back to the drawing board for this.


This page is powered by Blogger. Isn't yours?