diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2012-03-06 20:23:31 +0000 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2012-03-06 20:29:09 +0000 |
commit | 87ea3a4ffb9e910c16f1c48444cad41be1dc6a3d (patch) | |
tree | ee32cc0b52165fd295b69fec6fbb2c61b68c5d92 /alot/commands/envelope.py | |
parent | 5ae533d9aa0c13aa9f1ca685c68f0a9ec38e2061 (diff) |
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.
Diffstat (limited to 'alot/commands/envelope.py')
-rw-r--r-- | alot/commands/envelope.py | 12 |
1 files changed, 7 insertions, 5 deletions
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() |