summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2021-11-20 15:55:19 +0100
committerAnton Khirnov <anton@khirnov.net>2021-11-20 15:55:19 +0100
commitf5f723eada40036f74a022c2d9c7b6ac51efb63a (patch)
treee809a5b8f63df37255527e886abea464ab8d058c
parent46aad9005a504caf2894090bf245a9fdda61ea0e (diff)
commands/thread: refactor setting reply references
Move it to its own function, simplify the flow control. Expand the arbitrary references limit to 16 in total.
-rw-r--r--alot/commands/thread.py27
1 files changed, 14 insertions, 13 deletions
diff --git a/alot/commands/thread.py b/alot/commands/thread.py
index e84def23..cba0af65 100644
--- a/alot/commands/thread.py
+++ b/alot/commands/thread.py
@@ -173,6 +173,18 @@ class ReplyCommand(Command):
return bool(self._force_list_reply)
+ def _reply_references(self, message):
+ old_references = message.headers.get(HDR.REFERENCES)
+ references = []
+
+ if old_references:
+ references = old_references.split()
+ # limit to 16 references, including the one we add
+ del references[1:-14]
+
+ references.append('<%s>' % message.id)
+ return ' '.join(references)
+
async def apply(self, ui):
message = ui.current_buffer.get_selected_message()
@@ -280,20 +292,9 @@ class ReplyCommand(Command):
logging.debug('mail followup to: %s', followupto)
headers[HDR.MAIL_FOLLOWUP_TO] = followupto
- # set In-Reply-To header
+ # set In-Reply-To + References headers
headers[HDR.IN_REPLY_TO] = '<%s>' % message.id
-
- # set References header
- old_references = message.headers.get(HDR.REFERENCES)
- if old_references:
- old_references = old_references.split()
- references = old_references[-8:]
- if len(old_references) > 8:
- references = old_references[:1] + references
- references.append('<%s>' % message.id)
- headers[HDR.REFERENCES] = ' '.join(references)
- else:
- headers[HDR.REFERENCES] = '<%s>' % message.id
+ headers[HDR.REFERENCES] = self._reply_references(message)
# construct the envelope
envelope = Envelope(headers = headers, bodytext = mailcontent,