From 87ea3a4ffb9e910c16f1c48444cad41be1dc6a3d Mon Sep 17 00:00:00 2001 From: Patrick Totzke Date: Tue, 6 Mar 2012 20:23:31 +0000 Subject: determine editable content before pre-edit-hook this moves the construction of the tempfile content and edit_only_body flag before the call to the pre-translate-hook. Also make the setter more explicit, code readability. --- alot/commands/envelope.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'alot/commands/envelope.py') diff --git a/alot/commands/envelope.py b/alot/commands/envelope.py index ce599781..25d7cc94 100644 --- a/alot/commands/envelope.py +++ b/alot/commands/envelope.py @@ -239,7 +239,14 @@ class EditCommand(Command): value = re.sub('[ \t\r\f\v]*\n[ \t\r\f\v]*', ' ', value) headertext += '%s: %s\n' % (key, value) + # determine editable content bodytext = self.envelope.body + if headertext: + content = '%s\n%s' % (headertext, bodytext) + self.edit_only_body = False + else: + content = bodytext + self.edit_only_body = True # call pre-edit translate hook translate = settings.get_hook('pre_edit_translate') @@ -248,11 +255,6 @@ class EditCommand(Command): #write stuff to tempfile tf = tempfile.NamedTemporaryFile(delete=False, prefix='alot.') - content = bodytext - if headertext: - content = '%s\n%s' % (headertext, content) - else: - self.edit_only_body = True tf.write(content.encode('utf-8')) tf.flush() tf.close() -- cgit v1.2.3