summaryrefslogtreecommitdiff
path: root/lisp/init-framewin.el
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2014-01-26 02:00:22 -0500
committerKyle Meyer <kyle@kyleam.com>2014-01-26 02:00:22 -0500
commit4bcfb672357b5840249c72b28cb860001c4e3967 (patch)
tree13e236eaccfdf6985e576f3b07bdec937f2f7955 /lisp/init-framewin.el
parent7869360008d87ca4b459c703f4894625dd8181cc (diff)
downloademacs.d-4bcfb672357b5840249c72b28cb860001c4e3967.tar.gz
Reorganize and use require-package
`require-package' is from https://github.com/purcell/emacs.d/blob/master/lisp/init-elpa.el.
Diffstat (limited to 'lisp/init-framewin.el')
-rw-r--r--lisp/init-framewin.el37
1 files changed, 37 insertions, 0 deletions
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)