summaryrefslogtreecommitdiff
path: root/alot/commands/envelope.py
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2012-03-06 20:23:31 +0000
committerPatrick Totzke <patricktotzke@gmail.com>2012-03-06 20:29:09 +0000
commit87ea3a4ffb9e910c16f1c48444cad41be1dc6a3d (patch)
treeee32cc0b52165fd295b69fec6fbb2c61b68c5d92 /alot/commands/envelope.py
parent5ae533d9aa0c13aa9f1ca685c68f0a9ec38e2061 (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.py12
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()