Skip to content

Maximizing Emacs on startup

by mickey on October 18th, 2010

Until recently it was impossible to start Emacs in maximized mode in X, but that changed with the release of Emacs 23.2. Now you can force Emacs to start in maximized mode with the command line switch --maximized or -mm.

In Windows you have to use a bit of elisp and Win32 magic to get it to work.

Add this to your .emacs file to make Emacs start in maximized mode in Windows:

The code will only execute on Windows, and it works by sending a WM_SYSCOMMAND window message to itself, telling it to maximize. The magic number 61488 is a constant declared as SC_MAXIMIZED.

  1. This works great for me on Windows XP using GNU Emacs 23.2.1 (i386-mingw-nt5.1.2600) of 2010-05-08 on G41R2F1. Thanks for the awesome tip!

  2. I tested it on Windows XP, and works well, and does not conflict with my [setq initial-frame-alist...]
    It also work in GNU Linux distribution?

  3. I’ve tested in gNewSense 3.0 but doesn’t work :-(
    Sin, because it is a feature that I like.

  4. Bill Zimmerly permalink

    Hi Mickey!

    I’m a recent convert to Emacs and am struggling with some of the basics. Let me explain … I see so much potential for moulding Emacs into an application I would like to see, but some of what seem to be the simplest things are maddeningly difficult. For example:

    I like the format of applications that use a tri-term design – like Evolution. It has a small window (using Emacs terminology) on the left, a small window on the top-right, and a large window on the bottom. In Emacs, here is how I create it:

    (setq w1 (selected-window)) ; w1 = top left window.
    (setq w2 (split-window w1 9)) ; w2 = bottom window.
    (setq w3 (split-window w1 35 t)) ; w3 = top right window.

    BUT! No matter how hard I try with combinations of “display-buffer” … “select-window” … etc. I cannot make it so that *the buffer I want to see* is in the window I want to see it in.

    For example, if I want to see the “calendar” code run in the top right window (w3) I would expect to put code like this in next:

    (select-window w3)

    …but it doesn’t work as the calendar always seems to force itself into the bottom window. Please help me to understand how to put what I want into the windows that I want to put it in. (Thanks!)

    - Bill

    • mickey permalink


      Welcome to Camp Emacs. It’s a fun editor, with a fairly byzantine tiling window manager.

      Generally, in Emacs, we tend to let windows come and go as out needs change; it’s not really all that productive to lock it into a fixed set of tiles like you would in most IDEs. Exceptions here being tools that really are multi-windowed like GUD and so on.

      Saying that, there are several options that can alleviate your pains like escreen or just plain “Window Configurations”.

      Anyway, your conundrum is caused by errant calendar behavior, but that is easily rectified. Place the following code in your .emacs to force calendar to show itself in the top-right split window:

      Have fun.


      • Bill Zimmerly permalink

        Thanks Mickey! Two follow-up questions:

        1. What was the purpose of the (interactive) function in this context? (I read the info on it with C-h-f, but didn’t understand it.)

        2. Where should I execute (calendar) so there is a *Calendar* buffer to display? (Starting raw without it just causes an error;
        “Symbol’s function definition is void: calendar-basic-setup”
        when I run the function.)

        I’m really enjoying reading your blog and “Mastering Emacs” – THANKS for a great service! :)

        • mickey permalink


          You are getting symbol void error because the calendar isn’t loaded. You must add (require 'calendar) before the defun.

          Interactive means it is considered a command, which is something you can invoke using M-x.

          Glad you’re enjoying the blog!

          • Bill Zimmerly permalink

            Thanks AGAIN!!!!! :)

            Learning such complexity is *SO* much easier when you have the right teacher. ;)

      • Bill Zimmerly permalink

        Also, I tried to look up both “escreen” and “Window Configurations” in the info docs and couldn’t find them. (?)

  5. Justin permalink

    It might be nice to show how to make start with the window vertically maximized, or note that this isn’t possible if it’s not (I think I remember reading some very ugly incantations for it in the past, but I’m not sure).

  6. Nitin Bodke permalink

    Thanks. This works :)

  7. Phillip Oldham permalink

    No love for us mac users?! I’m having to manually expand emacs every time I open it! :(

    • mickey permalink

      Sorry, I don’t know if GNU Emacs for MacOSX supports maximizing.

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS