home *** CD-ROM | disk | FTP | other *** search
- ;; window-ring.el
- ;; Simple window configuration management
-
- (defun put-at-end (elem list)
- (if (cdr list) (cons (car list) (put-at-end elem (cdr list)))
- (cons (car list) (list elem))))
-
- (defun rotate-ring (ring)
- (cond ((not ring) ()) ; There is no ring to rotate
- ((not (cdr ring)) ring) ; Ring has one member
- (t (put-at-end (car ring) (cdr ring)))))
-
- (defun prepend-ring (elem ring)
- (cons elem ring))
-
- (defun chop-ring (ring)
- (if (not ring) ()
- (cdr ring)))
-
- (defun ring-size (ring)
- (if (not ring) 0
- (+ 1 (ring-size (cdr ring)))))
-
- (defvar window-config-ring ()) ; Start with a null ring
-
- (defun chop-window-config-ring ()
- (interactive)
- (setq window-config-ring
- (chop-ring window-config-ring))
- (message (format "window ring size:%d" (ring-size window-config-ring))))
-
- (defun add-to-window-config-ring ()
- (interactive)
- (message "window configuration saved")
- (setq window-config-ring
- (prepend-ring (current-window-configuration) window-config-ring)))
-
- (defun rotate-window-config-ring ()
- (interactive)
- (if (not window-config-ring) (message "No configurations saved")
- (message "Moving thru' window ring...")
- (setq window-config-ring (rotate-ring window-config-ring))
- (set-window-configuration (car window-config-ring))
- (redraw-display)))
-
- (global-set-key "\C-c\C-a" 'add-to-window-config-ring)
- (global-set-key "\C-t" 'rotate-window-config-ring)
- (global-set-key "\C-c\C-q" 'chop-window-config-ring)
-