home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / GNU / emacs.inst / emacs19.idb / usr / gnu / lib / emacs / site-lisp / window-ring.el.z / window-ring.el
Encoding:
Text File  |  1994-08-02  |  1.4 KB  |  49 lines

  1. ;; window-ring.el
  2. ;; Simple window configuration management
  3.  
  4. (defun put-at-end (elem list)
  5.   (if (cdr list) (cons (car list) (put-at-end elem (cdr list)))
  6.     (cons (car list) (list elem))))
  7.  
  8. (defun rotate-ring (ring)
  9.   (cond ((not ring) ())         ; There is no ring to rotate
  10.     ((not (cdr ring)) ring) ; Ring has one member
  11.     (t (put-at-end (car ring) (cdr ring)))))
  12.     
  13. (defun prepend-ring (elem ring)
  14.   (cons elem ring))
  15.  
  16. (defun chop-ring (ring)
  17.   (if (not ring) ()
  18.     (cdr ring)))
  19.  
  20. (defun ring-size (ring)
  21.   (if (not ring) 0
  22.     (+ 1 (ring-size (cdr ring)))))
  23.     
  24. (defvar window-config-ring ()) ; Start with a null ring
  25.  
  26. (defun chop-window-config-ring ()
  27.   (interactive)
  28.   (setq window-config-ring
  29.     (chop-ring window-config-ring))
  30.   (message (format "window ring size:%d" (ring-size window-config-ring))))
  31.  
  32. (defun add-to-window-config-ring ()
  33.   (interactive)
  34.   (message "window configuration saved")
  35.   (setq window-config-ring
  36.     (prepend-ring (current-window-configuration) window-config-ring)))
  37.  
  38. (defun rotate-window-config-ring ()
  39.   (interactive)
  40.   (if (not window-config-ring) (message "No configurations saved")
  41.     (message "Moving thru' window ring...")
  42.     (setq window-config-ring (rotate-ring window-config-ring))
  43.     (set-window-configuration (car window-config-ring))
  44.     (redraw-display)))
  45.  
  46. (global-set-key "\C-c\C-a" 'add-to-window-config-ring)
  47. (global-set-key "\C-t" 'rotate-window-config-ring)
  48. (global-set-key "\C-c\C-q" 'chop-window-config-ring)
  49.