integrate init_bodies into overthrowing edit

pull/4/head
Blake DeMarcy 2017-04-12 07:00:53 -05:00
parent 76aced8875
commit 7eef803084
1 changed files with 4 additions and 2 deletions

View File

@ -804,7 +804,7 @@ class App(object):
self.set_footer(string) self.set_footer(string)
def overthrow_ext_edit(self): def overthrow_ext_edit(self, init_body=""):
""" """
Opens the external editor, but instead of integreating it into the app, Opens the external editor, but instead of integreating it into the app,
stops the mainloop and blocks until the editor is killed. Returns the stops the mainloop and blocks until the editor is killed. Returns the
@ -812,6 +812,8 @@ class App(object):
""" """
self.loop.stop() self.loop.stop()
descriptor, path = tempfile.mkstemp() descriptor, path = tempfile.mkstemp()
with open(path, "w") as _:
_.write(init_body)
run("%s %s" % (self.prefs["editor"], path), shell=True) run("%s %s" % (self.prefs["editor"], path), shell=True)
with open(path) as _: with open(path) as _:
body = _.read() body = _.read()
@ -835,7 +837,7 @@ class App(object):
"Title", self.compose, extra_text=e.description) "Title", self.compose, extra_text=e.description)
if self.prefs["editor"] and not self.prefs["integrate_external_editor"]: if self.prefs["editor"] and not self.prefs["integrate_external_editor"]:
body = self.overthrow_ext_edit() body = self.overthrow_ext_edit(init_body)
if not body: if not body:
return self.temp_footer_message("EMPTY POST DISCARDED") return self.temp_footer_message("EMPTY POST DISCARDED")
params = {"body": body} params = {"body": body}