guile-user
[Top][All Lists]
Advanced

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

Re: readline eats previous text on line


From: Neil Jerram
Subject: Re: readline eats previous text on line
Date: Fri, 29 Sep 2006 23:33:54 +0100
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

Kevin Ryde <address@hidden> writes:

> Neil Jerram <address@hidden> writes:
>>
>> ... instead of by a parameter to `readline',
>
> Is that readline function meant to be used?  I assume it's emulating
> the C function of that name.  If you use it and no other input it
> works does it?

Yes, it is meant to be used, and I believe it works.

Sorry if I was misleading on this before.  I've refreshed my memory
now about how all this fits together.  Basically (ice-9 readline)
combines two separable things.

1. One is the Scheme readline function, which basically just wraps the
C function.  This allows programs to call `readline' explicitly when
they want to, and on such occasions it makes perfect sense for the
program to specify the prompt, so the readline's first arg is a prompt
string.

2. The other is the idea of using readline automatically whenever
something needs to be read from the current input port.  This is what
the `activate-readline' proc does - it could equally well be named
`use-readline-for-current-input-port'.  For this feature you wouldn't
expect to see an explicit `readline' call anywhere, except deep down
in the definition of a soft port that replaces the current input port.
Program code continues to use non-readline-specific calls like `read',
`read-char' or `read-line', and the port uses readline to replenish
the port's input buffer when necessary.

My explanation of the thinking behind set-readline-prompt! applies to
(2).  In this case the program can't always predict when a readline
will happen, and it doesn't issue the readline call itself directly;
so set-readline-prompt! basically means "use so-and-so prompt if a
readline is needed".

Slightly confusingly, set-readline-prompt! does also set the default
prompt for an explicit `readline' call (1).  I think the overall
situation would be clearer if it didn't.

The bug which Jon has noted, about the effect of set-readline-prompt!
not lasting very long, is caused by the fact that Guile's REPL code,
when using readline, does a

  (set-readline-prompt! "guile>" "...")

before reading an expression from the REPL, and

  (set-readline-prompt! "" "")

after the read, thus losing whatever prompt the user might have
installed for their own (non-REPL) purposes.  This code should instead
save the existing prompts and restore them afterwards - I'll post a
patch for that soon.

Regards,
     Neil





reply via email to

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