def display_completions_like_readline(event):
 b = event.current_buffer
 if (b.completer is None):
  return
 complete_event = CompleteEvent(completion_requested=True)
 completions = list(b.completer.get_completions(b.document, complete_event))
 common_suffix = get_common_complete_suffix(b.document, completions)
 if (len(completions) == 1):
  b.delete_before_cursor((- completions[0].start_position))
  b.insert_text(completions[0].text)
 elif common_suffix:
  b.insert_text(common_suffix)
 elif completions:
  _display_completions_like_readline(event.cli, completions)

def display_completions_like_readline ( event ) : b = event . current_buffer if ( b . completer is None ) : return complete_event = CompleteEvent ( completion_requested = True ) completions = list ( b . completer . get_completions ( b . document , complete_event ) ) common_suffix = get_common_complete_suffix ( b . document , completions ) if ( len ( completions ) == 1 ) : b . delete_before_cursor ( ( - completions [ 0 ] . start_position ) ) b . insert_text ( completions [ 0 ] . text ) elif common_suffix : b . insert_text ( common_suffix ) elif completions : _display_completions_like_readline ( event . cli , completions )
key binding handler for readline-style tab completion .