'Return a list of possible completions for the string ending at the point.
Also set begidx and endidx in the process.'

def _get_completions(self):

    completions = []
    self.begidx = self.l_buffer.point
    self.endidx = self.l_buffer.point
    buf = self.l_buffer.line_buffer
    if self.completer:
        while (self.begidx > 0):
            self.begidx -= 1
            if (buf[self.begidx] in self.completer_delims):
                self.begidx += 1
                break
        text = ''.join(buf[self.begidx:self.endidx])
        log(('complete    text="%s"' % text))
        i = 0
        while 1:
            try:
                r = self.completer(text, i)
            except:
                break
            i += 1
            if (r and (r not in completions)):
                completions.append(r)
            else:
                break
        if (len(completions) == 1):
            completions[0] = (completions[0] + '    ')
        log(('text    completions=%s' % completions))
    return completions
