summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2012-09-22 10:33:25 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2012-09-22 10:33:25 +0100
commitaaadf1728c58a5afbe43cfdac9bbb1ee5b151bd8 (patch)
tree1d32b0c9d0c14351cec64d83bef8daf8fd82a7b4
parent436d656ec82a5cca5e4a2e283d9621c5378e34b3 (diff)
parent593d64781343ddeba39b0892458172d0f9a2b5d5 (diff)
Merge branch '0.3.3-feature-compose-tags-523'
-rw-r--r--alot/commands/envelope.py2
-rw-r--r--alot/commands/globals.py10
-rw-r--r--alot/db/envelope.py5
-rw-r--r--alot/defaults/alot.rc.spec3
4 files changed, 18 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/commands/globals.py b/alot/commands/globals.py
index 5ff72c7f..900aea4e 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
@@ -735,6 +736,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/db/envelope.py b/alot/db/envelope.py
index f63c671b..96abbd40 100644
--- a/alot/db/envelope.py
+++ b/alot/db/envelope.py
@@ -27,7 +27,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 <parse_template>` this string before
@@ -39,6 +39,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 = {}
@@ -56,6 +58,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
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='~')