Emacs dynamically changes font size based on window width and column fill

I use Emacs on a small netbook to write code, and I set the font size so that the fill-column (79) characters fill the width of one "maximized" window (that is, a fairly large font size). However, if I open two windows side by side, I would like the font size in these windows to automatically decrease, so that each window width holds at least 79 characters.

Before I start to delve deeper into this (I don’t know how to use Lisp), is it possible to get the width of the window every time I resize it, divide it by placeholder columns and based on this result choose a monospace font size?

+5
source share
2 answers

, window-size-change-functions:

, , . , . , - , .

, .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))))))
+2

, face-remap+.el, : , , , . , , .

0

All Articles