I haven't called AppleScript from Emacs in a while. Cooked up an Emacs command today to to make iTunes either play or pause, depending on its state. It's nothing fancy.
(defun sw-pp ()
"Make iTunes either pause or play"
(interactive)
(setq apscript "
tell application \"iTunes\"
if player state is paused then
play
else
pause
end if
end tell
"
)
(do-applescript apscript)
)
(An aside: I'm using the code HTML tag here to render the above code, which doesn't honor indentation. Using the pre tag double spaces the code, which strikes me as a bug).
Formally, I should use (let) instead of (setq) (which creates and sets a global variable) but I'm too lazy to work out the syntax. Writing Emacs Lisp is not yet second nature to me.
