Skip to content

Instantly share code, notes, and snippets.

@lawlist lawlist/get-bounds.el
Last active Jul 17, 2019

What would you like to do?
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
You can’t perform that action at this time.