osa.el is an Emacs Lisp to macOS Open Scripting Architecture bridge (JavaScript / AppleScript) working on top of Apple Event descriptors as provided by Emacs Mac port.
All of the necessary Apple Event types that are needed to write useful scripts are supported for both packing and unpacking:
- True is unpacked to t
- False is unpacked to nil
- Boolean is unpacked to t or nil
- Long is unpacked from signed 32bit to Emacs Lisp integer
- Null which is distinct from null type, is unpacked to keyword :null
- Type is unpacked to either (:type :null), (:type :msng), (:type data)
- Unicode text (UTF-16 BOM auto-detection)
- List is unpacked to Emacs Lisp vector
- Record is unpacked to an Emacs Lisp tagged alist: (:reco (k . v) ..)
Conversely for packing, except t and nil are always packed to True and False (never a Boolean type) and tagged (:list ..) is packed like a vector.
Additional types may be implemented in future releases.
Does not work with official GNU Emacs for macOS (or emacsformacosx.com) as it does not expose an Apple Event API.
You need Yamamoto Mitsuharu’s excellent Emacs Mac port, which can also be found in MacPorts and Homebrew, though cloning its repository and building from source is highly recommended.
Simple and most flexible method:
;; Clone this repository, ensure directory of osa.el is in your
;; load-path and add the following to your init file:
(require 'osa-examples)
Alternatively, you can install through MELPA or some other Emacs package manager.
See osa-examples.el
This repository uses 2 different licenses:
- All files in the ‘scripts’ directory use a public-domain equivalent license
- All other files use a 2-clause BSD license
xristos (AT) sdf (DOT) org