> 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