I was trying to figure this out and I found the functions on how to set the pixels for a frame to start. I found this but appears to be for windows and couldn't get it working right: http://www.gnu.org/software/emacs/windows/old/faq4.html. May just have been my ignorance for writing lisp code. I wanted to use x-display-pixel-height and then half of x-display-pixel-width to set the frame sizes. Does anyone have code that does something similar or know how to correctly implement this. This is so on different systems it always sets it to have the size.
Asked
Active
Viewed 1,205 times
1 Answers
2
This should set the frame size to approximately the right size:
(set-frame-height (selected-frame) (/ (display-pixel-height) (frame-char-height))) (set-frame-width (selected-frame) (/ (/ (display-pixel-width) 2) (frame-char-width)))
Unfortunately, as the documentation for frame-height
states, the relationship between frame pixel height and line height is only approximate:
The result is roughly related to the frame pixel height via height in pixels = height in lines * `frame-char-height'. However, this is only approximate, and is complicated e.g. by the fact that individual window lines and menu bar lines can have differing font heights.

Luke Girvin
- 13,221
- 9
- 64
- 84
-
Thanks a lot. That appears to work but realized it may be a little more complicated then I thought. Is there a way to detect whether there are 2 screens or one?? If 2, I want to divide by 4 and if 1 then divide by 2. It gets the display pixel width of both screens. If not, I can live with it but just thought it be nice to set it up properly if that was easily doable. I know it can easily be obtained in bash but I'm not a great lisp coder. – J Spen Nov 07 '11 at 14:57