(archive 'newLISPer)

October 1, 2007

ThisService reaches version 2

Filed under: newLISP — newlisper @ 17:04

The cool utility ThisService from the excellently-named WaffleSoftware has been updated to version 2. It’s a clever way of running scripts written in scripting languages – such as newLISP – from the Services menu (the menu that’s available in every application, with a few dishonourable exceptions). It’s MacOS X specific – there’s probably an equivalent on other platforms.

One good addition is that you can now make services that link to scripts stored somewhere sensible on your disk. Before, your script was copied into the service, but now you can keep scripts in their rightful place and yet still use them in the services you create.

To complement this change, there’s also a packaging option, so that scripts and services can be merged ready for distribution.

The example scripts provided with this donation-ware application (written in Ruby, Perl, Python, and AppleScript – the four horsemen of Macintosh scripting) all seem to avoid reading line by line from STDIN, instead preferring to read any text input into a variable first. The word ‘slurp’ is used…

In newLISP, a typical service might look like this. This puts a comment before every line of the selection:

 #!/usr/bin/env newlisp

 (while (read-line)
   (push (current-line) the-text -1))

 (dolist (line the-text)
   (println {; } line))


As before, there will be the inevitable problems with applications that use “\r” rather than “\n” as line breaks. I think I’ve bored myself with that before!

Comment from Jesper

As the writer of the Ruby, Perl and AppleScript versions (and, also, of ThisService itself – hello everyone) I just want to defend my usage of slurping. It’s really easy – most of the time you want to run the whole input through a filter, and that might not work well with line-by-line or word-by-word or 512-summat-byte-block-by-block.

It will confuse the least amount of people who just want to get stuff done. Peter Hosey wrote the Python scripts completely independently (I said to comment well and keep STDIN/OUT UTF-8 and that was basically it), and he too chose slurping. I’d like to believe that this confirms my suspicions. ;)

Comment from cormullion

Hi! Slurping is cool. And it’s what I used too. I just quite like the word, which is much more descriptive than the usual way of describing it!

And ThisService is cool too, Jesper! If I was currently employed, I’d send you some money :-)


Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Blog at WordPress.com.

%d bloggers like this: