all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Changing height to fit window
@ 2022-11-29 20:37 Heime
  2022-11-29 22:58 ` [External] : " Drew Adams
  2022-11-30 12:23 ` Eli Zaretskii
  0 siblings, 2 replies; 6+ messages in thread
From: Heime @ 2022-11-29 20:37 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor


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?





^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [External] : Changing height to fit window
  2022-11-29 20:37 Changing height to fit window Heime
@ 2022-11-29 22:58 ` Drew Adams
  2022-11-29 23:15   ` Heime
  2022-11-30 12:23 ` Eli Zaretskii
  1 sibling, 1 reply; 6+ messages in thread
From: Drew Adams @ 2022-11-29 22:58 UTC (permalink / raw)
  To: Heime, 'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'

[-- Attachment #1: Type: text/plain, Size: 744 bytes --]

> 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?

Dunno whether this corresponds to what you're
asking, but library `face-remap+.el' adjusts
the frame/window size to the scaled text size,
when option `text-scale-resize-window' is non-nil.

The particular non-nil value controls whether
the window-fitting is horizontally, vertically,
or both.

;; URL: https://www.emacswiki.org/emacs/download/face-remap%2b.el
;; Doc URL: https://emacswiki.org/emacs/SetFonts


[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 13651 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [External] : Changing height to fit window
  2022-11-29 22:58 ` [External] : " Drew Adams
@ 2022-11-29 23:15   ` Heime
  0 siblings, 0 replies; 6+ messages in thread
From: Heime @ 2022-11-29 23:15 UTC (permalink / raw)
  To: Drew Adams; +Cc: 'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'

------- Original Message -------
On Tuesday, November 29th, 2022 at 10:58 PM, Drew Adams <drew.adams@oracle.com> wrote:


> > 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?
> 
> 
> Dunno whether this corresponds to what you're
> asking, but library `face-remap+.el' adjusts the frame/window size to the scaled text size, when option` text-scale-resize-window' is non-nil.

I want the opposite - given a window size, fit things in there with one call.
 
> The particular non-nil value controls whether
> the window-fitting is horizontally, vertically,
> or both.
> 
> ;; URL: https://www.emacswiki.org/emacs/download/face-remap%2B.el
> ;; Doc URL: https://emacswiki.org/emacs/SetFonts



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Changing height to fit window
  2022-11-29 20:37 Changing height to fit window Heime
  2022-11-29 22:58 ` [External] : " Drew Adams
@ 2022-11-30 12:23 ` Eli Zaretskii
  2022-11-30 14:40   ` Heime
  1 sibling, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2022-11-30 12:23 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Tue, 29 Nov 2022 20:37:03 +0000
> From: Heime <heimeborgia@protonmail.com>
> 
> 
> 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.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Changing height to fit window
  2022-11-30 12:23 ` Eli Zaretskii
@ 2022-11-30 14:40   ` Heime
  2022-11-30 15:33     ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Heime @ 2022-11-30 14:40 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs

------- Original Message -------
On Wednesday, November 30th, 2022 at 12:23 PM, Eli Zaretskii <eliz@gnu.org> wrote:


> > Date: Tue, 29 Nov 2022 20:37:03 +0000
> > From: Heime heimeborgia@protonmail.com
> > 
> > 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.

Are you discussing line-pixel-height and window-pixel-height ?
 
> 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.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Changing height to fit window
  2022-11-30 14:40   ` Heime
@ 2022-11-30 15:33     ` Eli Zaretskii
  0 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2022-11-30 15:33 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Wed, 30 Nov 2022 14:40:20 +0000
> From: Heime <heimeborgia@protonmail.com>
> Cc: help-gnu-emacs@gnu.org
> 
> > > 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.
> 
> Are you discussing line-pixel-height and window-pixel-height ?

No, I thought about window-text-pixel-size and window-body-height.



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-11-30 15:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-29 20:37 Changing height to fit window Heime
2022-11-29 22:58 ` [External] : " Drew Adams
2022-11-29 23:15   ` Heime
2022-11-30 12:23 ` Eli Zaretskii
2022-11-30 14:40   ` Heime
2022-11-30 15:33     ` Eli Zaretskii

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.