diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2011-09-15 19:50:00 +0100 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2011-09-15 19:50:00 +0100 |
commit | 146b63aaf9e229ba6e828cb9a8434b241e229a79 (patch) | |
tree | 0a9994dde6d9a2113fd6d16acfd6603e631c0c4d | |
parent | 5e0de3f7e7a4141f4c814c51dc31155ca8602ee2 (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 3a348af5..229b163e 100644 --- a/alot/command.py +++ b/alot/command.py @@ -405,26 +405,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 @@ -683,6 +691,8 @@ class PipeCommand(Command): # get messages to pipe if self.whole_thread: thread = ui.current_buffer.get_selected_thread() + if not thread: + return to_print = thread.get_messages().keys() else: to_print = [ui.current_buffer.get_selected_message()] |