unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: martin rudalics via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Stefan Kangas <stefankangas@gmail.com>, Toomas Rosin <toomas@rosin.ee>
Cc: Eli Zaretskii <eliz@gnu.org>, 74866@debbugs.gnu.org
Subject: bug#74866: 29.4; fit-frame-to-window + no vertical scroll bar + ch
Date: Wed, 18 Dec 2024 11:05:17 +0100	[thread overview]
Message-ID: <7e7b4037-5f71-4c74-9a93-2db76d2eb86e@gmx.at> (raw)
In-Reply-To: <CADwFkm=-HhE-N0sk9HnocSBOM-pMzes8mU9+sn_Lrf24eV1LXA@mail.gmail.com>

 > Toomas Rosin <toomas@rosin.ee> writes:

Toomas please include me in the recipients.

 >> 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.
 >
 > So is there a bug here?

It might be a synchronization problem.  When in the new frame I type M-x
fit-frame-to-buffer, it behaves as intended here.

Whatever it is, I'd suggest to never ever use the idiom

(setq-default vertical-scroll-bar nil)

'vertical-scroll-bar' is an automatically buffer-local variable meant to
override what the frame specifies for any buffer displayed in it.  But
the size hints Emacs sends to the window manager are derived from the
settings for the frame.  So it's easily possible that the window manager
truncates the frame size to the next size specified by our size
increments just that in the case at hand the base width would still
include the vertical scroll bar.  In fact, here I have to set
'frame-resize-pixelwise' to t to make your scenario work even without
the 'set-face-attribute' call.

So if you want to turn off vertical scroll bars for all frames please
use a (vertical-scroll-bars . nil) entry in 'default-frame-alist'.

Whether 'set-face-attribute' DTRT and how it is involved in the scenario
at hand is a question I'd prefer not to answer.  If it affects the
canonical line height or column width of a frame, it should find its way
into the size hints for each frame.  Otherwise, chaos may result.

martin





      parent reply	other threads:[~2024-12-18 10:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-14 12:57 bug#74866: 29.4; fit-frame-to-window + no vertical scroll bar + changed face height = mess toomas
2024-12-14 13:26 ` Eli Zaretskii
2024-12-14 17:16   ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-14 19:09     ` bug#74866: 29.4; fit-frame-to-window + no vertical scroll bar + ch Toomas Rosin
2024-12-17 13:07       ` Stefan Kangas
2024-12-17 13:15         ` Toomas Rosin
2024-12-18 10:05         ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7e7b4037-5f71-4c74-9a93-2db76d2eb86e@gmx.at \
    --to=bug-gnu-emacs@gnu.org \
    --cc=74866@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=rudalics@gmx.at \
    --cc=stefankangas@gmail.com \
    --cc=toomas@rosin.ee \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).