I'm using Emacs on a small netbook to write code, and I've set the font size so that approximately fill-column(79) characters fill the width of a single 'maximized' window (ie pretty big font size). However, if I open two windows side by side, I would like the font size in those windows to automatically shrink so that each window's width accommodates at least 79 characters.
Before I start looking deep into this (I'm not good at Lisp), is it possible to get the window's width on each resize, divide it by fill-columns, and based on that result select a monospaced font size?
It seems to me the right place to do this would be window-size-change-functions
:
Functions called before redisplay, if window sizes have changed. The value should be a list of functions that take one argument. Just before redisplay, for each frame, if any of its windows have changed size since the last redisplay, or have been split or deleted, all the functions in the list are called, with the frame as argument.
Specifically, stick something like this in your .emacs
:
(defun window-width-to-font-size (window-width)
;; Insert a calculation to turn window width into 79 chars.
)
(add-to-list
'window-size-change-functions
(lambda (frame)
(dolist (window (window-list frame))
(set-face-attribute
'default nil
:width (window-width-to-font-size (window-body-width window))))))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With