Cause `edwin-initialization' to be executed inside the command loop so
authorChris Hanson <org/chris-hanson/cph>
Fri, 11 Aug 1989 16:17:58 +0000 (16:17 +0000)
committerChris Hanson <org/chris-hanson/cph>
Fri, 11 Aug 1989 16:17:58 +0000 (16:17 +0000)
that all of the editor's dynamic-state is bound.

v7/src/edwin/comred.scm
v7/src/edwin/editor.scm

index 79f138b1129f972507661fe5f757d551859ea7d9..e6c866c8b241d2d1b8b79d336fecaefbbacc7f7d 100644 (file)
@@ -1,6 +1,6 @@
 ;;; -*-Scheme-*-
 ;;;
-;;;    $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/comred.scm,v 1.79 1989/08/11 10:51:02 cph Exp $
+;;;    $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/comred.scm,v 1.80 1989/08/11 16:17:44 cph Exp $
 ;;;
 ;;;    Copyright (c) 1986, 1989 Massachusetts Institute of Technology
 ;;;
   (set! command-history (make-circular-list command-history-limit false))
   unspecific)
 
-(define (command-history-list)
-  (let loop ((history command-history))
-    (if (car history)
-       (let loop ((history (cdr history)) (result (list (car history))))
-         (if (eq? history command-history)
-             result
-             (loop (cdr history) (cons (car history) result))))
-       (let ((history (cdr history)))
-         (if (eq? history command-history)
-             '()
-             (loop history))))))
-
-(define (top-level-command-reader)
+(define (top-level-command-reader initialization)
   (let loop ()
     (with-keyboard-macro-disabled
      (lambda ()
        (intercept-^G-interrupts (lambda () unspecific)
-                               command-reader)))
+        (lambda ()
+          (command-reader initialization)))))
     (loop)))
 
-(define (command-reader)
+(define (command-reader #!optional initialization)
   (define (command-reader-loop)
-    (let ((value
-          (call-with-current-continuation
-           (lambda (continuation)
-             (fluid-let ((*command-continuation* continuation)
-                         (*command-char*)
-                         (*command*)
-                         (*next-message* false))
-               (start-next-command))))))
-      (if (not (eq? value 'ABORT)) (value)))
+    (let ((value (with-command-variables start-next-command)))
+      (if (not (eq? value 'ABORT))
+         (value)))
     (command-reader-loop))
 
+  (define (with-command-variables start-next-command)
+    (call-with-current-continuation
+     (lambda (continuation)
+       (fluid-let ((*command-continuation* continuation)
+                  (*command-char*)
+                  (*command*)
+                  (*next-message* false))
+        (start-next-command)))))
+
   (define (start-next-command)
     (reset-command-state!)
     (let ((char (with-editor-interrupts-disabled keyboard-read-char)))
 
   (fluid-let ((*command-message*)
              (*non-undo-count* 0))
-    (with-command-argument-reader command-reader-loop)))
+    (with-command-argument-reader
+     (lambda ()
+       (if (and (not (default-object? initialization)) initialization)
+          (with-command-variables
+           (lambda ()
+             (reset-command-state!)
+             (initialization))))
+       (command-reader-loop)))))
 
 (define (reset-command-state!)
   (reset-command-argument-reader!)
   (if (and *command-message*
           (eq? (car *command-message*) tag))
       (apply if-received (cdr *command-message*))
-      (if-not-received)))\f
+      (if-not-received)))
+
+(define (command-history-list)
+  (let loop ((history command-history))
+    (if (car history)
+       (let loop ((history (cdr history)) (result (list (car history))))
+         (if (eq? history command-history)
+             result
+             (loop (cdr history) (cons (car history) result))))
+       (let ((history (cdr history)))
+         (if (eq? history command-history)
+             '()
+             (loop history))))))
+\f
 (define (%dispatch-on-command window command record?)
   (set! *command* command)
   (guarantee-command-loaded command)
index d5e1452abf85eedf25f8737ea53f0bb5ef36f0dc..7e8dc778779efb08907d6edea2a4877c4346277b 100644 (file)
@@ -1,6 +1,6 @@
 ;;; -*-Scheme-*-
 ;;;
-;;;    $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/editor.scm,v 1.190 1989/08/11 11:50:27 cph Exp $
+;;;    $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/editor.scm,v 1.191 1989/08/11 16:17:58 cph Exp $
 ;;;
 ;;;    Copyright (c) 1986, 1989 Massachusetts Institute of Technology
 ;;;
                               (dynamic-wind
                                (lambda () (update-screens! true))
                                (lambda ()
-                                 ;; Should this be in a dynamic wind? -- Jinx
-                                 (if edwin-initialization
-                                     (edwin-initialization))
                                  (let ((message (cmdl-message/null)))
                                    (push-cmdl (lambda (cmdl)
                                                 cmdl ;ignore
-                                                (top-level-command-reader)
+                                                (top-level-command-reader
+                                                 edwin-initialization)
                                                 message)
                                               false
                                               message)))
                                (lambda () unspecific)))))))))))))))))
-  ;; Should this be here or in a dynamic wind? -- Jinx
   (if edwin-finalization (edwin-finalization))
   unspecific)
 
@@ -88,7 +85,8 @@
 
 ;; Set this before entering the editor to get something done after the
 ;; editor's dynamic environment is initialized, but before the command
-;; loop is started.  [Should this bind the ^G interrupt also? -- CPH](define edwin-initialization false)
+;; loop is started.
+(define edwin-initialization false)
 
 ;; Set this while in the editor to get something done after leaving
 ;; the editor's dynamic environment; for example, this can be used to