!Changing the last line to (substring pcomplete-stub 1 -2) fixes it in my
example. I don't know if one is supposed to do [[*prefix<c-a-p>]] or
[[*prefix<c-a-p> as is implied by the code, but better to support both,
specially considering electric pairs, don't you think?

Indeed, the right limit should be the position of the point.