Permalink
Browse files

basic windows layout utility

  • Loading branch information...
larsen committed Nov 15, 2015
1 parent 592272f commit cb37d713d598c30741b5e49f82e7a8f9251d2dc3
Showing with 29 additions and 0 deletions.
  1. +29 −0 larsen-functions.el
View
@@ -1,4 +1,33 @@
(defun osx-notify (title message)
(start-process "osx-notify" nil "terminal-notifier" "-title" title "-message" message))
+;; Windows layout
+
+(defun change-split-type (split-fn &optional arg)
+ "Change 3 window style from horizontal to vertical and vice-versa"
+ (let ((bufList (mapcar 'window-buffer (window-list))))
+ (select-window (get-largest-window))
+ (funcall split-fn arg)
+ (mapcar* 'set-window-buffer (window-list) bufList)))
+
+(defun change-split-type-2 (&optional arg)
+ "Changes splitting from vertical to horizontal and vice-versa"
+ (interactive "P")
+ (let ((split-type (lambda (&optional arg)
+ (delete-other-windows-internal)
+ (if arg (split-window-vertically)
+ (split-window-horizontally)))))
+ (change-split-type split-type arg)))
+
+(defvar *larsen/split-layout-type* t)
+
+(defun toggle-split-layout ()
+ (interactive)
+ (progn (change-split-type-2 *larsen/split-layout-type*)
+ (if *larsen/split-layout-type*
+ (setq *larsen/split-layout-type* nil)
+ (setq *larsen/split-layout-type* t))))
+
+(global-set-key (kbd "M-<f1>") 'toggle-split-layout)
+
(provide 'larsen-functions)

0 comments on commit cb37d71

Please sign in to comment.