Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Recently i bought laptop with Windows XP. I'd really like to start using emacs on it but there is one problem - when I start emacs it just do not fit vertically to my screen. So every time I launch emacs I should begin with resizing its window which is quite embarrassing and inconvenient. Is there any way to automatically save at exit and restore at startup emacs window size?

update I moved my code to the question answer

share|improve this question

migrated from Jan 26 '10 at 8:15

This question came from our site for professional and enthusiast programmers.

up vote 4 down vote accepted

Just put in .emacs this piece of code

(defun restore-saved-window-size()
  (unless (load "~/.emacs.d/whsettings" t nil t)
    (setq saved-window-size '(80 30)))
  (nconc default-frame-alist `((width . ,(car saved-window-size))
                   (height . ,(cadr saved-window-size)))))


(defun save-window-size-if-changed (&optional unused)
  (let ((original-window-size  `(,(frame-width) ,(frame-height))))
    (unless (equal original-window-size saved-window-size)
        (setq saved-window-size original-window-size) 
        (insert (concat "(setq saved-window-size '"
                        (prin1-to-string saved-window-size) ")"))
        (write-file "~/.emacs.d/whsettings")))))

(add-hook 'window-size-change-functions 'save-window-size-if-changed)

Works great on my Windows XP
For shortcut, can create file named emacs.cmd in %system32% folder with following content: C:\path-to-emacs\bin\runemacs.exe %* to be able to launch it from cmd everywhere.

share|improve this answer

Save the following to a .reg file and import it into the registry:

share|improve this answer

I use this in my .emacs to fix the size

(defvar max-width  80)
(defvar max-height 50)
share|improve this answer
it is not it at all – Shchvova Jan 27 '10 at 20:48

John T answered the question.

For further information about what Emacs reads in the Windows registry, check the MsWindowsRegistry page on EmacsWiki.

share|improve this answer
did you read my question? – Shchvova Jan 27 '10 at 0:36
"save and restore" No, I guess not. :-/ You should write your answer as an Answer so I can upvote it. – piyo Jan 27 '10 at 12:08
I finally got enough rep, so upvoting yours. – piyo Feb 10 '10 at 17:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .