psql: tab completions for 'WITH'

Started by Josh Kupershmidtabout 14 years ago4 messageshackers
Jump to latest
#1Josh Kupershmidt
schmiddy@gmail.com

Hi all,

I noticed psql's tab-completion for 'WITH' is a bit overeager. If you
try to tab-complete commands like:
ALTER ROLE jsmith WITH [TAB]
COPY tbl FROM 'filename' WITH [TAB]

you'll get 'RECURSIVE' unhelpfully filled in. I think 'RECURSIVE'
should only be suggested if 'WITH' is the first and only word of the
line.

On a related note, I found it annoying that after fixing the above
problem, trying:
ALTER ROLE jsmith WITH [TAB]
CREATE ROLE jsmith WITH [TAB]

didn't suggest any tab-completions -- it only works if you leave off
the 'WITH' noise word, which I happen to use.

Attached are fixes for both of these gripes. I'll add to the next CF.

Josh

Attachments:

overeager_with.diffapplication/octet-stream; name=overeager_with.diffDownload+7-7
create_alter_role_tab_complete.diffapplication/octet-stream; name=create_alter_role_tab_complete.diffDownload+25-25
#2Peter Eisentraut
peter_e@gmx.net
In reply to: Josh Kupershmidt (#1)
Re: psql: tab completions for 'WITH'

On tis, 2012-04-03 at 22:34 -0700, Josh Kupershmidt wrote:

I noticed psql's tab-completion for 'WITH' is a bit overeager. If you
try to tab-complete commands like:
ALTER ROLE jsmith WITH [TAB]
COPY tbl FROM 'filename' WITH [TAB]

you'll get 'RECURSIVE' unhelpfully filled in. I think 'RECURSIVE'
should only be suggested if 'WITH' is the first and only word of the
line.

Committed that.

On a related note, I found it annoying that after fixing the above
problem, trying:
ALTER ROLE jsmith WITH [TAB]
CREATE ROLE jsmith WITH [TAB]

didn't suggest any tab-completions -- it only works if you leave off
the 'WITH' noise word, which I happen to use.

Hmm, but now you've set it up so that you can complete ALTER ROLE foo
WITH WITH. Were you aware of that?

#3Josh Kupershmidt
schmiddy@gmail.com
In reply to: Peter Eisentraut (#2)
Re: psql: tab completions for 'WITH'

On Tue, Apr 10, 2012 at 10:38 AM, Peter Eisentraut <peter_e@gmx.net> wrote:

On tis, 2012-04-03 at 22:34 -0700, Josh Kupershmidt wrote:

I noticed psql's tab-completion for 'WITH' is a bit overeager. If you
try to tab-complete commands like:
  ALTER ROLE jsmith WITH [TAB]
  COPY tbl FROM 'filename' WITH [TAB]

you'll get 'RECURSIVE' unhelpfully filled in. I think 'RECURSIVE'
should only be suggested if 'WITH' is the first and only word of the
line.

Committed that.

Thanks!

On a related note, I found it annoying that after fixing the above
problem, trying:
    ALTER ROLE jsmith WITH [TAB]
    CREATE ROLE jsmith WITH [TAB]

didn't suggest any tab-completions -- it only works if you leave off
the 'WITH' noise word, which I happen to use.

Hmm, but now you've set it up so that you can complete ALTER ROLE foo
WITH WITH.  Were you aware of that?

D'oh, I overlooked that. Attached is v2: the diff is a tad lengthier
now, but that should fix it.

Josh

Attachments:

create_alter_role_tab_complete.v2.diffapplication/octet-stream; name=create_alter_role_tab_complete.v2.diffDownload+41-6
#4Peter Eisentraut
peter_e@gmx.net
In reply to: Josh Kupershmidt (#3)
Re: psql: tab completions for 'WITH'

On tis, 2012-04-10 at 17:48 -0700, Josh Kupershmidt wrote:

Hmm, but now you've set it up so that you can complete ALTER ROLE

foo

WITH WITH. Were you aware of that?

D'oh, I overlooked that. Attached is v2: the diff is a tad lengthier
now, but that should fix it.

Committed.