views:

1520

answers:

6

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?

+2  A: 

Did you try this : emacs -geometry 110x58+200+2 &

Found at :

http://web.mit.edu/answers/emacs/emacs_window_size.64R.html

siukurnin
+12  A: 

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

Bill White
I had given up on this problem for a while ago, using your code fixed it finally :)
Rene Saarsoo
+1  A: 

For emacs on windows, I generally put it in the registry.

HKCU\Software\GNU\Emacs\
    Emacs.Geometry REG_SZ "245x74"

(This keeps machine-local settings out of my .emacs file, which I share with many other machines...)

Alastair
+2  A: 

See this previous question as well: How do I set the size of emacs’ window?

Chris Conway
+1  A: 
(setq initial-frame-alist '(
      (top . 40) (left . 10)
      (width . 128) (height . 68)
      )
  )
Cheeso
+1  A: 

Between Emacs 19 and 21, I used to have a perfectly working .emacs that did exactly what you are looking for, by distinguishing between default-frame and initial-frame:

  (setq default-frame-alist '((foreground-color . "LightGray")
                  (background-color . "Black")
                  (cursor-color . "Medium Sea Green")
                  (width . 80)
                  (height . 36)
                  (menu-bar-lines . 1)
                  (vertical-scroll-bars . right)))

and

  (setq initial-frame-alist
                (cons '(width . 96)
                      (cons '(height . 72)
                        (cons '(menu-bar-lines . 1)
                          initial-frame-alist))))

Alas, when I "upgraded" to Emacs 23.2 the above doesn't fully anymore. Emacs is not my career. I am using it as a tool, so I can't devote too much time delving into understanding why. So I simply worked around the problem by adding to the Emacs Windows XP shortcut "-geometry 96x72". So the shortcut target now looks:

C:\emacs-23.2\bin\runemacs.exe -geometry 96x72
Android Eve