diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2011-09-15 19:50:00 +0100 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2011-09-15 23:28:16 +0100 |
commit | a4530960317575e379373ffd38fd05c0ce4c304d (patch) | |
tree | f36aca1927a7a5cab3a6958b152ffad89e92ae2d | |
parent | 8e04392b47bf50c9aebc587d9308513741771eed (diff) |
fix error on retag on empty search
-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) |