From: Chris Hanson Date: Fri, 27 Oct 2000 04:00:34 +0000 (+0000) Subject: When killing buffer, it's possible to signal an error if there are no X-Git-Tag: 20090517-FFI~3207 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=167f2cce7151e962cfc6f46e7b683451d9c97c16;p=mit-scheme.git When killing buffer, it's possible to signal an error if there are no other buffers. Previously, this error could have been signalled _after_ the killing procedure had already killed off any buffer process, run the kill hooks, etc. Now the error test is done first, and if the error is signalled, no other action is taken. --- diff --git a/v7/src/edwin/curren.scm b/v7/src/edwin/curren.scm index bea561979..097821486 100644 --- a/v7/src/edwin/curren.scm +++ b/v7/src/edwin/curren.scm @@ -1,6 +1,6 @@ ;;; -*-Scheme-*- ;;; -;;; $Id: curren.scm,v 1.138 2000/10/27 03:16:20 cph Exp $ +;;; $Id: curren.scm,v 1.139 2000/10/27 04:00:34 cph Exp $ ;;; ;;; Copyright (c) 1986, 1989-2000 Massachusetts Institute of Technology ;;; @@ -411,6 +411,8 @@ The frame is guaranteed to be deselected at that time." (define (kill-buffer buffer) (without-interrupts (lambda () + (if (not (make-buffer-invisible buffer)) + (error "Buffer to be killed has no replacement" buffer)) (for-each (lambda (process) (hangup-process process #t) (set-process-buffer! process #f)) @@ -418,8 +420,6 @@ The frame is guaranteed to be deselected at that time." (for-each (lambda (hook) (hook buffer)) (get-buffer-hooks buffer 'KILL-BUFFER-HOOKS)) (delete-buffer-layout buffer) - (if (not (make-buffer-invisible buffer)) - (error "Buffer to be killed has no replacement" buffer)) (bufferset-kill-buffer! (current-bufferset) buffer)))) (define (make-buffer-invisible buffer) @@ -481,8 +481,7 @@ The frame is guaranteed to be deselected at that time." (define (change-selected-buffer window buffer record? selection-thunk) (change-local-bindings! (selected-buffer) buffer selection-thunk) (set-buffer-point! buffer (window-point window)) - (if record? - (bufferset-select-buffer! (current-bufferset) buffer)) + (if record? (bufferset-select-buffer! (current-bufferset) buffer)) (for-each (lambda (hook) (hook buffer window)) (get-buffer-hooks buffer 'SELECT-BUFFER-HOOKS)) (if (not (minibuffer? buffer)) @@ -564,18 +563,24 @@ The buffer is guaranteed to be selected at that time." (if (let loop ((buffers (cdr l2))) (or (not (weak-pair? buffers)) (and (let ((buffer (weak-car buffers))) - (and buffer (buffer-alive? buffer))) + (and buffer + (buffer-alive? buffer))) (loop (weak-cdr buffers))))) (begin - (hash-table/put! screen-buffer-layouts screen l2) (delete-other-windows window) + (hash-table/put! screen-buffer-layouts screen l2) l2) (begin (delete-buffer-layout-1 l2) #f)))))))) - + (define (maybe-deselect-buffer-layout screen) - (hash-table/remove! screen-buffer-layouts screen)) + (without-interrupts + (lambda () + (if (hash-table/get screen-buffer-layouts screen #f) + (begin + (hash-table/remove! screen-buffer-layouts screen) + (delete-other-windows (screen-selected-window screen))))))) (define (delete-buffer-layout buffer) ;; Caller disables interrupts.