Is there a way to maximize my window on start-up?
Currently, I hit Control++Up on my keyboard but it is very bothersome to do that every time.
I am using Emacs 24.4 on Ubuntu 12.04.
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
).
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?
initial-frame-alist
. Like the name implies, this will only maximize the initial frame.
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
optionsYou have two ...-frame-alist
options:
default-frame-alist
(as in @Scott Weldon's answer)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.
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.
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))
initial-frame-alist
is much more useful than default-frame-alist
when one uses tools like ediff.
(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.
Commented
Nov 23, 2019 at 10:27
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.
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.
t
argument to add-hook
(to make toggle-frame-fullscreen
run last, not first) was the missing ingredient for me that made it work.
@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'
emacs -fs
starts Emacs maximized to the full screen, or maximally maximized to the max.
Commented
Jun 8, 2018 at 10:54
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)
)
<kbd>![Windows Key][oldwinlogo]</kbd>
This does not work for me :-(