Does anyone know how to setup org-mode so that you can write/process applescript from within org source code blocks? I.e.,

#+BEGIN_SRC applescript

tell application "Emacs"
    [do something amazing]
end tell



3 Answers 3


It's super rough, but I managed to get a very, very basic integration working last night. Hope it is useful: https://github.com/stig/ob-applescript.el -- that should at least give you something to work with.

  • Awesome! Thanks Stig — great job!!!
    – Adam
    Sep 12, 2016 at 21:33
  • You're welcome. If this PR is merged you should be able to install this module from Melpa. I also updated the module to support the apples-mode major mode, and table output. Sep 14, 2016 at 21:18
  • You can now install this using package.el from MELPA. Dec 20, 2016 at 11:18

Not sure if Org Babel supports AppleScript, but it supports bash. You can run applescript from Bash using osascript and a bash heredoc:

  osascript <<'END'
  display dialog "Hello, World"

SE doesn't allow proper formatting. The END statement should be all the way to the left, with no spaces before it.

  • Emacs supports do-applescript (an alias for ns-do-applescript) from ns-win.el, so it could also be an elisp code block that calls said function.
    – lawlist
    Aug 19, 2016 at 4:16
  • Thanks @mankoff! Good tip. I was hoping to find a way to support AppleScript directly though, so I could apply font-locking...
    – Adam
    Aug 20, 2016 at 12:01

Would a bit of indirection be OK? You can use noweb to have an applescript block inserted into a shell block for execution…

#+name: hello-apples
#+BEGIN_SRC apples
display dialog "Hello, World"

#+BEGIN_SRC sh :noweb yes :exports both
osascript -e '<<hello-apples>>'

: button returned:OK

I'm using apples-mode because it appears to have better font-locking than applescript-mode but you can use either.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.