Re: Making frames match original frame or current window size

[email protected] Sun, 02 Aug 2026 10:21:59 -0400
Newsgroups gmane.emacs.help
Message-ID <[email protected]>
Heime <[email protected]> writes:

> This makes a new frame of the same size of the original.
> I also want to have the option for the new frame to have
> the size of the current window.  How can I do this?
>
>

You could use the functions =E2=80=98window-height=E2=80=99 and
=E2=80=98window-width=E2=80=99 to specify the height and width of the new
frame.  Try the following to see whether it gives you what
you want:

  1. Start Emacs using =E2=80=98emacs -Q=E2=80=99.

  2. Copy the following expression into the *scratch*
     buffer, but do not evaluate it:

     (let ((my-window-flag t)
           (frame-params (list (cons 'height (window-height))
                               (cons 'width (window-width)))))
       (if my-window-flag
           (make-frame frame-params)
         (setq frame-inherited-parameters '(width height))
         (make-frame)))

   3. Split the window in the frame, vertically or
      horizontally.

   4. Evaluate the expression in your *scratch* buffer,
      which should result in a new frame whose size matches
      the current window.

   5. Repeat step 4, but change (my-window-flag t) to
      (my-window-flag nil) first, to confirm that the new
      frame is the same size as the existing frame (unless
      there is a bug involving =E2=80=98make-frame=E2=80=99 and
      =E2=80=98frame-inherited-parameters=E2=80=99, as you reported in a
      previous email).

--=20
The lyf so short, the craft so long to lerne.
- Geoffrey Chaucer, The Parliament of Birds.