diff options
-rw-r--r-- | alot/command.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/alot/command.py b/alot/command.py index 942d7797..af5f3308 100644 --- a/alot/command.py +++ b/alot/command.py @@ -397,26 +397,34 @@ class ComposeCommand(Command): # SEARCH class RetagPromptCommand(Command): - """start a commandprompt to retag selected threads' tags""" + """start a commandprompt to retag selected threads' tags + this is needed to fill the prompt with the current tags.. + """ def apply(self, ui): thread = ui.current_buffer.get_selected_thread() + if not thread: + return initial_tagstring = ','.join(thread.get_tags()) ui.commandprompt('retag ' + initial_tagstring) class RetagCommand(Command): """tag selected thread""" - def __init__(self, tagsstring=u'', **kwargs): + def __init__(self, tagsstring=u'', thread=None, **kwargs): self.tagsstring = tagsstring + self.thread = thread Command.__init__(self, **kwargs) def apply(self, ui): - thread = ui.current_buffer.get_selected_thread() - initial_tagstring = ','.join(thread.get_tags()) + if not self.thread: + self.thread = ui.current_buffer.get_selected_thread() + if not self.thread: + return + initial_tagstring = ','.join(self.thread.get_tags()) tags = filter(lambda x: x, self.tagsstring.split(',')) ui.logger.info("got %s:%s" % (self.tagsstring, tags)) try: - thread.set_tags(tags) + self.thread.set_tags(tags) except DatabaseROError, e: ui.notify('index in read-only mode', priority='error') return @@ -663,6 +671,8 @@ class PrintCommand(Command): # get messages to print if self.all: thread = ui.current_buffer.get_selected_thread() + if not thread: + return to_print = thread.get_messages().keys() confirm_msg = 'print all messages in thread?' ok_msg = 'printed thread: %s' % str(thread) |