When coding sometimes you need a reference file open alongside your code. I wrote a nice little helper function that puts Emacs into “widescreen mode” to help with this.
Specifically it doubles the width of the frame and splits it in two. You can then switch between them (
C-x o) and load whatever buffer into whichever side works best for you. I set it up so that one convenient keypress expands and contracts.
This was my first bit of actual Elisp coding and now I can’t live without it.
First we need some basic settings. I set my windows to be 120×70 because that feels comfortable to me.
(defvar brettw/default-screen-width 120) (defvar brettw/default-screen-height 70)
This is the primary functionality.
(defun brettw/widescreen () "Resize the frame double the width, or if already there, to default width." (interactive) (if (= (frame-width) brettw/default-screen-width) (progn (set-frame-size (selected-frame) (* 2 brettw/default-screen-width) brettw/default-screen-height) (split-window-horizontally) ) (progn (set-frame-size (selected-frame) brettw/default-screen-width brettw/default-screen-height) (delete-other-windows) ) ) )
Finally bind it to a useful key
(global-set-key (kbd "C-`") 'brettw/widescreen)
Note that this isn’t the smartest of code. If you have already split the frame, it’ll make its changes to the current window, and destroy everything else when you contract it back.