123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- (require 'windmove)
- (defun buf-move-up ()
- "Swap the current buffer and the buffer above the split.
- If there is no split, ie now window above the current one, an
- error is signaled."
- (interactive)
- (let* ((other-win (windmove-find-other-window 'up))
- (buf-this-buf (window-buffer (selected-window))))
- (if (null other-win)
- (error "No window above this one")
-
- (set-window-buffer (selected-window) (window-buffer other-win))
-
- (set-window-buffer other-win buf-this-buf)
- (select-window other-win))))
- (defun buf-move-down ()
- "Swap the current buffer and the buffer under the split.
- If there is no split, ie now window under the current one, an
- error is signaled."
- (interactive)
- (let* ((other-win (windmove-find-other-window 'down))
- (buf-this-buf (window-buffer (selected-window))))
- (if (or (null other-win)
- (string-match "^ \\*Minibuf" (buffer-name (window-buffer other-win))))
- (error "No window under this one")
-
- (set-window-buffer (selected-window) (window-buffer other-win))
-
- (set-window-buffer other-win buf-this-buf)
- (select-window other-win))))
- (defun buf-move-left ()
- "Swap the current buffer and 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* ((other-win (windmove-find-other-window 'left))
- (buf-this-buf (window-buffer (selected-window))))
- (if (null other-win)
- (error "No left split")
-
- (set-window-buffer (selected-window) (window-buffer other-win))
-
- (set-window-buffer other-win buf-this-buf)
- (select-window other-win))))
- (defun buf-move-right ()
- "Swap the current buffer and 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* ((other-win (windmove-find-other-window 'right))
- (buf-this-buf (window-buffer (selected-window))))
- (if (null other-win)
- (error "No right split")
-
- (set-window-buffer (selected-window) (window-buffer other-win))
-
- (set-window-buffer other-win buf-this-buf)
- (select-window other-win))))
- (provide 'buffer-move)
|