Resize your emacs frame with keyboard shortcuts

I like my emacs windows to be the full height, and 86 columns wide and at the left of the screen if I am using a single monitor, or at the right hand side of the left screen if I am using two monitors.

I have set up a few functions to give me quick keyboard shortcuts to resize and move my frame in this way. These functions require the package frame-cmds (which you can install as usual) to provide the maximize-frame-vertically function.

With these I just use e.g. C-c b <left> or C-c b <S-right> to send my frame exactly where I want it to be.

;;set frame full height and 86 columns wide
;;and position at screen left
(defun bjm-frame-resize-l ()
  "set frame full height and 86 columns wide and position at screen left"
  (interactive)
  (set-frame-width (selected-frame) 86)
  (maximize-frame-vertically)
  (set-frame-position (selected-frame) 0 0)
  )

;;set frame full height and 86 columns wide
;;and position at screen right
(defun bjm-frame-resize-r ()
  "set frame full height and 86 columns wide and position at screen right"
  (interactive)
  (set-frame-width (selected-frame) 86)
  (maximize-frame-vertically)
  (set-frame-position (selected-frame) (- (display-pixel-width) (frame-pixel-width)) 0)
  )

;;set frame full height and 86 columns wide
;;and position at screen right of left hand screen in 2 monitor display
;;assumes monitors are same resolution
(defun bjm-frame-resize-r2 ()
  "set frame full height and 86 columns wide and position at screen right of left hand screen in 2 monitor display assumes monitors are same resolution"
  (interactive)
  (set-frame-width (selected-frame) 86)
  (maximize-frame-vertically)
  (set-frame-position (selected-frame) (- (/ (display-pixel-width) 2) (frame-pixel-width)) 0)
  )

;;set keybindings
(global-set-key (kbd "C-c b <left>") 'bjm-frame-resize-l)
(global-set-key (kbd "C-c b <right>") 'bjm-frame-resize-r)
(global-set-key (kbd "C-c b <S-right>") 'bjm-frame-resize-r2)