Re: Invisible PROMPT2

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
Cc: david(at)fetter(dot)org, alvherre(at)2ndquadrant(dot)com, ilmari(at)ilmari(dot)org, thomas(dot)munro(at)gmail(dot)com, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Invisible PROMPT2
Date: 2019-11-14 14:58:03
Message-ID: 20559.1573743483@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com> writes:
> This seems assuming %x are a kind of stable (until semicolon)
> function. But at least %`..` can be volatile. So, I think the %w
> thing in PROMPT2 should be able to refer the actual prompt string
> resulted from PROMPT1.

Oh, that's a good point. But it actually leads to a much simpler
definition and implementation than the other ideas we've kicked
around: define %w as "whitespace equal to the length of the
last-generated PROMPT1 string (initially empty)", and we just
have to save PROMPT1 each time we generate it.

Except ... I'm not sure how to deal with hidden escape sequences.
We should probably assume that anything inside %[...%] has width
zero, but how would we remember that?

Maybe count the width of non-escape characters whenever we
generate PROMPT1, and just save that number not the string?
It'd add overhead that's useless when there's no %w, but
probably not enough to care about.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jonathan S. Katz 2019-11-14 15:07:03 Re: 2019-11-14 Press Release Draft
Previous Message Peter Eisentraut 2019-11-14 14:54:02 Re: Proposal: Add more compile-time asserts to expose inconsistencies.