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

From Fabien COELHO
Subject Re: Getting psql to redisplay command after \e
Date
Msg-id alpine.DEB.2.21.1910301007130.10013@lancre
Whole thread Raw
In response to Re: Getting psql to redisplay command after \e  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Getting psql to redisplay command after \e
List pgsql-hackers
Hello Tom,

>>    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.

Yep.

My point is to possibly not implicitely <return> at the end of \e, but to 
behave as if we were moving in history, which allows editing the lines, so 
that you would get

   psql=> select 1<cursor>

Instead of the above.

> 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.

I was suggesting something much simpler than rethinking readline handling. 
Does not mean that it is a good idea, but while testing the patch I would 
have liked the unfinished line to be in the current editing buffer, 
basically as if I had not typed <nl>.

ISTM more natural that \e behaves like history when coming back from 
editing, i.e. the \e-edited line is set as the current buffer for 
readline.

> 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.

-- 
Fabien.



pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: update ALTER TABLE with ATTACH PARTITION lock mode (docs)
Next
From: Natarajan R
Date:
Subject: Postgres cache