home *** CD-ROM | disk | FTP | other *** search
- ;;;; windows.jl -- Window handling
- ;;; Copyright (C) 1993, 1994 John Harper <jsh@ukc.ac.uk>
-
- ;;; This file is part of Jade.
-
- ;;; Jade is free software; you can redistribute it and/or modify it
- ;;; under the terms of the GNU General Public License as published by
- ;;; the Free Software Foundation; either version 2, or (at your option)
- ;;; any later version.
-
- ;;; Jade is distributed in the hope that it will be useful, but
- ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
- ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ;;; GNU General Public License for more details.
-
- ;;; You should have received a copy of the GNU General Public License
- ;;; along with Jade; see the file COPYING. If not, write to
- ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
- (setq window-list (cons (current-window) nil))
-
- (defun open-window (&optional buffer x y w h)
- "(open-window [BUFFER] [X] [Y] [WIDTH] [HEIGHT])
- Creates a new window display BUFFER or the buffer that the current window is
- showing."
- (let
- ((old-buf-list buffer-list)
- win)
- (unless buffer
- (setq buffer (current-buffer)))
- (when (setq win (make-window x y w h))
- (setq window-list (cons win window-list))
- (with-window win
- (setq buffer-list (cons buffer (delq buffer (copy-list old-buf-list))))
- (set-current-buffer buffer win))
- win)))
-
- (defun close-window (&optional win)
- "(close-window [WIN])
- Close window WIN, or the current window."
- (unless win
- (setq win (current-window)))
- (if (= (window-count) 1)
- (save-and-quit)
- (setq window-list (delq win window-list))
- (destroy-window win)))
-
- (defun close-other-windows (&optional win)
- "(close-other-windows [WIN])
- Close all windows except for WIN, or the current one."
- (unless win
- (setq win (current-window)))
- (setq window-list (delq win window-list))
- (while window-list
- (destroy-window (car window-list))
- (setq window-list (cdr window-list)))
- (setq window-list (cons win nil)))
-
- (defun add-buffer (buffer)
- "(add-buffer BUFFER)
- Make sure that BUFFER is in the `buffer-list' of all open windows. It gets
- put at the end of the list."
- (let
- ((win-list window-list))
- (while (consp win-list)
- (with-window (car win-list)
- (setq buffer-list (nconc (delq buffer buffer-list) (cons buffer nil))))
- (setq win-list (cdr win-list)))))
-
- (defun remove-buffer (buffer)
- "(remove-buffer BUFFER)
- Delete all references to BUFFER in any of the windows' `buffer-list'"
- (let
- ((win-list window-list))
- (while (consp win-list)
- (with-window (car win-list)
- (setq buffer-list (delq buffer buffer-list))
- (when (eq (current-buffer (car win-list)) buffer)
- (set-current-buffer (car buffer-list) (car win-list))))
- (setq win-list (cdr win-list)))))
-
- (defmacro in-other-window (&rest body)
- "(in-other-window BODY...) <MACRO>
- Switches to the ``other'' window and evaluates BODY in it."
- (cons 'progn (cons '(goto-other-window) body)))
-
- (defun goto-other-window ()
- "(goto-other-window)
- Switch to the ``other'' window."
- (set-current-window
- (if (= 1 (window-count))
- (open-window)
- (if (eq (car window-list) (current-window))
- (car (cdr window-list))
- (car window-list)))
- t))
-