1

My goal is to resize Emacs frame on start to make its width 120 chars and center the frame. To compute offset i'm using this:

(let* ((width-left (- (x-display-pixel-width)
                      (frame-pixel-width)))
       (frame-left-offest (/ width-left 2)))
 (add-to-list 'default-frame-alist (cons 'left frame-left-offest)))

The problem is that (frame-pixel-width) during the app launch gives me one width and when the app has started it gives me another width (the proper one, which i need). So the result is wrong. I'm not sure why that happens and what's the proper way to do it.

  • I have my various computers already calculated in terms of screen sizes and so forth, and I have a test that identifies the display-pixel-width and display-pixel-height and the operating system and version of the OS and I set my frame precisely based on previously established information. If you want to set pixel width and height at the time a frame is created (instead of relying on 120 characters), see the feature request 21415 that was implemented a couple of months ago -- that feature also works with the default-frame-alist for the initial frame, as well as subsequently created ones. – lawlist Jan 28 '16 at 21:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.