Re: Getting psql to redisplay command after \e

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Getting psql to redisplay command after \e
Date: 2019-10-31 09:09:14
Message-ID: alpine.DEB.2.21.1910301007130.10013@lancre
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Natarajan R 2019-10-31 09:49:23 Postgres cache
Previous Message Michael Paquier 2019-10-31 09:07:34 Re: update ALTER TABLE with ATTACH PARTITION lock mode (docs)