I often have multiple windows in
emacs. I would like to have a function that modifies the width of a window to a certain value, then scales the text such that the longest line in the buffer fits the window leaving a small margin at the end (e.g. of two or three characters)
text-scale-adjust (bound to
C-x C-=, and
C-x C-0) let you resize the text in the current buffer by
changing its scale factor. When you shrink or enlarge the
apparent text size this way, however, the window takes no notice
of it. In particular, although shrinking text can result in extra
horizontal space at the right, window commands do not see this
space as extra.
If you use library
face-remap+.el then you can do what you want, or at least something similar, which you can modify.
text-scale-resize-window lets you
automatically resize the selected window (horizontally,
vertically, or both) when text is resized, so that the way the
window fits the buffer text remains relatively constant.
Shrinking the text in one window shrinks that window, giving more
space to adjacent windows.
If you also use library
fit-frame.el, then one-window frames
also respond to text resizing by scaling. If not, then the
text-scale commands have no effect on frame size for one-window
frames. (See also Shrink-Wrapping Frames.)