I’m trying to write a function that makes all the windows in an Emacs frame 120 characters wide. So far I have this:
(defun standard-width ()
"makes the widht of the window 120, our coding standard"
(interactive)
(delete-other-windows)
(set-frame-width (selected-frame) 120 )
)
However I’d like to have this work without the delete-other-windows call. Unfortunately, without this call the total frame width is 120, shared among windows. How can I make the total frame width (maximum number of windows in the horizontal direction) * 120?
I don’t know of a simple way to do this. I would use
(window-tree (selected-frame)), and parse the return value to find the row with the maximum number of windows laid out horizontally, and use the count to calculate frame width and hope that the windows would scale correctly. If the windows do not scale right, then I’d attempt to resize them individually (after setting the frame width) using thewindow-resizefunction defined inwindow.el.The format of the return value for
window-treecan be found in Emacs Lisp document.Something along the lines of the following function should do the trick:
You use it as
(horizontal-window-count (car (window-tree))). The code can probably be simplified and it may have some issues, but I am also not very fluent in lisp.