Bill Lovett

Set The Size and Position of Emacs Frames

The Problem

When Emacs is launched, its initial window ("frame") is sized and positioned according to application defaults instead of your own preferences. Inevitably, you adjust it to your liking. But this fiddling happens every time Emacs launches and it distracts you from the task at hand. It would be more efficient if Emacs automatically sized the frame according to your expectations.

The Solution

I call this function immediately after defining it so that it takes effect as soon as possible. There's a slight lag between the time Emacs draws the initial frame at its default size and the time the resize happens. It's not instantaneous, but it does happen fast. That's good enough for me, because I just want to avoid unnecessary window fiddling.

Taking things a step further, you could have different window configurations for different circumstances: a large window that occupies the full screen on a laptop and a less wide but taller window for a desktop monitor, or one setup for when you're on a Mac and another for when you're not.

References

I started with the function from Control your emacs frames programatically and simplified it by removing the nosplit parameter, the platform detection, and the hard-coded frame position coordinates. Note that as of Emacs 23, the line (when (equal 'mac (framep frame)) should be (when (equal 'ns (framep frame))