From babfed1bc6d816d8a220f455530d72b60b71b7ee Mon Sep 17 00:00:00 2001 From: Patrick Totzke Date: Sun, 16 Sep 2012 14:36:00 +0100 Subject: add envelope.tags that contains tagstrings to add to message after successful sendout --- alot/commands/envelope.py | 2 +- alot/db/envelope.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/alot/commands/envelope.py b/alot/commands/envelope.py index b0490b6a..2a041165 100644 --- a/alot/commands/envelope.py +++ b/alot/commands/envelope.py @@ -181,7 +181,7 @@ class SendCommand(Command): # add mail to index if maildir path available if path is not None: logging.debug('adding new mail to index') - ui.dbman.add_message(path, account.sent_tags) + ui.dbman.add_message(path, account.sent_tags + envelope.tags) ui.apply_command(globals.FlushCommand()) def send_errb(failure): diff --git a/alot/db/envelope.py b/alot/db/envelope.py index 041b26d6..783cb369 100644 --- a/alot/db/envelope.py +++ b/alot/db/envelope.py @@ -26,7 +26,7 @@ from utils import encode_header class Envelope(object): """a message that is not yet sent and still editable""" def __init__(self, template=None, bodytext=u'', headers={}, attachments=[], - sign=False, sign_key=None, encrypt=False): + sign=False, sign_key=None, encrypt=False, tags=[]): """ :param template: if not None, the envelope will be initialised by :meth:`parsing ` this string before @@ -38,6 +38,8 @@ class Envelope(object): :type headers: dict (str -> unicode) :param attachments: file attachments to include :type attachments: list of :class:`~alot.db.attachment.Attachment` + :param tags: tags to add after successful sendout and saving this message + :type tags: list of str """ assert isinstance(bodytext, unicode) self.headers = {} @@ -55,6 +57,7 @@ class Envelope(object): self.sign = sign self.sign_key = sign_key self.encrypt = encrypt + self.tags = tags # tags to add after successful sendout self.sent_time = None self.modified_since_sent = False self.sending = False # semaphore to avoid accidental double sendout -- cgit v1.2.3 From 86f1e8fb270240950b558033b8b1a097c8fca37f Mon Sep 17 00:00:00 2001 From: Patrick Totzke Date: Sun, 16 Sep 2012 22:00:55 +0100 Subject: prompt for initial tags when composing msg This also adds a new config option `compose_ask_tags` that defaults to False. --- alot/commands/globals.py | 10 ++++++++++ alot/defaults/alot.rc.spec | 3 +++ 2 files changed, 13 insertions(+) diff --git a/alot/commands/globals.py b/alot/commands/globals.py index 3f57faa4..a91c8549 100644 --- a/alot/commands/globals.py +++ b/alot/commands/globals.py @@ -23,6 +23,7 @@ from alot import helper from alot.db.errors import DatabaseLockedError from alot.completion import ContactsCompleter from alot.completion import AccountCompleter +from alot.completion import TagsCompleter from alot.db.envelope import Envelope from alot import commands from alot.settings import settings @@ -740,6 +741,15 @@ class ComposeCommand(Command): return self.envelope.add('Subject', subject) + if settings.get('compose_ask_tags'): + comp = TagsCompleter(ui.dbman) + tagsstring = yield ui.prompt('Tags', completer=comp) + tags = filter(lambda x: x, tagsstring.split(',')) + if tags is None: + ui.notify('canceled') + return + self.envelope.tags = tags + if self.attach: for gpath in self.attach: for a in glob.glob(gpath): diff --git a/alot/defaults/alot.rc.spec b/alot/defaults/alot.rc.spec index 73ecc95d..9506aa04 100644 --- a/alot/defaults/alot.rc.spec +++ b/alot/defaults/alot.rc.spec @@ -1,6 +1,9 @@ ask_subject = boolean(default=True) # ask for subject when compose +# prompt for initial tags when compose +compose_ask_tags = boolean(default=False) + # directory prefix for downloading attachments attachment_prefix = string(default='~') -- cgit v1.2.3