Re: Getting psql to redisplay command after \e - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Getting psql to redisplay command after \e
Date
Msg-id 24982.1572365167@sss.pgh.pa.us
Whole thread Raw
In response to Re: Getting psql to redisplay command after \e  (Fabien COELHO <coelho@cri.ensmp.fr>)
Responses Re: Getting psql to redisplay command after \e
List pgsql-hackers
Fabien COELHO <coelho@cri.ensmp.fr> writes:
>> The attached patch teaches psql to redisplay any not-yet-executed
>> query text after editing with \e. 

> I've tested this patch. Although I agree that it is an improvement, I'm a 
> little at odd with the feature as is:

>    psql=> \e
>    # select 1...

> then:

>    psql=> select 1...
>    psql-> <prompt>

> I cannot move back with readline to edit further, I'm stuck there, which 
> is strange.

I don't follow.  readline doesn't allow you to edit already-entered lines
today, that is, after typing "select 1<return>" you see

regression=# select 1
regression-# 

and there isn't any way to move back and edit the already-entered line
within readline.  I agree it might be nicer if you could do that, but
that's *far* beyond the scope of this patch.  It would take entirely
fundamental rethinking of our use of libreadline, if indeed it's possible
at all.  I also don't see how we could have syntax-aware per-line prompts
if we were allowing readline to treat the whole query as one line.

In the larger picture, tinkering with how that works would affect
every psql user at the level of "muscle memory" editing habits,
and I suspect that their reactions would not be uniformly positive.
What I propose here doesn't affect anyone who doesn't use \e at all.
Even for \e users it doesn't have any effect on what you need to type.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Vik Fearing
Date:
Subject: Re: Join Correlation Name
Next
From: Tom Lane
Date:
Subject: Re: alternative to PG_CATCH