Hi everyone,
Here is some Elisp that I use to make playdate dev a smidge easier. If there are any other emacs wonks, I'd consider turning it into en elisp package for distribution through melpa.
(use-package lua-mode)
(use-package luarocks)
(setenv "PLAYDATE_SDK_PATH" (expand-file-name "~/Developer/PlaydateSDK"))
(defun playdate/sdk-bin (binary)
(shell-quote-argument (expand-file-name (concat (getenv "PLAYDATE_SDK_PATH")
"/bin/"
binary))))
(defun playdate/compile ()
(interactive "")
(playdate/expect-dir)
(projectile-with-default-dir (projectile-acquire-root)
(let* ((cmd-buf (with-current-buffer (get-buffer-create "*pdc-output*") (erase-buffer) (current-buffer)))
(cmd-result
(call-process "pdc"
nil
cmd-buf
nil
"source"
(playdate/pdx-dir)
))
(cmd-output (with-current-buffer cmd-buf (buffer-string))))
(if (> cmd-result 0)
(error (format "Compilation Failed(%d): %s" cmd-result cmd-output))
(message cmd-output))
cmd-result)))
(defun playdate/pdx-dir()
(interactive)
(expand-file-name (concat (playdate/game-name) ".pdx")
(projectile-project-root)))
(defun playdate/run-emu ()
(interactive)
(shell-command
(concat "/usr/bin/open "
"-a "
(playdate/sdk-bin "Playdate Simulator.app")
" "
(shell-quote-argument (playdate/pdx-dir)))))
(defun playdate/compile-and-run ()
(interactive)
(playdate/expect-dir)
(playdate/compile)
(playdate/run-emu))
(use-package ini
:straight t)
(defun playdate/read-pdxinfo ()
(cdr (assoc "pdxinfo"
(ini-decode (expand-file-name "source/pdxinfo" (projectile-project-root))))))
(defun playdate/game-name ()
(cdr (assoc "name" (playdate/read-pdxinfo))))