Re: [HACKERS] psql patch: tab-complete :variables also at buffer start

2011-02-11 Thread Robert Haas
On Thu, Feb 10, 2011 at 8:13 AM, Itagaki Takahiro
 wrote:
> On Thu, Feb 10, 2011 at 19:37, Christoph Berg  wrote:
>> Currently, tab-completing :variable names in psql does not work at the
>> beginning of the line. Fix this by moving the code block before the
>> "empty buffer" case.
>
> Seems reasonable to me.

OK, committed.

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

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


Re: [HACKERS] psql patch: tab-complete :variables also at buffer start

2011-02-10 Thread Itagaki Takahiro
On Thu, Feb 10, 2011 at 19:37, Christoph Berg  wrote:
> Currently, tab-completing :variable names in psql does not work at the
> beginning of the line. Fix this by moving the code block before the
> "empty buffer" case.

Seems reasonable to me.

-- 
Itagaki Takahiro

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


[HACKERS] psql patch: tab-complete :variables also at buffer start

2011-02-10 Thread Christoph Berg
Currently, tab-completing :variable names in psql does not work at the
beginning of the line. Fix this by moving the code block before the
"empty buffer" case.

(I have several "sql macros" in my .psqlrc like :relsize that prints
table sizes in a nicely formatted way, being able to type : would
be very welcome.)

diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 1c9623d..a540912 100644
*** a/src/bin/psql/tab-complete.c
--- b/src/bin/psql/tab-complete.c
*** psql_completion(char *text, int start, i
*** 761,766 
--- 761,777 
if (text[0] == '\\')
COMPLETE_WITH_LIST(backslash_commands);
  
+   /* Variable interpolation */
+   else if (text[0] == ':' && text[1] != ':')
+   {
+   if (text[1] == '\'')
+   matches = complete_from_variables(text, ":'", "'");
+   else if (text[1] == '"')
+   matches = complete_from_variables(text, ":\"", "\"");
+   else
+   matches = complete_from_variables(text, ":", "");
+   }
+ 
/* If no previous word, suggest one of the basic sql commands */
else if (!prev_wd)
COMPLETE_WITH_LIST(sql_commands);
*** psql_completion(char *text, int start, i
*** 2767,2783 
)
matches = completion_matches(text, 
filename_completion_function);
  
- /* Variable interpolation */
-   else if (text[0] == ':' && text[1] != ':')
-   {
-   if (text[1] == '\'')
-   matches = complete_from_variables(text, ":'", "'");
-   else if (text[1] == '"')
-   matches = complete_from_variables(text, ":\"", "\"");
-   else
-   matches = complete_from_variables(text, ":", "");
-   }
- 
/*
 * Finally, we look through the list of "things", such as TABLE, INDEX 
and
 * check if that was the previous word. If so, execute the query to get 
a
--- 2778,2783 

Christoph
-- 
c...@df7cb.de | http://www.df7cb.de/


signature.asc
Description: Digital signature