I want to write some AppleScript to raise individual Emacs frames, with a given name. Also to send keyboard events to those frames, and to resize and position them. I think that Emacs is "unscriptable," but I am not sure if there is a way to do this nonetheless. Can anyone help?


Feature request 18283 was added to Emacs 25 and the master branch in conjunction with feature request 21415, but its primary purpose was to enable debugging of Emacs relating to frames on OSX. .../Emacs.app/Contents/Info.plist (when Emacs was built --with-ns) now contains near the bottom the following:


Control of Emacs with Applescripts is not officially supported, but the above-lines added to the location indicated above permits some limited abilities.

Here is an example of the get bounds function that I used while assisting to debug certain frame location/placement issues:

(defun get-bounds ()
"Get bounds."
  (let ((script (concat
      "tell front window of application \"Emacs\"\n"
        "get bounds\n"
      "end tell")))
    (start-process "get-bounds" nil "osascript" "-e" script)
    (set-process-filter (get-process "get-bounds") 
      (lambda (proc string)
        (let ((bounds (format "Bounds of Frame:  %s" (car (split-string string "\n")))))
          (message (propertize bounds 'face 'font-lock-warning-face))

FWI:  Feature request 21415 brought about several important bug fixes in Emacs 25 and the master branch regarding frame placement and sizing, including the ability to control the precise pixel size of a frame at the time of creation (without the need to resize it after the fact). Most (if not all) frame manipulation needs can be met within Emacs without using an Applescript. The following is an example of frame-parameter specification to control exact pixel size upon frame creation -- this includes items such as the initial-frame-alist, default-frame-alist, and the make-frame function:

  • Example of usage for the frame width parameter: '(width . (text-pixels . 1900))

  • Example of usage for the frame height parameter: '(height . (text-pixels . 1054))

See also some of the built-in functions such as set-frame-position, set-frame-size (with an optional pixelwise argument), and set-frame-height (with an optional pixelwise argument):



FWIW my Applescripts here do successfully resize and reposition windows including Emacs windows on

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.