mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-29 19:30:36 +02:00
readline repl-reader falls back to boot-9 definition for other ports
* guile-readline/ice-9/readline.scm (readline-repl-reader): Pull definition out of activate-readline. If the current input port is not the readline port, fall back to the boot-9 repl reader. (activate-readline): Adapt.
This commit is contained in:
parent
41e826492a
commit
1924145df5
1 changed files with 25 additions and 18 deletions
|
@ -200,26 +200,33 @@
|
|||
(lambda ()
|
||||
(set! *readline-completion-function* old-completer)))))
|
||||
|
||||
(define readline-repl-reader
|
||||
(let ((boot-9-repl-reader repl-reader))
|
||||
(lambda* (repl-prompt #:optional (reader (fluid-ref current-reader)))
|
||||
(let ((port (current-input-port)))
|
||||
(if (eq? port (readline-port))
|
||||
(let ((outer-new-input-prompt new-input-prompt)
|
||||
(outer-continuation-prompt continuation-prompt)
|
||||
(outer-read-hook read-hook))
|
||||
(dynamic-wind
|
||||
(lambda ()
|
||||
(set-buffered-input-continuation?! port #f)
|
||||
(set-readline-prompt! repl-prompt "... ")
|
||||
(set-readline-read-hook! (lambda ()
|
||||
(run-hook before-read-hook))))
|
||||
(lambda () ((or reader read) port))
|
||||
(lambda ()
|
||||
(set-readline-prompt! outer-new-input-prompt
|
||||
outer-continuation-prompt)
|
||||
(set-readline-read-hook! outer-read-hook))))
|
||||
(boot-9-repl-reader repl-prompt reader))))))
|
||||
|
||||
(define-public (activate-readline)
|
||||
(if (isatty? (current-input-port))
|
||||
(let ((repl-read-hook (lambda () (run-hook before-read-hook))))
|
||||
(set-current-input-port (readline-port))
|
||||
(set! repl-reader
|
||||
(lambda* (repl-prompt
|
||||
#:optional (reader (fluid-ref current-reader)))
|
||||
(let ((outer-new-input-prompt new-input-prompt)
|
||||
(outer-continuation-prompt continuation-prompt)
|
||||
(outer-read-hook read-hook))
|
||||
(dynamic-wind
|
||||
(lambda ()
|
||||
(set-buffered-input-continuation?! (readline-port) #f)
|
||||
(set-readline-prompt! repl-prompt "... ")
|
||||
(set-readline-read-hook! repl-read-hook))
|
||||
(lambda () ((or reader read) (current-input-port)))
|
||||
(lambda ()
|
||||
(set-readline-prompt! outer-new-input-prompt outer-continuation-prompt)
|
||||
(set-readline-read-hook! outer-read-hook))))))
|
||||
(set! (using-readline?) #t))))
|
||||
(begin
|
||||
(set-current-input-port (readline-port))
|
||||
(set! repl-reader readline-repl-reader)
|
||||
(set! (using-readline?) #t))))
|
||||
|
||||
(define-public (make-completion-function strings)
|
||||
"Construct and return a completion function for a list of strings.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue