Setting An Emacs Per-System Height

Every time I start Emacs I have to adjust the frame size. That’s because my two main systems are a 15 inch MacBook Pro and a 27 inch iMac. In both cases I want the width to be 80 cols so I just set that with set-frame-width in my init.el file. I always ended up setting the height though because the MacBook can handle only 53 rows while the iMac can do 87. I finally got tired of that and added a bit of code to check the system name and set the height appropriately. I’m not even sure this is the best way of handling the problem but it’s simple and works. Here’s the code for anyone else who has a similar problem

(defconst jcs-system-heights '(("aineko" . 87) ("manfred" . 53)))
(let* ((system (car (split-string (system-name) "\\.")))
       (height (assoc system jcs-system-heights)))
  (when height
      (set-frame-height (selected-frame) (cdr height))))

Once you have the system name, you can make any other system-specific adjustments you need. If this init.el is used for another system (such as one of my servers), height will be nil and no action will be taken. If you are using Linux, you can probably get the same effect by setting the X-defaults; I couldn’t find a way of doing this for OS X.

This entry was posted in General and tagged . Bookmark the permalink.