95

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.

3
  • 2
    I did not know the key combination to maximize emacs. Thanks for that and also the answer below worked out!
    – Prasanna
    Commented May 10, 2016 at 14:17
  • 1
    From where did you find out the combination <kbd>![Windows Key][oldwinlogo]</kbd> This does not work for me :-(
    – Prasanna
    Commented May 10, 2016 at 14:19
  • To circumvent the problem, one could use desktop-save-mode, so that you set your favorite frame sizes once and they are reproduced in the next emacs session automatically.
    – Alsk
    Commented Jan 12, 2022 at 22:36

6 Answers 6

119

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

4
  • 4
    +1 for the precise answer. If I could accept this as answer again - I really would!
    – Prasanna
    Commented May 10, 2016 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
    Commented Jun 19, 2017 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. Commented Jun 20, 2017 at 22:59
  • 3
    @marcanuy You can use initial-frame-alist. Like the name implies, this will only maximize the initial frame.
    – clemera
    Commented Nov 23, 2019 at 13:13
48

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
  • 5
    Indeed initial-frame-alist is much more useful than default-frame-alist when one uses tools like ediff.
    – giordano
    Commented Nov 12, 2014 at 0:17
  • (add-to-list 'default-frame-alist '(fullscreen . maximized)) is not the best answer. I confirm what another answer said (Dan): (add-to-list 'initial-frame-alist '(fullscreen . maximized)) is the way to have this work well.
    – francogrex
    Commented Nov 23, 2019 at 10:27
35

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.

2
  • This works with castlemacs on mac. Thanks!
    – Sankalp
    Commented Feb 21, 2019 at 19:27
  • Thanks this works for me on emacsclient where as the add to frame list doesn't.
    – nmu
    Commented Aug 13, 2020 at 14:36
18

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
  • Finally! The t argument to add-hook (to make toggle-frame-fullscreen run last, not first) was the missing ingredient for me that made it work.
    – Lassi
    Commented Mar 29, 2020 at 12:18
13

@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'
3
  • 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
    Commented Jul 23, 2015 at 8:48
  • 1
    To add to this answer: emacs -fs starts Emacs maximized to the full screen, or maximally maximized to the max. Commented Jun 8, 2018 at 10:54
  • These options don't work with emacsclient, but the same thing can be achieved with emacsclient -c -F "'(fullscreen . maximized)"
    – Iain
    Commented Jul 30 at 0:59
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 and acknowledge you have read our privacy policy.

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