Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

swaping buffers

0 views
Skip to first unread message

dydimustk

unread,
Mar 16, 2006, 2:09:57 PM3/16/06
to
I want to be able to quickly swap between the two open buffers I am
working on, while keeping the screen dimensions. I usually keep a
little buffer open at the bottom of the screen with erc running, and
I'm working in the top part.

____________
| |
| |
| |
|===========|
|-------------------|

I want to be able to just swap the top and bottom buffer, while keeping
the screen layout the same. Does anyone know if this is possible?

Kevin Rodgers

unread,
Mar 16, 2006, 4:35:58 PM3/16/06
to help-gn...@gnu.org

Window configurations record which buffer is displayed in each window,
so I think you need to explicitly save each configuration. See the
Saving Window Configurations in Registers node of the Emacs manual,
which also describes how to restore a saved configuration.

--
Kevin Rodgers

pookiebe...@yahoo.com

unread,
Mar 16, 2006, 5:45:57 PM3/16/06
to
How about recording a little macro

C-x b RET
C-x o
C-x b RET
C-x o
C-x b RET

Does that do what you want?

dydimustk

unread,
Mar 17, 2006, 2:12:44 AM3/17/06
to
It doesn't quite do what I want.
I'm using different buffers in top half than I am in the bottom half.
And I want to specifically swap out the top and bottom half without
losing the buffer sizes.

Mathias Dahl

unread,
Mar 17, 2006, 6:05:17 AM3/17/06
to
"dydimustk" <dydi...@gmail.com> writes:

The parent poster's solution does that, at least when I try. The
*window* sizes are the same.

This is my result:

Before:

+----------------+
| |
| Buf A |
| |
|----------------|
| Buf B |
+----------------+

+----------------+
| |
| Buf B |
| |
|----------------|
| Buf A |
+----------------+

Was this what you wanted:

+----------------+
| Buf A |
|----------------|
| |
| |
| Buf B |
+----------------+

?

Floyd L. Davidson

unread,
Mar 17, 2006, 7:32:26 AM3/17/06
to

Did you actually mean to say that you have two windows, top and
bottom, which you want to remain the same size while the buffers
being display in each is changed? For example, the top window is
always larger no matter which buffer is being display.

Here is a function which more or less does that, and works in
both Emacs and XEmacs. (It isn't well tested and may have a
surprise or two...) If there are three buffers displayed, it
flips between the current buffer and the one below it, or the
top buffer if the bottom buffer is current.

I've added comments to indicate what it is doing.

(defun fld-flip-buffers ()
"Flip buffers between two windows."
(interactive)
(if (not(one-window-p 't)) ; do nothing for only 1 window
(let ((w1 (selected-window)) ; save current window
(w2 (next-window)) ; save "next window"
(b1 (current-buffer))) ; save current buffer
(select-window w2) ; switch to "next window"
(set-window-buffer w1
(current-buffer)) ; display that buf in this window
(set-window-buffer w2 b1) ; display this buf in that window
(select-window w1)))) ; switch back to that window

Put that into your init file and bind it to some convenient key sequence.
For example, this binds it to the F5 function key:

(define-key global-map [f5] 'fld-flip-buffers)

--
Floyd L. Davidson <http://www.apaflo.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska) fl...@apaflo.com

0 new messages