Commits

Mike Steder  committed c06d204

Added snippet for swapping buffer windows

  • Participants
  • Parent commits 8e07ffe

Comments (0)

Files changed (1)

File emacs.d/misc.el

 (global-undo-tree-mode)
 
 
+;; You've split the window into two buffers?
+;; But you wanted the new buffer on the left?
+;; Try this!
+(defun rwd-swap-buffers ()
+  "Swap the current 2 buffers in their windows"
+  (interactive)
+  (if (one-window-p)
+      (error "Frame doesn't have two windows")
+    (let* ((cw (selected-window))
+           (nw (next-window cw))
+           (cb (buffer-name (window-buffer cw)))
+           (nb (buffer-name (window-buffer nw))))
+      (switch-to-buffer nb)
+      (select-window nw)
+      (switch-to-buffer cb))))