Home » Questions » Computers [ Ask a new question ]

Save Emacs window size on Windows XP

Save Emacs window size on Windows XP

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?

Asked by: Guest | Views: 250
Total answers/comments: 2
Guest [Entry]

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

(restore-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)
(with-temp-buffer
(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."
Guest [Entry]

"I use this in my .emacs to fix the size

(defvar max-width 80)
(defvar max-height 50)"