AppleScript integration for Org Babel
This module lets you run AppleScript from AppleScript source code blocks with Org Babel.
This package is a direct result of attempting to answer a question on this emacs.stackexchange.com thread.
Some simple examples
No arguments, no code – just return a string.
#+BEGIN_SRC applescript "Hello World" #+END_SRC #+RESULTS: : Hello World
You can, however, pass a variable to a block:
#+BEGIN_SRC applescript :var subject="World" "Hello " & subject #+END_SRC #+RESULTS: : Hello World
You can use either
applescript as the language designation, to
cater for two popular major modes. Use whichever you like. I prefer the
font-locking of the
apples one. This example also shows you can do
#+BEGIN_SRC apples display alert "Danger! The WHAM is overheating!" #+END_SRC #+RESULTS: : button returned:OK
If the result of the evaluation looks like a table, it’ll become a table:
#+BEGIN_SRC apples "fi fo 1 2 3 4" #+END_SRC #+RESULTS: | fi | fo | | 1 | 2 | | 3 | 4 |
M-x package-install RET ob-applescript RET
Then, load the package from your
Ideas for future work (you’re welcome to help!)
osascriptsupports an interactive mode, which means I think it should be possible to support
- Adding some tests.
- Adding some more documentation & examples.