Subject: Re: bug#74866: 29.4; fit-frame-to-window + no vertical scroll bar + ch

From: Toomas Rosin <[email-masked]>
Date: Sat, 14 Dec 2024 21:09:01 +0200

Thank you, this got the damn thing working for me.  As the lines about
vertical scroll bars and font size were from my init.el, I was loath to
clutter my function with them and hoped to get away with only adding the
`vertical-scroll-bars' item to the `frame-attributes' arg of
`make-frame'.  And indeed, this worked.  So the final form of my MWM
looks like this:

;;; init.el:
(setq-default vertical-scroll-bar nil)
(set-face-attribute 'default nil :height 75)

;;; main code:
(defun fit (lin col)
  "Fit some text (LIN lines and COL columns) into a newly created frame."
  (interactive)
  (let ((buf (get-buffer-create "*foo*"))
        (frm (make-frame
         `((z-group . above)
           (vertical-scroll-bars . ,vertical-scroll-bar)))))
    (with-current-buffer buf
      (erase-buffer)
      (setq mode-line-format '(""))
      (dotimes (_ lin) (insert (format "%s\n" (make-string col ?x))))
      (goto-char (point-min)))
    (with-selected-frame frm
      (switch-to-buffer buf)
      (fit-frame-to-buffer))))

Cheers, T.