Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically setting Emacs frame size

My emacs (on Windows) always launches with a set size, which is rather small, and if I resize it, it's not "remembered" at next start-up.

I've been playing with the following:

(set-frame-position (selected-frame) 200 2) ; pixels x y from upper left (set-frame-size (selected-frame) 110 58) ; rows and columns w h 

which totally works when I execute it in the scratch buffer. I put it in my .emacs, and although now when I start the program, I can see the frame temporarily set to that size, by the time *scratch* loads, it resets back to the small default again.

Can anyone help me fix up the above code so that it "sticks" on start-up?

like image 856
J Cooper Avatar asked Dec 02 '08 21:12

J Cooper


People also ask

How do I set the window size in Emacs?

The `-geometry' option controls the size and position of the initial Emacs frame. Here is the format for specifying the window geometry: `-g width x height {+-} xoffset {+-} yoffset ' Specify window size width and height (measured in character columns and lines), and positions xoffset and yoffset (measured in pixels).

Which function is used for setting the size of frame?

Using setSize() you can give the size of frame you want but if you use pack() , it will automatically change the size of the frames according to the size of components in it.


2 Answers

Here's what I use in my ~/.emacs:

(add-to-list 'default-frame-alist '(left . 0)) (add-to-list 'default-frame-alist '(top . 0)) (add-to-list 'default-frame-alist '(height . 50)) (add-to-list 'default-frame-alist '(width . 155)) 
like image 64
Bill White Avatar answered Oct 04 '22 04:10

Bill White


(setq initial-frame-alist '(             (top . 40) (left . 10)             (width . 128) (height . 68)             )   ) 
like image 24
Cheeso Avatar answered Oct 04 '22 02:10

Cheeso