Skip to content

Instantly share code, notes, and snippets.

@danmayer
Created June 5, 2011 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danmayer/1009137 to your computer and use it in GitHub Desktop.
Save danmayer/1009137 to your computer and use it in GitHub Desktop.
This function makes emacs move the current buffer to another window. It also closes the current tab and sets focus on the new buffer
;; move buffer to other window
;; after c-x 3 to split screen this lets you move buffers between sides.
;; altered code from:
;; http://stackoverflow.com/questions/1774832/how-to-swap-the-buffers-in-2-windows-emacs
(defun swap-buffer-window ()
"Put the buffer from the selected window in next window, and vice versa"
(interactive)
(let* ((this (selected-window))
(other (next-window))
(this-buffer (window-buffer this)))
(set-window-buffer other this-buffer)
(tabbar-close-tab) ;;close current tab
(other-window 1) ;;swap cursor to new buffer
)
)
(global-set-key (kbd "C-x /") 'swap-buffer-window)
@danmayer
Copy link
Author

danmayer commented Jun 5, 2011

If you don't use tabs just comment out the tabbar-close-tab function call

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment