guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] branch main updated: Better REPL behavior on syntax erro


From: Daniel Llorens
Subject: [Guile-commits] branch main updated: Better REPL behavior on syntax errors in meta commands.
Date: Fri, 25 Oct 2024 07:45:52 -0400

This is an automated email from the git hooks/post-receive script.

lloda pushed a commit to branch main
in repository guile.

The following commit(s) were added to refs/heads/main by this push:
     new 242e8698c Better REPL behavior on syntax errors in meta commands.
242e8698c is described below

commit 242e8698c2fdfada96a136abde5156bac3dbc6c9
Author: Taylan Kammer <taylan.kammer@gmail.com>
AuthorDate: Tue May 18 18:15:08 2021 +0200

    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.
---
 module/system/repl/command.scm | 5 ++++-
 module/system/repl/common.scm  | 9 ++++++++-
 module/system/repl/repl.scm    | 7 -------
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/module/system/repl/command.scm b/module/system/repl/command.scm
index 8b0422dbd..5b575f368 100644
--- a/module/system/repl/command.scm
+++ b/module/system/repl/command.scm
@@ -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)
diff --git a/module/system/repl/common.scm b/module/system/repl/common.scm
index a3f2032ba..46d0d5c04 100644
--- a/module/system/repl/common.scm
+++ b/module/system/repl/common.scm
@@ -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))))
diff --git a/module/system/repl/repl.scm b/module/system/repl/repl.scm
index fc525b547..1c3407159 100644
--- a/module/system/repl/repl.scm
+++ b/module/system/repl/repl.scm
@@ -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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]