I can resize the emacs frame to whatever size by mouse, is there a way that the frame size be set in init.el by pixels? Or anything similar in the window manager?

  • 1
    See the manual node on Frame Size and Position. I found this with a web search for "emacs frame pixels".
    – Dan
    Commented Sep 28, 2015 at 14:09
  • 1
    The default-frame-alist can be used to come very close, but only pixelwise on OSX with the latest patch in bug number 21415: debbugs.gnu.org/cgi/bugreport.cgi?bug=21415 For exact sizes, adjusting after the fact is necessary with set-frame-size using the optional pixelwise argument. I'll put in a request for Emacs on Microsoft Windows later on today. Most people use toggle-frame-maximized or other full-frame arguments in make-frame or the default-frame-alist, but if the user wants a specific size that is not full-screen, then set-frame-size is the way to go if not OSX
    – lawlist
    Commented Sep 28, 2015 at 14:20
  • See also the initial-frame-alist: gnu.org/software/emacs/manual/html_node/elisp/…
    – lawlist
    Commented Sep 28, 2015 at 14:39
  • Per @Dan comment, possible new location manual node
    – Liam
    Commented May 23, 2020 at 13:06

2 Answers 2


I have a screen with resolution of 1024X600, but i set the display to 1024X724, here is my solution.

(setq frame-resize-pixelwise t)
(set-frame-position (selected-frame) 0 0)
(set-frame-size (selected-frame) 1024 600 t)

As of October 13, 2015, Feature request #21415 has been incorporated into the master branch (aka Emacs trunk), such that frame creation may now include a pixel specification -- this includes items such as the initial-frame-alist, default-frame-alist, and the make-frame function. The git commit identification number is d4fe840df0b5fdb3aed538fae2ced143a471f60a. It is built-in to the public release of Emacs 25.

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

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

Here is an example using make-frame -- the font I have chosen is available on OSX 10.6.8 (substitute your own favorite font in the example accordingly):

(defun my-example-make-frame ()
  (make-frame '((name . "HELLO-WORLD")
                (font . "-*-Courier-normal-normal-normal-*-18-*-*-*-m-0-iso10646-1")
                (top . 100)
                (left . 100)
                (left-fringe . 8)
                (right-fringe . 8)
                (vertical-scroll-bars . right)
                (cursor-color . "yellow")
                (cursor-type . (bar . 1))
                (background-color . "black")
                (foreground-color . "white")
                (tool-bar-lines . 0)
                (menu-bar-lines . 0)
                (width . (text-pixels . 400))
                (height . (text-pixels . 400)))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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