summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2021-05-13 10:05:51 +0200
committerAnton Khirnov <anton@khirnov.net>2021-05-13 10:05:51 +0200
commita741ac644bf77eb7deb61ba0e1eecb30a1c77268 (patch)
treedca6f2a62d6e19ecc346e82958a0fbaace333d9b
parentbff3f4050be4e015c99d1bae7fcf1289d026e5ad (diff)
commands/thread:ReplyCommand: factor out building reply subject
-rw-r--r--alot/commands/thread.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/alot/commands/thread.py b/alot/commands/thread.py
index b00cbd68..7ac7dd93 100644
--- a/alot/commands/thread.py
+++ b/alot/commands/thread.py
@@ -153,6 +153,18 @@ class ReplyCommand(Command):
self.force_spawn = spawn
super().__init__(**kwargs)
+ def _reply_subject(self, message):
+ subject = message.headers.get('Subject') or ''
+ reply_subject_hook = settings.get_hook('reply_subject')
+ if reply_subject_hook:
+ subject = reply_subject_hook(subject)
+ else:
+ rsp = settings.get('reply_subject_prefix')
+ if not subject.lower().startswith(('re:', rsp.lower())):
+ subject = rsp + subject
+
+ return subject
+
async def apply(self, ui):
message = ui.current_buffer.get_selected_message()
mail = message.get_email()
@@ -177,16 +189,7 @@ class ReplyCommand(Command):
envelope = Envelope(bodytext = mailcontent, replied = message)
- # copy subject
- subject = message.headers.get('Subject') or ''
- reply_subject_hook = settings.get_hook('reply_subject')
- if reply_subject_hook:
- subject = reply_subject_hook(subject)
- else:
- rsp = settings.get('reply_subject_prefix')
- if not subject.lower().startswith(('re:', rsp.lower())):
- subject = rsp + subject
- envelope.add('Subject', subject)
+ envelope.add('Subject', self._reply_subject(message))
# Auto-detect ML
auto_replyto_mailinglist = settings.get('auto_replyto_mailinglist')