AppleScript with Common Lisp

Latest News

January 5, 2008

Added a link to Clozure CL's bug #216, which contains a patch necessary for cl-applescript.

December 24, 2007

Added initial web page and files.


cl-applescript provides an easy-to-use API for making AppleScript calls from Common Lisp and translating AppleScript's output to Common Lisp structures.

This is still a work in progress; currently only SBCL and CCL are supported, and the output translation does not handle dictionaries nor «foo ...» forms other than «class ...» and «data ...».

Also, this requires Mac OS X Leopard (10.5) which made AppleScript fully Unicode-compatible


The following symbols are exported from the cl-applescript package:

run-applescript script
Executes the string script and returns the output string of the script.
parse-applescript-output str [start]

Parses output from AppleScript by recursively reading lists, strings, numbers, symbols, class names and hex-encoded binary data. The following grammar (roughly) describes the AppleScript output format:

    as-object := as-list | as-string | as-number | as-symbol | as-binary | as-class
    as-list   := '{' [as-object] [, as-object]* '}'
    as-class  := '«class ' as-symbol '»'
    as-binary := '«data ' [hex]* '»'
    as-string := '"'string'"'
    as-number := 0-9[.0-9]
    as-symbol := characters

The tricky part is that AppleScript symbols can include spaces, so a symbol is only terminated if a comma, }, » or EOF are encountered. Symbols are interned in the package designated by *applescript-symbol-package* which defaults to the keyword package, with spaces replaced by hyphens. Class names are simply interned in the same way as regular symbols. Other «foo ...» structures are possible, but only «data ...» and «class ...» are currently supported. Also, named lists (i.e. dictionaries) of the form {key:value, ...} are not supported.

native-namestring path
Returns a string representation of path that can be passed to OS API's. This can be useful if you need to load external scripts within your AppleScript calls.
This variable should be set to a package specifier where all AppleScript symbols are interned during parse-applescript-output. Defaults to the keyword package.


  1. Mac OS X Leopard (10.5) or later.
  2. Clozure CL or SBCL. For CCL, a patch for bug #216 is required, as of 2008-1-5.
  3. FLEXI-STREAMS, which is ASDF-installable.


Mailing List


There is a Darcs repository for this project.

Please mail the mailing list with comments, patches, bug reports, etc.

Valid XHTML 1.0 Strict