You should be automatically redirected . If not, visit
http://newlisper.wordpress.com
and update your bookmarks.

01/10/2007

ThisService reaches version 2

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))

 (exit)

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 :-)

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home