psql case preserving completion

Lists: pgsql-hackers
From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: psql case preserving completion
Date: 2012-01-11 20:29:18
Message-ID: 1326313758.22276.12.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

In psql, the tab completion always converts key words to upper case. In
practice, I and I think most users type in lower case. So then you end
up with commands looking like this:

=> alter TABLE foo add CONSTRAINT bar check (a > 0);

To address this, I have implemented a slightly different completion mode
that looks at the word being completed and converts the completed word
to the case of the original word. (Well, it looks at the first letter.)

In fact, since almost all completions in psql are of this nature, I made
this the default mode for COMPLETE_WITH_CONST and COMPLETE_WITH_LIST and
added a new macro COMPLETE_WITH_LIST_CS that uses the old case-sensitive
behavior. The latter is used mainly for completing backslash commands.

After playing with this a little, I find the behavior more pleasing.
Less yelling. ;-)

Patch attached.

Attachment Content-Type Size
psql-cp-completion.patch text/x-patch 4.7 KB

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: psql case preserving completion
Date: 2012-01-11 20:35:03
Message-ID: CAFj8pRAa_x7mQhdkEqboMypHUjbcm+FBWt9YN52pVLE6cpHYLw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

2012/1/11 Peter Eisentraut <peter_e(at)gmx(dot)net>:
> In psql, the tab completion always converts key words to upper case.  In
> practice, I and I think most users type in lower case.  So then you end
> up with commands looking like this:
>
> => alter TABLE foo add CONSTRAINT bar check (a > 0);
>
> To address this, I have implemented a slightly different completion mode
> that looks at the word being completed and converts the completed word
> to the case of the original word.  (Well, it looks at the first letter.)
>
> In fact, since almost all completions in psql are of this nature, I made
> this the default mode for COMPLETE_WITH_CONST and COMPLETE_WITH_LIST and
> added a new macro COMPLETE_WITH_LIST_CS that uses the old case-sensitive
> behavior. The latter is used mainly for completing backslash commands.
>
> After playing with this a little, I find the behavior more pleasing.
> Less yelling. ;-)
>
> Patch attached.

+1

Pavel

>
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>


From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: psql case preserving completion
Date: 2012-01-17 07:46:07
Message-ID: CAHGQGwFkTWOFK4P1y7VBXqLdu_4ZN8b138736waoMm4c4y5E0A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Jan 12, 2012 at 5:29 AM, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:
> In psql, the tab completion always converts key words to upper case.  In
> practice, I and I think most users type in lower case.  So then you end
> up with commands looking like this:
>
> => alter TABLE foo add CONSTRAINT bar check (a > 0);
>
> To address this, I have implemented a slightly different completion mode
> that looks at the word being completed and converts the completed word
> to the case of the original word.  (Well, it looks at the first letter.)
>
> In fact, since almost all completions in psql are of this nature, I made
> this the default mode for COMPLETE_WITH_CONST and COMPLETE_WITH_LIST and
> added a new macro COMPLETE_WITH_LIST_CS that uses the old case-sensitive
> behavior. The latter is used mainly for completing backslash commands.
>
> After playing with this a little, I find the behavior more pleasing.
> Less yelling. ;-)
>
> Patch attached.

When I tested the patch, "create ta" was converted unexpectedly to
"create TABLE"
though "alter ta" was successfully converted to "alter table". As far
as I read the patch,
you seems to have forgotten to change create_or_drop_command_generator() or
something.

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: psql case preserving completion
Date: 2012-02-01 18:19:24
Message-ID: 1328120364.28270.2.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On tis, 2012-01-17 at 16:46 +0900, Fujii Masao wrote:
> When I tested the patch, "create ta" was converted unexpectedly to
> "create TABLE"
> though "alter ta" was successfully converted to "alter table". As far
> as I read the patch,
> you seems to have forgotten to change create_or_drop_command_generator() or
> something.

Thanks, fixed and committed.


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: psql case preserving completion
Date: 2012-02-08 01:02:21
Message-ID: 20120208010221.GC17580@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Feb 01, 2012 at 08:19:24PM +0200, Peter Eisentraut wrote:
> On tis, 2012-01-17 at 16:46 +0900, Fujii Masao wrote:
> > When I tested the patch, "create ta" was converted unexpectedly to
> > "create TABLE"
> > though "alter ta" was successfully converted to "alter table". As far
> > as I read the patch,
> > you seems to have forgotten to change create_or_drop_command_generator() or
> > something.
>
> Thanks, fixed and committed.

I have to admit I like the capitalized keywords, but don't normally type
them, but it must be just me because no one else said anything.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: psql case preserving completion
Date: 2012-02-08 02:50:21
Message-ID: CA+Tgmobf5TzbuHDnpFC_JN0hbe6aCx8iBfOU2i65ERsNippEUg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Feb 7, 2012 at 8:02 PM, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> On Wed, Feb 01, 2012 at 08:19:24PM +0200, Peter Eisentraut wrote:
>> On tis, 2012-01-17 at 16:46 +0900, Fujii Masao wrote:
>> > When I tested the patch, "create ta" was converted unexpectedly to
>> > "create TABLE"
>> > though "alter ta" was successfully converted to "alter table". As far
>> > as I read the patch,
>> > you seems to have forgotten to change create_or_drop_command_generator() or
>> > something.
>>
>> Thanks, fixed and committed.
>
> I have to admit I like the capitalized keywords, but don't normally type
> them, but it must be just me because no one else said anything.

Yeah, I liked the old behavior, too. But I figured it was a sign that
I'm an old fuddy-duddy.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company