diff options
author | pazz <patricktotzke@gmail.com> | 2011-07-19 22:43:52 +0100 |
---|---|---|
committer | pazz <patricktotzke@gmail.com> | 2011-07-19 22:43:52 +0100 |
commit | ef2edc0210377f02638eb30ed3f09c67410f6569 (patch) | |
tree | 6c11d33f1e4d7dc26582b70f87e373f05c2ee061 | |
parent | 1e0d2ad1d6ce3ee71e187831faa5cff1a617b852 (diff) |
subject & to commands for envelopes + mappings
to overwrite header fields. completes issue #27
-rw-r--r-- | alot/commandfactory.py | 14 | ||||
-rw-r--r-- | alot/commands.py | 17 | ||||
-rw-r--r-- | alot/settings.py | 8 |
3 files changed, 34 insertions, 5 deletions
diff --git a/alot/commandfactory.py b/alot/commandfactory.py index 0ce715f3..80d321d0 100644 --- a/alot/commandfactory.py +++ b/alot/commandfactory.py @@ -45,8 +45,11 @@ COMMANDS = { 'shellescape': (commands.ExternalCommand, {}), 'taglist': (commands.TagListCommand, {}), 'toggletag': (commands.ToggleThreadTagCommand, {'tag': 'inbox'}), + # envelope 'send': (commands.SendMailCommand, {}), 'reedit': (commands.EnvelopeReeditCommand, {}), + 'subject': (commands.EnvelopeSetCommand, {'key': 'Subject'}), + 'to': (commands.EnvelopeSetCommand, {'key': 'To'}), 'open_envelope': (commands.OpenEnvelopeCommand, {}), 'retag': (commands.RetagCommand, {}), @@ -100,8 +103,9 @@ globalcomands = [ ] ALLOWED_COMMANDS = { - 'search': ['refine', 'refineprompt', 'toggletag', 'openthread', 'retag', 'retagprompt'] + globalcomands, - 'envelope': ['send', 'reedit'] + globalcomands, + 'search': ['refine', 'refineprompt', 'toggletag', 'openthread', 'retag', + 'retagprompt'] + globalcomands, + 'envelope': ['send', 'reedit', 'to', 'subject'] + globalcomands, 'bufferlist': ['openfocussed', 'closefocussed'] + globalcomands, 'taglist': globalcomands, 'thread': ['toggletag'] + globalcomands, @@ -134,7 +138,7 @@ def interpret_commandline(cmdline, mode): return None if not params: # commands that work without parameter - if cmd in ['exit', 'flush', 'pyshell', 'taglist', 'close','compose', + if cmd in ['exit', 'flush', 'pyshell', 'taglist', 'close', 'compose', 'openfocussed', 'closefocussed', 'bnext', 'bprevious', 'retag', 'refresh', 'bufferlist', 'refineprompt', 'openthread', 'send', 'reedit', 'retagprompt']: @@ -152,8 +156,12 @@ def interpret_commandline(cmdline, mode): return commandfactory(cmd, query=params) elif cmd == 'retag': return commandfactory(cmd, tagsstring=params) + elif cmd == 'subject': + return commandfactory(cmd, key='Subject', value=params) elif cmd == 'shellescape': return commandfactory(cmd, commandstring=params) + elif cmd == 'to': + return commandfactory(cmd, key='To', value=params) elif cmd == 'toggletag': return commandfactory(cmd, tag=params) elif cmd == 'edit': diff --git a/alot/commands.py b/alot/commands.py index b4e5d6b7..2b8d312a 100644 --- a/alot/commands.py +++ b/alot/commands.py @@ -514,3 +514,20 @@ class EnvelopeReeditCommand(Command): on_success=readTmpfile, refocus=False)) + +class EnvelopeSetCommand(Command): + """sets header fields of mail open in envelope buffer""" + + def __init__(self, key='', value='', **kwargs): + self.key = key + self.value = value + Command.__init__(self, **kwargs) + + def apply(self, ui): + envelope = ui.current_buffer + mail = envelope.get_email() + if self.key in mail: + mail.replace_header(self.key, self.value) + else: + mail[self.key] = self.value + envelope.rebuild() diff --git a/alot/settings.py b/alot/settings.py index 16a68606..24eb2b1d 100644 --- a/alot/settings.py +++ b/alot/settings.py @@ -324,7 +324,7 @@ MAPPING = { 'm': ('compose', ''), }, 'search': { - '|': ('refineprompt',''), + '|': ('refineprompt', ''), 'enter': ('openthread', ''), 'l': ('retagprompt', ''), 'a': ('toggletag inbox', ''), @@ -340,6 +340,8 @@ MAPPING = { 'envelope': { 'y': ('send', ''), 'enter': ('reedit', ''), + 't': ('prompt to', ''), + 's': ('prompt subject', ''), }, 'bufferlist': { 'd': ('closefocussed', ''), @@ -347,6 +349,7 @@ MAPPING = { } } + def get_mappings_by_mode(mode): if not mode in MAPPING: return None # invalid mode string @@ -354,9 +357,10 @@ def get_mappings_by_mode(mode): maps.update(MAPPING[mode]) return maps + def get_mapping(key, mode): maps = get_mappings_by_mode(mode) if key in maps: return maps[key] else: - return None,None + return None, None |