0

How can I maximize the current frame in an idempotent manner? That is to say, it maximizes the frame if it isn't, and leaves the frame maximized if it is?

Trevoke
  • 2,375
  • 21
  • 34
Dilna
  • 1,173
  • 3
  • 10

1 Answers1

0

As indicated in the comments, there are existing questions that lead the way to the answer to this one.

How do I toggle between current frame size and maximized frame teaches us that there is toggle-frame-maximized.

How do I make sure a frame is fullscreen? teaches us that there is a function set-frame-parameter.

When we look at the help for toggle-frame-maximized with C-h f toggle-frame-maximized RET, we see the following at the top:

toggle-frame-maximized is an interactive byte-compiled Lisp function in ‘frame.el’.

This tells us the function is written in elisp, so we can go look at the source code by clicking on frame.el, right there.

When we go look at the source code for toggle-frame-maximized, we see that it fundamentally is a conditional that has three possible calls to set-frame-parameter.

In order to unconditionally maximize the current frame, all we need to do is the following:

(set-frame-parameter nil 'fullscreen 'maximized)

That's it.

Trevoke
  • 2,375
  • 21
  • 34