buf = window.get_active_doc().get_buffer()
start = buf.get_iter_at_mark(buf.get_insert())
start.set_line_offset(0)
end = start.copy()
end.forward_line()
end.set_line_offset(0)
while not end.ends_line():
    if not end.get_char().isspace():
        break
    end.forward_char()
start.forward_to_line_end()
buf.delete(start, end)
if not start.starts_line():
    space = start.copy()
    space.backward_char()
    if space.get_char() in ',:':
        buf.insert(start, ' ')