Last active
August 29, 2015 14:02
-
-
Save djg/af42e453e06f47c568e0 to your computer and use it in GitHub Desktop.
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
;; I'm always opening a buffer in the wrong window. These function | |
;; help move the newly opened buffer to another window and restore the | |
;; buffer I was previously looking at. | |
(defun djg/buf-move (dir errmsg) | |
(let* ((other-win (windmove-find-other-window dir)) | |
(buf-this-buf (window-buffer (selected-window)))) | |
(if (null other-win) | |
(error errmsg) | |
(set-window-buffer other-win buf-this-buf) | |
(switch-to-prev-buffer)))) | |
(defun djg/buf-move-left () | |
"Move the current buffer left and replace with previous buffer. | |
If there is no split, ie no window on the left of the current | |
one, an error is signaled." | |
(interactive) | |
(djg/buf-move 'left "No left split")) | |
(defun djg/buf-move-right () | |
"Move the current buffer right and replace with previous buffer. | |
If there is no split, ie no window on the right of the current | |
one, an error is signaled." | |
(interactive) | |
(djg/buf-move 'right "No right split")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment