'Edit a given text.
Args:
text: The initial text to edit.'

def edit(self, text):

    if (self._text is not None):
        raise ValueError('Already    editing    a    file!')
    self._text = text
    encoding = config.get('general', 'editor-encoding')
    try:
        with tempfile.NamedTemporaryFile(mode='w', prefix='qutebrowser-editor-', encoding=encoding, delete=False) as fobj:
            if text:
                fobj.write(text)
            self._file = fobj
    except OSError as e:
        message.error('Failed    to    create    initial    file:    {}'.format(e))
        return
    self._proc = guiprocess.GUIProcess(what='editor', parent=self)
    self._proc.finished.connect(self.on_proc_closed)
    self._proc.error.connect(self.on_proc_error)
    editor = config.get('general', 'editor')
    executable = editor[0]
    args = [arg.replace('{}', self._file.name) for arg in editor[1:]]
    log.procs.debug('Calling    "{}"    with    args    {}'.format(executable, args))
    self._proc.start(executable, args)
