10

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?

4

2 Answers 2

14

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)
0
9

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)))))

Your Answer

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

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