Thanks for taking a look at this! The word count returned by get_previous_words was incorrect. Here is a corrected version.
I haven't looked at v6 yet, but in v5:
"set work_mem TO" completes to "NULL" not to "DEFAULT"
line 2665 of the patched tab complete file,, should be "DEFAULT", not "NULL" as the completion string. Looks like a simple copy and paste error.
For the bigger picture, I don't think we should not apply this patch simply because there is something even better we might theoretically do at some point in the future. Having used it a little bit, I do agree with Robert that it is not a gigantic improvement over the current situation, as the code it replaces is largely mechanical boilerplate. But I think it is enough of an improvement that we should go ahead with it.