Skip to content

Instantly share code, notes, and snippets.

@lawlist
Last active July 17, 2019 05:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lawlist/d7000235c8510460079149ad25233f0d to your computer and use it in GitHub Desktop.
Save lawlist/d7000235c8510460079149ad25233f0d to your computer and use it in GitHub Desktop.
Get the bounds of the selected frame using an applescript.
Feature request 18283 was previously added to Emacs 25 and the master branch in
conjunction with feature request 21415. In a nutshell, it is now possible to act
upon Emacs (to some degree) using an applescript.
CAVEAT: Feature request 18283 was implemented primarily to facilitate debugging,
and not to control Emacs per se using applescripts.
(defun get-bounds ()
"Return the bounds of the selected frame."
(let* ((script (concat "tell front window of application \"Emacs\"\n"
"return get bounds\n"
"end tell"))
(command (format "osascript -e '%s'" script)))
(car (split-string (shell-command-to-string command) "\n"))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment