unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: floyd@apaflo.com (Floyd L. Davidson)
Subject: Re: swaping buffers
Date: Fri, 17 Mar 2006 03:32:26 -0900	[thread overview]
Message-ID: <877j6tjlph.fld@apaflo.com> (raw)
In-Reply-To: 1142579564.152836.87160@p10g2000cwp.googlegroups.com

"dydimustk" <dydimustk@gmail.com> wrote:
>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.

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)                         floyd@apaflo.com

      parent reply	other threads:[~2006-03-17 12:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-16 19:09 swaping buffers dydimustk
2006-03-16 21:35 ` Kevin Rodgers
     [not found] ` <mailman.147.1142545046.9686.help-gnu-emacs@gnu.org>
2006-03-16 22:45   ` pookiebearbottom
2006-03-17  7:12     ` dydimustk
2006-03-17 11:05       ` Mathias Dahl
2006-03-17 12:32       ` Floyd L. Davidson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877j6tjlph.fld@apaflo.com \
    --to=floyd@apaflo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).