Skip to content

Instantly share code, notes, and snippets.

@greenrd
Forked from mariusae/emacsd-tile.el
Created September 8, 2010 15:01
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save greenrd/570250 to your computer and use it in GitHub Desktop.
;; emacsd-tile.el -- tiling windows for emacs
;; Sep 2010: Modified by Robin Green <greenrd@greenrd.org> to use modified cursor keys
(defun swap-with (dir)
(interactive)
(let ((other-window (windmove-find-other-window dir)))
(when other-window
(let* ((this-window (selected-window))
(this-buffer (window-buffer this-window))
(other-buffer (window-buffer other-window))
(this-start (window-start this-window))
(other-start (window-start other-window)))
(set-window-buffer this-window other-buffer)
(set-window-buffer other-window this-buffer)
(set-window-start this-window other-start)
(set-window-start other-window this-start)))))
(global-set-key (kbd "C-M-S-<down>") (lambda () (interactive) (swap-with 'down)))
(global-set-key (kbd "C-M-S-<up>") (lambda () (interactive) (swap-with 'up)))
(global-set-key (kbd "C-M-S-<left>") (lambda () (interactive) (swap-with 'left)))
(global-set-key (kbd "C-M-S-<right>") (lambda () (interactive) (swap-with 'right)))
(global-set-key (kbd "M-S-<up>") (lambda () (interactive) (enlarge-window 1)))
(global-set-key (kbd "M-S-<down>") (lambda () (interactive) (enlarge-window -1)))
(global-set-key (kbd "M-S-<right>") (lambda () (interactive) (enlarge-window -1 t)))
(global-set-key (kbd "M-S-<left>") (lambda () (interactive) (enlarge-window 1 t)))
(provide 'emacsd-tile)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment