Depending on exactly what you mean by maximized, you can use either
toggle-frame-fullscreen
or toggle-frame-maximized
to achieve
it through elisp (or M-x ...
). Note, as @lawlist's answer
points out, you may need to adjust frame-resize-pixelwise
.
Here are the relevant docstrings. First, the "fullscreen" version:
(toggle-frame-fullscreen)
Toggle fullscreen mode of the selected frame.
Enable fullscreen mode of the selected frame or disable if it is
already fullscreen. Ignore window manager screen decorations.
When turning on fullscreen mode, remember the previous value of the
maximization state in the temporary frame parameter maximized
.
Restore the maximization state when turning off fullscreen mode.
Note that with some window managers you may have to set
frame-resize-pixelwise
to non-nil in order to make a frame
appear truly fullscreen.
See also toggle-frame-maximized
.
And the "maximized" version:
(toggle-frame-maximized)
Toggle maximization state of the selected frame.
Maximize the selected frame or un-maximize if it is already maximized.
Respect window manager screen decorations.
If the frame is in fullscreen mode, don't change its mode,
just toggle the temporary frame parameter maximized
,
so the frame will go to the right maximization state
after disabling fullscreen mode.
Note that with some window managers you may have to set
frame-resize-pixelwise
to non-nil in order to make a frame
appear truly maximized.
See also toggle-frame-fullscreen
.