I wrote: > I've spent some effort previously on getting tab-completion to deal > sanely with single-quoted strings, but everything I've tried has > crashed and burned :-(, mainly because it's not clear when to take > the whole literal as one "word" and when not.
After a little further thought, a new idea occurred to me: maybe we could push some of the problem down into the Matches functions. Consider inventing a couple of new match primitives: * MatchLiteral matches one or more parse tokens that form a single complete, valid SQL literal string (either single-quoted or dollar style). Use it like else if (Matches("CREATE", "SUBSCRIPTION", MatchAny, "CONNECTION", MatchLiteral)) COMPLETE_WITH("PUBLICATION"); I think there's no question that most Matches calls that might subsume a quoted literal would prefer to treat the literal as a single word, and this'd let them do that correctly. * MatchLiteralBegin matches the opening of a literal string (either ' or $...$). Handwaving freely, we might do else if (Matches("CREATE", "SUBSCRIPTION", MatchAny, "CONNECTION", MatchLiteralBegin)) COMPLETE_WITH(List_of_connection_keywords); This part of the idea still needs some thought, because it remains unclear how we might offer completion for connection keywords after the first one. Implementing these primitives might be a little tricky too. If memory serves, readline and libedit have different behaviors around quote marks. But at least it seems like a framework that could solve a number of problems, if we can make it go. regards, tom lane