Skip to content

Instantly share code, notes, and snippets.

@gilbertw1
Last active January 12, 2017 18:45
Show Gist options
  • Save gilbertw1/9f1651cc5054619c4d5fba8e8c20a344 to your computer and use it in GitHub Desktop.
Save gilbertw1/9f1651cc5054619c4d5fba8e8c20a344 to your computer and use it in GitHub Desktop.
;;; buffer-copy.el ---
;;; Code:
(require 'windmove)
;;;###autoload
(defun buf-copy-up ()
"Copy the current buffer to the buffer above the split.
If there is no split, ie now window above the current one, an
error is signaled."
;; "Switches between the current buffer, and the buffer above the
;; split, if possible."
(interactive)
(let ((buf (window-buffer)))
(windmove-up)
(set-window-buffer nil buf)))
;;;###autoload
(defun buf-copy-down ()
"Copy the current buffer to the buffer under the split.
If there is no split, ie now window under the current one, an
error is signaled."
(interactive)
(let ((buf (window-buffer)))
(windmove-down)
(set-window-buffer nil buf)))
;;;###autoload
(defun buf-copy-left ()
"Copy the current buffer to the buffer on the left of the split.
If there is no split, ie now window on the left of the current
one, an error is signaled."
(interactive)
(let ((buf (window-buffer)))
(windmove-left)
(set-window-buffer nil buf)))
;;;###autoload
(defun buf-copy-right ()
"Copy the current buffer to the buffer on the right of the split.
If there is no split, ie now window on the right of the current
one, an error is signaled."
(interactive)
(let ((buf (window-buffer)))
(windmove-right)
(set-window-buffer nil buf)))
(provide 'buffer-copy)
;;; buffer-move.el ends here
(spacemacs/set-leader-keys
"bh" 'buf-copy-left
"bj" 'buf-copy-down
"bk" 'buf-copy-up
"bl" 'buf-copy-right)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment