Hello here is a proposed patch - autocomplete for known psql variable content
Regards Pavel 2014-07-10 9:50 GMT+02:00 Pavel Stehule <pavel.steh...@gmail.com>: > > > > 2014-07-10 7:32 GMT+02:00 Fujii Masao <masao.fu...@gmail.com>: > > On Wed, Jul 9, 2014 at 9:44 PM, Pavel Stehule <pavel.steh...@gmail.com> >> wrote: >> >> Barring any objection, I will commit this patch except tab-completion >> >> part. >> >> Committed. >> > > Thank you very much > >> >> > It can be a second discussion, but I am thinking so anywhere when we >> can use >> > autocomplete, then we should it - Although it should not to substitute >> > documentation, it is fast help about available options, mainly in >> situation >> > where variables can hold a relative different content. I can prepare, if >> > there will not any objection addition patch with complete autocomplete >> for >> > all psql variables described in doc. >> >> I have no objection. But I found that the tab-completion for psql >> variables names >> are not complete. For example, COMP_KEYWORD_CASE is not displayed. >> Probably we should address this problem, too. >> > > I prepare patch for next commitfest - it is relative trivial task > > Pavel > > >> >> Regards, >> >> -- >> Fujii Masao >> > >
commit 7cba776aea228165c5b65f7077515328a0efa039 Author: root <root@localhost.localdomain> Date: Thu Jul 10 14:54:36 2014 +0200 initial concept diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c index 5a397e8..f05dfe2 100644 --- a/src/bin/psql/startup.c +++ b/src/bin/psql/startup.c @@ -147,6 +147,8 @@ main(int argc, char *argv[]) SetVariable(pset.vars, "PROMPT2", DEFAULT_PROMPT2); SetVariable(pset.vars, "PROMPT3", DEFAULT_PROMPT3); + SetVariable(pset.vars, "COMP_KEYWORD_CASE", "preserve-upper"); + parse_psql_options(argc, argv, &options); /* diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index bab0357..41ae499 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -3592,6 +3592,79 @@ psql_completion(const char *text, int start, int end) { matches = complete_from_variables(text, "", ""); } + else if (strcmp(prev2_wd, "\\set") == 0) + { + if (strcmp(prev_wd, "AUTOCOMMIT") == 0) + { + static const char *const my_list[] = + {"on", "off", "interactive", NULL}; + + COMPLETE_WITH_LIST_CS(my_list); + } + else if (strcmp(prev_wd, "COMP_KEYWORD_CASE") == 0) + { + static const char *const my_list[] = + {"lower", "upper", "preserve-lower", "preserve-upper", NULL}; + + COMPLETE_WITH_LIST_CS(my_list); + } + else if (strcmp(prev_wd, "ECHO") == 0) + { + static const char *const my_list[] = + {"none", "errors", "queries", "all", NULL}; + + COMPLETE_WITH_LIST_CS(my_list); + } + else if (strcmp(prev_wd, "ECHO_HIDDEN") == 0) + { + static const char *const my_list[] = + {"noexec", "off", "on", NULL}; + + COMPLETE_WITH_LIST_CS(my_list); + } + else if (strcmp(prev_wd, "ON_ERROR_ROLLBACK") == 0) + { + static const char *const my_list[] = + {"on", "off", "interactive", NULL}; + + COMPLETE_WITH_LIST_CS(my_list); + } + else if (strcmp(prev_wd, "ON_ERROR_STOP") == 0) + { + static const char *const my_list[] = + {"on", "off", NULL}; + + COMPLETE_WITH_LIST_CS(my_list); + } + else if (strcmp(prev_wd, "QUIET") == 0) + { + static const char *const my_list[] = + {"on", "off", NULL}; + + COMPLETE_WITH_LIST_CS(my_list); + } + else if (strcmp(prev_wd, "SINGLELINE") == 0) + { + static const char *const my_list[] = + {"on", "off", NULL}; + + COMPLETE_WITH_LIST_CS(my_list); + } + else if (strcmp(prev_wd, "SINGLESTEP") == 0) + { + static const char *const my_list[] = + {"on", "off", NULL}; + + COMPLETE_WITH_LIST_CS(my_list); + } + else if (strcmp(prev_wd, "VERBOSITY") == 0) + { + static const char *const my_list[] = + {"default", "verbose", "terse", NULL}; + + COMPLETE_WITH_LIST_CS(my_list); + } + } else if (strcmp(prev_wd, "\\sf") == 0 || strcmp(prev_wd, "\\sf+") == 0) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_functions, NULL); else if (strcmp(prev_wd, "\\cd") == 0 ||
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers