bug-readline
[Top][All Lists]
Advanced

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

Re: [Bug-readline] Re: Using SIGINT/rl_free_line_state () in .inputrc?


From: Chet Ramey
Subject: Re: [Bug-readline] Re: Using SIGINT/rl_free_line_state () in .inputrc?
Date: Sun, 28 Mar 2010 19:07:54 -0400
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.7) Gecko/20100111 Lightning/1.0b1 Thunderbird/3.0.1

On 3/28/10 6:01 PM, Tim Landscheidt wrote:
> Chet Ramey <address@hidden> wrote:
> 
>>> (The "\\r\n" tells psql to clear its query buffer.) Unfortu-
>>> nately, this doesn't work if readline is in "quote mode",
>>> e. g. the preceding line contains an opening "'" or '"'. I
>>> noticed though that pressing C-c does what I want: It can-
>>> cels all active thingies and gives me a clean prompt.
> 
>>>   Unfortunately, I can't use "\C-c" to invoke it as the key
>>> probably gets passed as SIGINT to readline. Is there another
>>> way to "call" rl_free_line_state () from a binding defini-
>>> tion?
> 
>> Why not bind a key sequence to "abort" and use it in the macro?

I'm sorry, I didn't read this closely enough.  You're not going to be able
to do this well without application support.  Readline doesn't have a
notion of a "quote mode," for instance -- it works a line at a time.  An
application can note that a line contains an unbalanced quote and
accumulate subsequent lines into a complete command, but readline
doesn't know about this.

I suspect that psql works much like bash in this regard.  The disconnect
between separate lines of input is why readline has a hard time honoring
quoting that appears on a previous line while doing completion in bash.

> a) I tried:
> 
>    | "\C-xa": abort
>    | "\e[24~": "\C-xa\fSELECT * FROM DashboardQuery;\n"
> 
>    and
> 
>    | "\e[24~": "\C-g\fSELECT * FROM DashboardQuery;\n"
> 
>    but neither did /anything/. If I prepended the \C-g with
>    other text, that got inserted, but the processing stopped
>    at the \C-g.

Yeah.  rl_abort also cancels macro processing (as does the SIGINT
handler).

> b) Pressing C-g interactively does not what C-c does for me.
>    In fact, it merely cancels C-r & Co., but does not delete
>    the query buffer, cancel "quote mode", etc.

It can't.  Readline doesn't do these things.  The application catches
the SIGINT and cleans up what it needs to.  Readline also catches the
SIGINT and cleans up the current line, but not previous lines the
application has already consumed.


Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/




reply via email to

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