From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.help Subject: Re: Changing height to fit window Date: Wed, 30 Nov 2022 14:23:36 +0200 Message-ID: <83lensljg7.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4413"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 30 13:25:09 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p0M9E-0000yY-GU for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 30 Nov 2022 13:25:08 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p0M8N-0000Rm-7q; Wed, 30 Nov 2022 07:24:15 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0M8E-0000RI-1H for help-gnu-emacs@gnu.org; Wed, 30 Nov 2022 07:24:07 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0M8D-00029f-Pe for help-gnu-emacs@gnu.org; Wed, 30 Nov 2022 07:24:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=1SIhpeo8bK2/WaIwOg9JKp5nuqsx1579DrOKuiy/w/I=; b=NmBQZQxgK9uU nd1IS11KkrSVbWDlsVUygjsCBW7ItQEKKcCnlwu6NQqd8eog1V2a2Mtb5rYSaTg4wCiWpujqYxE5g TyKXKtQBu3y36bC090DpqRKGn7A4lB0iVMRdlIh53qpqbC6Tu/0IVoAIzmZ6BS4ahdknaErqyvLJc AGZ+2zbu7PQzCLfB2TImemNlcGchTLEpFaXYLz6d+bSTA9C1nxaFwMIk44aORPPfh3nq5OeU0qGSH Va+hul0yoNcixXapFIJPwU+MA0d3RFHJJNoYauRUsyJjv9mvxtc+EBQaxoHWBKvSw0QeOQY4z/hSd zNuz5tE1RvJlFmgn4eQK4Q==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0M8D-0005Pf-0B for help-gnu-emacs@gnu.org; Wed, 30 Nov 2022 07:24:05 -0500 In-Reply-To: (message from Heime on Tue, 29 Nov 2022 20:37:03 +0000) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:141254 Archived-At: > Date: Tue, 29 Nov 2022 20:37:03 +0000 > From: Heime > > > One can C-x C-+ and C-x C-- to call text-scale-adjust, > which increases or decreases the buffer text size, with > C-+ or C-- to repeat. > > Instead of repeating, I want to have a function that adjusts > the scale so that the contents of the buffer fit the window, > based on the longest line. What can I do? Ask Emacs about the pixel-height of the text, then compute the scale you need to make that the same as the pixel-height of the window's body. Caveat: when you change the font size, some lines could take more or fewer lines on the screen (due to wrapping) and disrupt your calculations. Dealing with that is left as an exercise.