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
#+END_SRC
Thanks!
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.
apples-mode
major mode, and table output.
Commented
Sep 14, 2016 at 21:18
Not sure if Org Babel supports AppleScript, but it supports bash. You can run applescript from Bash using osascript
and a bash heredoc
:
#+BEGIN_SRC sh
osascript <<'END'
display dialog "Hello, World"
END
#+END_SRC
SE doesn't allow proper formatting. The END
statement should be all the way to the left, with no spaces before it.
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.
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"
#+END_SRC
#+BEGIN_SRC sh :noweb yes :exports both
osascript -e '<<hello-apples>>'
#+END_SRC
#+RESULTS:
: button returned:OK
I'm using apples-mode
because it appears to have better font-locking than applescript-mode
but you can use either.