mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-25 04:40:19 +02:00
use *repl-stack* instead of *repl-level*
* module/ice-9/boot-9.scm (*repl-stack*): Instead of repl-level, have a stack. (batch-mode?): Change to poke the stack. * module/ice-9/deprecated.scm (set-batch-mode?!): Update deprecation method. * module/system/repl/common.scm (repl-prompt): Update to poke *repl-stack* to get the level. * module/system/repl/repl.scm (start-repl): Bind *repl-stack* appropriately.
This commit is contained in:
parent
9d2136ba40
commit
652f48c062
4 changed files with 15 additions and 10 deletions
|
@ -2684,14 +2684,14 @@ module '(ice-9 q) '(make-q q-length))}."
|
||||||
;;; {Running Repls}
|
;;; {Running Repls}
|
||||||
;;;
|
;;;
|
||||||
|
|
||||||
(define *repl-level* (make-fluid))
|
(define *repl-stack* (make-fluid))
|
||||||
|
|
||||||
;; Programs can call `batch-mode?' to see if they are running as part of a
|
;; Programs can call `batch-mode?' to see if they are running as part of a
|
||||||
;; script or if they are running interactively. REPL implementations ensure that
|
;; script or if they are running interactively. REPL implementations ensure that
|
||||||
;; `batch-mode?' returns #f during their extent.
|
;; `batch-mode?' returns #f during their extent.
|
||||||
;;
|
;;
|
||||||
(define (batch-mode?)
|
(define (batch-mode?)
|
||||||
(negative? (or (fluid-ref *repl-level*) -1)))
|
(null? (or (fluid-ref *repl-stack*) '())))
|
||||||
|
|
||||||
;; Programs can re-enter batch mode, for example after a fork, by calling
|
;; Programs can re-enter batch mode, for example after a fork, by calling
|
||||||
;; `ensure-batch-mode!'. It's not a great interface, though; it would be better
|
;; `ensure-batch-mode!'. It's not a great interface, though; it would be better
|
||||||
|
|
|
@ -616,7 +616,7 @@ the `(system repl common)' module.")
|
||||||
(else
|
(else
|
||||||
(issue-deprecation-warning
|
(issue-deprecation-warning
|
||||||
"`set-batch-mode?!' with an argument of `#f' is deprecated. Use the
|
"`set-batch-mode?!' with an argument of `#f' is deprecated. Use the
|
||||||
`*repl-level*' fluid instead.")
|
`*repl-stack*' fluid instead.")
|
||||||
#t)))
|
#t)))
|
||||||
|
|
||||||
(define (repl read evaler print)
|
(define (repl read evaler print)
|
||||||
|
|
|
@ -130,7 +130,7 @@ See <http://www.gnu.org/licenses/lgpl.html>, for more details.")
|
||||||
(else
|
(else
|
||||||
(format #f "~A@~A~A> " (language-name (repl-language repl))
|
(format #f "~A@~A~A> " (language-name (repl-language repl))
|
||||||
(module-name (current-module))
|
(module-name (current-module))
|
||||||
(let ((level (or (fluid-ref *repl-level*) 0)))
|
(let ((level (length (or (fluid-ref *repl-stack*) '()))))
|
||||||
(if (zero? level) "" (format #f " [~a]" level)))))))
|
(if (zero? level) "" (format #f " [~a]" level)))))))
|
||||||
|
|
||||||
(define (repl-read repl)
|
(define (repl-read repl)
|
||||||
|
|
|
@ -60,18 +60,23 @@
|
||||||
(current-module))))
|
(current-module))))
|
||||||
#:on-error 'pass))
|
#:on-error 'pass))
|
||||||
|
|
||||||
(define* (start-repl #:optional (lang (current-language)) #:key
|
|
||||||
(level (1+ (or (fluid-ref *repl-level*) -1)))
|
|
||||||
(welcome (equal? level 0)))
|
;;;
|
||||||
|
;;; The repl
|
||||||
|
;;;
|
||||||
|
|
||||||
|
(define* (start-repl #:optional (lang (current-language)))
|
||||||
(let ((repl (make-repl lang))
|
(let ((repl (make-repl lang))
|
||||||
(status #f))
|
(status #f))
|
||||||
(if welcome
|
(with-fluids ((*repl-stack* (cons repl
|
||||||
(repl-welcome repl))
|
(or (fluid-ref *repl-stack*) '())))
|
||||||
(with-fluids ((*repl-level* level)
|
|
||||||
(*debug-input-port*
|
(*debug-input-port*
|
||||||
(or (fluid-ref *debug-input-port*) (current-input-port)))
|
(or (fluid-ref *debug-input-port*) (current-input-port)))
|
||||||
(*debug-output-port*
|
(*debug-output-port*
|
||||||
(or (fluid-ref *debug-output-port*) (current-output-port))))
|
(or (fluid-ref *debug-output-port*) (current-output-port))))
|
||||||
|
(if (null? (cdr (fluid-ref *repl-stack*)))
|
||||||
|
(repl-welcome repl))
|
||||||
(let prompt-loop ()
|
(let prompt-loop ()
|
||||||
(let ((exp (prompting-meta-read repl)))
|
(let ((exp (prompting-meta-read repl)))
|
||||||
(cond
|
(cond
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue