home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: gnu.emacs.help
- Path: sparky!uunet!convex!darwin.sura.net!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!cbnewsm!cbnewsl!att-out!cbfsb!cbnewsb!mviae!mvjrs
- From: mvjrs@mviae.ATT.COM (Rick Sladkey)
- Subject: Re: cycling window positions
- In-Reply-To: lynn@urbana.mcd.mot.com's message of Mon, 16 Nov 1992 13:22:56 GMT
- Message-ID: <MVJRS.92Nov17130906@mviae.ATT.COM>
- Originator: news@cbnewsb.cb.att.com
- Lines: 52
- Sender: news@cbfsb.cb.att.com
- Nntp-Posting-Host: mviae-gw.cnet.att.com
- Organization: AT&T Network Systems
- References: <LYNN.92Nov16082256@ives.urbana.mcd.mot.com>
- Distribution: gnu
- Date: Tue, 17 Nov 1992 18:09:06 GMT
-
- >>>>> On Mon, 16 Nov 1992 13:22:56 GMT, lynn@urbana.mcd.mot.com (Lynn
- >>>>> D. Newton) said:
-
-
- Lynn> Has anybody out there already written a function that is able to
- Lynn> cycle the position of windows in the following way? I'll use 3
- Lynn> windows for example. I have:
-
- I've wanted that before so I just wrote one. Here it is.
- -----
- ;;; rotbuf.el - rotate buffers in windows - rick sladkey
-
- ;; example .emacs usage:
- ;;
- ;; (global-set-key "\C-c\C-r" 'rotate-window-buffers)
- ;; (autoload 'rotate-window-buffers "rotbuf" "Rotate buffers in windows." t)
-
- (defun window-buffer-lists ()
- (let* ((first-window (selected-window))
- (window (next-window first-window 'no-minibuf))
- (win-list (list first-window))
- (buf-list (list (window-buffer first-window))))
- (while (not (eq window first-window))
- (setq win-list (cons window win-list))
- (setq buf-list (cons (window-buffer window) buf-list))
- (setq window (next-window window 'no-minibuf)))
- (cons (nreverse win-list) (nreverse buf-list))))
-
- (defun rotate-window-buffers (n)
- "Rotate visible buffers within their respective windows.
- With an argument, rotate them through ARG windows."
- (interactive "p")
- (let* ((lists (window-buffer-lists))
- (win-list (car lists))
- (buf-list (cdr lists))
- (length (length win-list)))
- (setq n (mod (+ (mod n length) length) length))
- (if (= n 0)
- (message "Thanks, but no thanks.")
- (let* ((last (nthcdr (1- n) buf-list))
- (rest (cdr last)))
- (setcdr last nil)
- (setq buf-list (nconc rest buf-list)))
- (while win-list
- (set-window-buffer (car win-list) (car buf-list))
- (setq win-list (cdr win-list))
- (setq buf-list (cdr buf-list))))))
-
-
- --
- Rick Sladkey
- mvjrs@mviae.ATT.COM
-