From 4bcfb672357b5840249c72b28cb860001c4e3967 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sun, 26 Jan 2014 02:00:22 -0500 Subject: Reorganize and use require-package `require-package' is from https://github.com/purcell/emacs.d/blob/master/lisp/init-elpa.el. --- lisp/init-framewin.el | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 lisp/init-framewin.el (limited to 'lisp/init-framewin.el') diff --git a/lisp/init-framewin.el b/lisp/init-framewin.el new file mode 100644 index 0000000..cbcce94 --- /dev/null +++ b/lisp/init-framewin.el @@ -0,0 +1,37 @@ +;;; Frames and windows + +;; From prelude +(defun km/swap-windows () + "If you have 2 windows, it swaps them." + (interactive) + (if (/= (count-windows) 2) + (message "You need exactly 2 windows to do this.") + (let* ((w1 (car (window-list))) + (w2 (cadr (window-list))) + (b1 (window-buffer w1)) + (b2 (window-buffer w2)) + (s1 (window-start w1)) + (s2 (window-start w2))) + (set-window-buffer w1 b2) + (set-window-buffer w2 b1) + (set-window-start w1 s2) + (set-window-start w2 s1))) + (other-window 1)) + +;; http://www.emacswiki.org/emacs/ToggleWindowSplit +(defun km/switch-frame-split () + "If the frame is split vertically, split it horizontally or vice versa. +Assumes that the frame is only split into two." + (interactive) + (unless (= (length (window-list)) 2) + (error "Can only toggle a frame split in two")) + (let ((split-vertically-p (window-combined-p))) + (delete-window) + (if split-vertically-p + (split-window-horizontally) + (split-window-vertically)) + (switch-to-buffer nil))) + +(global-set-key (kbd "C-c s") 'km/swap-windows) + +(provide 'init-framewin) -- cgit v1.2.3