Created
February 12, 2014 21:01
-
-
Save hub-cap/8964433 to your computer and use it in GitHub Desktop.
i totally stole this from someone!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Buffer indention stuff, either indent region or buffer w/ a C-M-\ | |
(defun indent-buffer () | |
"Indent the currently visited buffer." | |
(interactive) | |
(indent-region (point-min) (point-max))) | |
(defun indent-region-or-buffer () | |
"Indent a region if selected, otherwise the whole buffer." | |
(interactive) | |
(save-excursion | |
(if (region-active-p) | |
(progn | |
(indent-region (region-beginning) (region-end)) | |
(message "Indented selected region.")) | |
(progn | |
(indent-buffer) | |
(message "Indented buffer."))))) | |
(global-set-key (kbd "C-M-\\") 'indent-region-or-buffer) | |
;; toggle-window-split ftw (it changes 2 vert to 2 horiz and back | |
(defun toggle-window-split () | |
(interactive) | |
(if (= (count-windows) 2) | |
(let* ((this-win-buffer (window-buffer)) | |
(next-win-buffer (window-buffer (next-window))) | |
(this-win-edges (window-edges (selected-window))) | |
(next-win-edges (window-edges (next-window))) | |
(this-win-2nd (not (and (<= (car this-win-edges) | |
(car next-win-edges)) | |
(<= (cadr this-win-edges) | |
(cadr next-win-edges))))) | |
(splitter | |
(if (= (car this-win-edges) | |
(car (window-edges (next-window)))) | |
'split-window-horizontally | |
'split-window-vertically))) | |
(delete-other-windows) | |
(let ((first-win (selected-window))) | |
(funcall splitter) | |
(if this-win-2nd (other-window 1)) | |
(set-window-buffer (selected-window) this-win-buffer) | |
(set-window-buffer (next-window) next-win-buffer) | |
(select-window first-win) | |
(if this-win-2nd (other-window 1)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment