I’m regulary jumping between my big display and the notebook screen.
This little function resizes and repositions my emacs window based on the screen size.
You will need to adjust the sizes to your need.
(defun set-frame-size-according-to-resolution () (interactive) (if window-system (progn (if (> (x-display-pixel-width) 1500) ;; 1500 is the delimiter marging in px to consider the screen big (set-frame-width (selected-frame) 237) ;; on the big screen make the fram 237 columns big (set-frame-width (selected-frame) 177)) ;; on the small screen we use 177 columns (setq my-height (/ (- (x-display-pixel-height) 150) ;; cut 150 px of the screen height and use the rest as height for the frame (frame-char-height))) (set-frame-height (selected-frame) my-height) (set-frame-position (selected-frame) 3 90) ;; position the frame 3 pixels left and 90 px down ))) ;; (set-frame-size-according-to-resolution) (global-set-key (kbd "C-x 9") 'set-frame-size-according-to-resolution)
Just put this in your .emacs or any other startup script