home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / gnu / emacs / help / 4830 < prev    next >
Encoding:
Text File  |  1992-11-17  |  2.2 KB  |  68 lines

  1. Path: sparky!uunet!convex!darwin.sura.net!tulane!uflorida!travis.csd.harris.com!travis!jimbo
  2. From: jimbo@rcx1.ssd.csd.harris.com (Jim Winters)
  3. Newsgroups: gnu.emacs.help
  4. Subject: Re: cycling window positions
  5. Message-ID: <JIMBO.92Nov17134130@rcx1.ssd.csd.harris.com>
  6. Date: 17 Nov 92 18:41:30 GMT
  7. References: <LYNN.92Nov16082256@ives.urbana.mcd.mot.com>
  8. Distribution: gnu
  9. Organization: Harris Computer Systems Division
  10. Lines: 54
  11. NNTP-Posting-Host: rcx1.ssd.csd.harris.com
  12. In-reply-to: lynn@urbana.mcd.mot.com's message of Mon, 16 Nov 1992 13:22:56 GMT
  13.  
  14. Lynn> Has anybody out there already written a function that is able to cycle
  15. Lynn> the position of windows in the following way? I'll use 3 windows for
  16. Lynn> example. I have:
  17.  
  18. Lynn> And so forth, so that the contents of the second window is now in the
  19. Lynn> top window, the third is now second, and the top is shoved down to the
  20. Lynn> bottom. I'd like this to be able to work however many windows I've
  21. Lynn> got. Of course I'd also like to be a numeric argument, including
  22. Lynn> negative, to be able to cycle some number of positions.
  23.  
  24. Your lucky day!  :-)
  25.  
  26. (But what I'd really like is to be able to put a window somewhere and
  27. have it STAY THERE.  :-)
  28.  
  29. ;;
  30. ;;    transpose-windows
  31. ;;
  32. (defun transpose-windows (arg)
  33.   "Move buffer displayed in the selected window to the ARG'th window.
  34. The other buffers slide down to make room."
  35.   (interactive "p")
  36.   (if (or
  37.        (one-window-p t)    ;; If there's only one window, or
  38.        (equal (minibuffer-window) (selected-window))    ;; m.b. is selected
  39.        )
  40.       nil    ;; then do nothing
  41.     (let ((fun (if (> arg 0) 'next-window 'previous-window))
  42.       )
  43.       (while (/= arg 0)
  44.     (let* ((this-win (selected-window))
  45.            (oth-win (funcall fun (selected-window)))
  46.            (this-buf (window-buffer this-win))
  47.            (oth-buf (window-buffer oth-win))
  48.            )
  49.       (set-window-buffer this-win (buffer-name oth-buf))
  50.       (set-window-buffer oth-win (buffer-name this-buf))
  51.       (select-window oth-win)
  52.       )
  53.     (if (< arg 0)
  54.         (setq arg (1+ arg))
  55.       (setq arg (1- arg))
  56.       )
  57.     )
  58.       )
  59.     )
  60.   )
  61.  
  62. (define-key ctl-x-map "T" 'transpose-windows)
  63. --
  64.  
  65. --
  66. Jim Winters    jimbo@ssd.csd.harris.com
  67. ]O    See through science part of a backdoor.  A door made up of doors...
  68.