Skip to content

Instantly share code, notes, and snippets.

@nilcolor
Created January 21, 2011 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nilcolor/790443 to your computer and use it in GitHub Desktop.
Save nilcolor/790443 to your computer and use it in GitHub Desktop.
Set Emacs default frame size
(defun set-frame-size-according-to-resolution ()
(interactive)
(if window-system
(progn
;; use 180 char wide window for largeish displays
;; and smaller 80 column windows for smaller displays
;; pick whatever numbers make sense for you
(if (> (x-display-pixel-width) 1280)
(add-to-list 'default-frame-alist (cons 'width 180))
(add-to-list 'default-frame-alist (cons 'width 80)))
;; for the height, subtract a couple hundred pixels
;; from the screen height (for panels, menubars and
;; whatnot), then divide by the height of a char to
;; get the height we want
(add-to-list 'default-frame-alist
(cons 'height (/ (- (x-display-pixel-height) 200) (frame-char-height)))))))
(set-frame-size-according-to-resolution)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment