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?
-
1See the [manual node on Frame Size and Position](http://www.gnu.org/software/emacs/manual/html_node/elisp/Size-and-Position.html). I found this with a [web search for "emacs frame pixels"](https://www.google.com/search?q=emacs+frame+pixels&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a&channel=fflb). – Dan Sep 28 '15 at 14:09
-
1The `default-frame-alist` can be used to come very close, but only pixelwise on OSX with the latest patch in bug number 21415: https://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 Sep 28 '15 at 14:20
-
See also the `initial-frame-alist`: http://www.gnu.org/software/emacs/manual/html_node/elisp/Initial-Parameters.html – lawlist Sep 28 '15 at 14:39
-
Per @Dan comment, possible new location [manual node](https://www.gnu.org/software/emacs/manual/html_node/emacs/Window-Size-X.html) – Liam May 23 '20 at 13:06
2 Answers
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)

- 1,177
- 8
- 21
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 ()
"Doc-string."
(interactive)
(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)))))

- 18,826
- 5
- 37
- 118