code: def start_history_lines_completion(self):
          
          found_completions = set()
          completions = []
  
          # For every line of the whole history, find matches with the current line.
          current_line = self.document.current_line_before_cursor.lstrip()
  
          for i, string in enumerate(self._working_lines):
              for j, l in enumerate(string.split('\n')):
                  l = l.strip()
                  if l and l.startswith(current_line):
                      # When a new line has been found.
                      if l not in found_completions:
                          found_completions.add(l)
  
                          # Create completion.
                          if i == self.working_index:
                              display_meta = "Current, line %s" % (j+1)
                          else:
                              display_meta = "History %s, line %s" % (i+1, j+1)
  
                          completions.append(Completion(
                              l,
                              start_position=-len(current_line),
                              display_meta=display_meta))
  
          self.set_completions(completions=completions[::-1])
docs: Start a completion based on all the other lines in the document and the
          history.