1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-29 19:30:36 +02:00

Better REPL behavior on syntax errors in meta commands.

Fixes <https://bugs.gnu.org/30600>.

* module/system/repl/command.scm (define-meta-command): Flush all
remaining input after handling a read error.
* module/system/repl/common.scm (flush-all-input): New public procedure.
* module/system/repl/repl.scm: Remove local flush-all-input definition.
This commit is contained in:
Taylan Kammer 2021-05-18 18:15:08 +02:00 committed by Daniel Llorens
parent 818b879b2e
commit 242e8698c2
3 changed files with 12 additions and 9 deletions

View file

@ -229,7 +229,10 @@
(lp (cons x out)))))))
(lambda (k . args)
(handle-read-error #f k args)))))
(lambda (k) #f))))) ; the abort handler
;; The abort handler:
(lambda (k)
(flush-all-input)
#f)))))
((_ ((name category) repl . datums) docstring b0 b1 ...)
(define-meta-command ((name category) repl () . datums)

View file

@ -33,7 +33,7 @@
repl-expand repl-optimize repl-optimize-cps
repl-parse repl-print repl-option-ref repl-option-set!
repl-default-option-set! repl-default-prompt-set!
puts ->string user-error
puts ->string user-error flush-all-input
*warranty* *copying* *version*))
(define *version*
@ -297,3 +297,10 @@ See <http://www.gnu.org/licenses/lgpl.html>, for more details.")
(define (user-error msg . args)
(throw 'user-error #f msg args #f))
(define (flush-all-input)
(if (and (char-ready?)
(not (eof-object? (peek-char))))
(begin
(read-char)
(flush-all-input))))

View file

@ -92,13 +92,6 @@
*unspecified*)
(else ((language-reader lang) port env))))))))
(define (flush-all-input)
(if (and (char-ready?)
(not (eof-object? (peek-char))))
(begin
(read-char)
(flush-all-input))))
;; repl-reader is a function defined in boot-9.scm, and is replaced by
;; something else if readline has been activated. much of this hoopla is
;; to be able to re-use the existing readline machinery.