From b0ea0764a69602f0d6a644b4068ad26538dc0a6e Mon Sep 17 00:00:00 2001 From: Patrick Totzke Date: Sat, 8 Oct 2011 23:06:42 +0100 Subject: set/refine commands for envelope buffers --- alot/command.py | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'alot') diff --git a/alot/command.py b/alot/command.py index ea32be45..bd47a18b 100644 --- a/alot/command.py +++ b/alot/command.py @@ -982,6 +982,19 @@ class EnvelopeSetCommand(Command): envelope.rebuild() +class EnvelopeRefineCommand(Command): + """prompt to change current value of header field""" + + def __init__(self, key='', **kwargs): + Command.__init__(self, **kwargs) + self.key = key + + def apply(self, ui): + mail = ui.current_buffer.get_email() + value = mail.get(self.key, '') + ui.commandprompt('set %s %s' % (self.key, value)) + + class EnvelopeSendCommand(Command): @defer.inlineCallbacks def apply(self, ui): @@ -1136,8 +1149,8 @@ COMMANDS = { 'attach': (EnvelopeAttachCommand, {}), 'send': (EnvelopeSendCommand, {}), 'reedit': (EnvelopeEditCommand, {}), - 'subject': (EnvelopeSetCommand, {'key': 'Subject'}), - 'to': (EnvelopeSetCommand, {'key': 'To'}), + 'refine': (EnvelopeRefineCommand, {}), + 'set': (EnvelopeSetCommand, {}), }, 'bufferlist': { 'closefocussed': (BufferCloseCommand, {'focussed': True}), @@ -1248,15 +1261,18 @@ def interpret_commandline(cmdline, mode): elif cmd == 'prompt': return commandfactory(cmd, mode=mode, startstring=params) elif cmd == 'refine': - return commandfactory(cmd, mode=mode, query=params) + if mode == 'search': + return commandfactory(cmd, mode=mode, query=params) + elif mode == 'envelope': + return commandfactory(cmd, mode=mode, key=params) + elif cmd == 'retag': return commandfactory(cmd, mode=mode, tagsstring=params) - elif cmd == 'subject': - return commandfactory(cmd, mode=mode, key='Subject', value=params) elif cmd == 'shellescape': return commandfactory(cmd, mode=mode, commandstring=params) - elif cmd == 'to': - return commandfactory(cmd, mode=mode, key='To', value=params) + elif cmd == 'set': + key, value = params.split(' ', 1) + return commandfactory(cmd, mode=mode, key=key, value=value) elif cmd == 'toggletag': return commandfactory(cmd, mode=mode, tags=params.split()) elif cmd == 'fold': -- cgit v1.2.3