58

Is there a way to maximize my window on start-up?

Currently, I hit Control+Windows Key+Up on my keyboard but it is very bothersome to do that every time.

I am using Emacs 24.4 on Ubuntu 12.04.

  • 1
    I did not know the key combination to maximize emacs. Thanks for that and also the answer below worked out! – Prasanna May 10 '16 at 14:17
  • From where did you find out the combination <kbd>![Windows Key][oldwinlogo]</kbd> This does not work for me :-( – Prasanna May 10 '16 at 14:19
65

I have another method, which I have tested with Emacs 24.3 and 24.4, as well as on both Windows and GNU/Linux. I have placed the following in my init file:

(add-to-list 'default-frame-alist '(fullscreen . maximized))

I believe this was modified slightly from a StackOverflow answer I found a while ago, but I can't seem to find it again now.

Edit: Another bonus of this method is that it also applies to new clients that connect to your Emacs server (with e.g. emacsclient -c).

  • 3
    +1 for the precise answer. If I could accept this as answer again - I really would! – Prasanna May 10 '16 at 14:18
  • 1
    I like this solution using emacsclient, but there are some frames that starting them maximized would prevent to use them correctly, like the ediff control panel, is there a workaround for this? – marcanuy Jun 19 '17 at 1:03
  • @marcanuy: I don't know of a solution off the top of my head, but it might be worth posting a new question for that. – Scott Weldon Jun 20 '17 at 22:59
28

On Emacs 24.4, (toggle-frame-maximized) toggles the maximized state of the current frame.

See also, the Maximize Emacs on start up question on stackoverflow and the Full Screen page on the EmacsWiki.

  • This works with castlemacs on mac. Thanks! – Sankalp Feb 21 at 19:27
26

Adjust the ...-frame-alist in your init file to tell Emacs how to maximize the frame. You also have multiple options for how, exactly, to maximize it.

alist options

You have two ...-frame-alist options:

  1. default-frame-alist (as in @Scott Weldon's answer)
  2. initial-frame-alist

If you use default-frame-alist, it will maximize all frames: both the first one and any others you create. That may not be what you want (or maybe it is: who am I to judge?).

If you use initial-frame-alist, it will maximize only the frame that Emacs creates at startup, but will not touch any subsequent frames you create.

maximization options

For your maximization options, see this node of the manual for details. The short version is that you can set the fullscreen parameter to:

  • fullwidth (make the frame as wide as possible, don't touch the vertical)
  • fullheight (make the frame as tall as possible, don't touch the horizontal)
  • fullboth (set height and width to to size of the screen)
  • maximized (make it, well, maximized)

The difference between fullboth and maximized is that you can resize the former with the mouse, while with the latter you cannot.

example

So, for example, these lines will 1) create a maximized initial frame, and 2) create fullheight (but not fullwidth) frames on every subsequent frame:

(add-to-list 'initial-frame-alist '(fullscreen . maximized))
(add-to-list 'default-frame-alist '(fullscreen . fullheight))
  • 2
    Indeed initial-frame-alist is much more useful than default-frame-alist when one uses tools like ediff. – giordano Nov 12 '14 at 0:17
9

@Constantine's answer already covers how this can be achieved by modifying your init-file (if you use Emacs 24.4).

If you start Emacs from the command line, from the dash, or from a launcher like Synapse or krunner, you can specify the -mm option (short for --maximized) to achieve the same result:

emacs -mm

The -mm option was first introduced in Emacs 23.2, so this solution is not limited to the latest stable release.


What distinguishes this solution from other suggestions posted here (all of which are great) is that it allows you to decide on a case-by-case basis whether you want the Emacs frame maximized at start-up or not.

If you want a more permanent solution, you can set up an alias for the command shown above by adding the following to your .bashrc:

alias emacs='emacs -mm'
  • 2
    Another benefit of this solution is that emacs starts already maximized. Init file workarounds make it switch to maximized during the startup, which is kind of annoying. – and Jul 23 '15 at 8:48
  • 1
    To add to this answer: emacs -fs starts Emacs maximized to the full screen, or maximally maximized to the max. – Teemu Leisti Jun 8 '18 at 10:54
6

To startup Emacs maximised, add to your init file:

;; Start maximised (cross-platf)
(add-hook 'window-setup-hook 'toggle-frame-maximized t)

In case you want to go full screen or, as they say now, distraction free mode:

;; Start fullscreen (cross-platf)
(add-hook 'window-setup-hook 'toggle-frame-fullscreen t)

NOTE: This works in Windows too.

1

I'm using the following:

(when (eq system-type 'gnu/linux)
  (defun x11-maximize-frame ()
    "Maximize the current frame (to full screen)"
    (interactive)
    (x-send-client-message nil 0 nil "_NET_WM_STATE" 32 '(2 "_NET_WM_STATE_MAXIMIZED_HORZ" 0))
    (x-send-client-message nil 0 nil "_NET_WM_STATE" 32 '(2 "_NET_WM_STATE_MAXIMIZED_VERT" 0)))
  (run-with-idle-timer 0.01 nil 'x11-maximize-frame)
  )

(when (eq system-type 'windows-nt)
  (w32-send-sys-command 61488)
)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.