'Open the file specified by name in an editor
:param syntax: The media type of the file, for example, ``\'text/html\'``. If not specified it is guessed from the file extension.
:param use_template: A template to initialize the opened editor with'

def edit_file(self, name, syntax=None, use_template=None):

    editor = editors.get(name, None)
    if (editor is None):
        syntax = (syntax or syntax_from_mime(name, guess_type(name)))
        if (use_template is None):
            data = current_container().raw_data(name)
            if (isbytestring(data) and (syntax in {u'html', u'css', u'text', u'xml'})):
                try:
                    data = data.decode(u'utf-8')
                except UnicodeDecodeError:
                    return error_dialog(self.gui, _(u'Cannot    decode'), (_(u'Cannot    edit    %s    as    it    appears    to    be    in    an    unknown    character    encoding') % name), show=True)
        else:
            data = use_template
        editor = editors[name] = editor_from_syntax(syntax, self.gui.editor_tabs)
        self.init_editor(name, editor, data, use_template=bool(use_template))
        if tprefs[u'pretty_print_on_open']:
            editor.pretty_print(name)
    self.show_editor(name)
    return editor
