guile-devel
[Top][All Lists]
Advanced

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

Re: Reading more than one expression on the same line


From: Neil Jerram
Subject: Re: Reading more than one expression on the same line
Date: 12 Jan 2001 12:07:09 +0000

Some time ago, I wrote:

    >> When readline is *not* activated, this is what you see if you
    >> type two expressions on the same line and press enter:
    
    guile> 'a 'b
    a
    guile> b
    guile> 

    >>  Whereas I think it would be more natural, and less confusing,
    >> to see:
    
    guile> 'a 'b
    a
    b
    guile>

and sent in a corresponding patch.

Maciej replied:

    Maciej> It's interesting to note that this patch changes more than
    Maciej> the case you mentioned. In particular, if you type a full
    Maciej> expression and a partial expression on the same line, e.g.

    guile> 'foo '(bar

    Maciej> foo will be displayed right away but you won't get another
    Maciej> prompt.

Maciej's point raises the question of what the next prompt should be.
I would argue that, since the beginning of the next top-level
expression has already been entered, it should be the continuation
prompt "... ", not "guile> ".  Further investigation shows that, if my
argument is accepted, the readline code has this wrong:

guile> 'foo '(bar
foo
guile> )
(bar)

should according to my argument be

guile> 'foo '(bar
foo
... )
(bar)

A patch for the readline code is below.  The logic of the patch is
that prompt should become prompt2 as soon as (get-character) returns
any character at all that was previously read.

What do you think?

        Neil

--- ../cvs/guile-core/guile-readline/readline.scm       Tue Dec 12 18:56:59 2000
+++ readline.scm        Fri Jan 12 12:03:44 2001
@@ -74,13 +74,13 @@
                        (begin
                          (or (string=? read-string "")
                              (begin
-                               (add-history read-string)
-                               (set! prompt prompt2)))
+                               (add-history read-string)))
                          (get-character))
                        read-string)))
                 (else 
                  (let ((res (string-ref read-string string-index)))
                    (set! string-index (+ 1 string-index))
+                   (set! prompt prompt2)
                    res))))))         
       (make-soft-port
        (vector write-char display #f get-character #f)



reply via email to

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