summaryrefslogtreecommitdiff
path: root/alot/commands.py
diff options
context:
space:
mode:
authorpazz <patricktotzke@gmail.com>2011-07-17 00:08:09 +0100
committerpazz <patricktotzke@gmail.com>2011-07-17 00:08:09 +0100
commit43268e0c0f54b716fe034ad8c976ea01338495f6 (patch)
treee28100b7623e3f3054ef53d8bb76b6c9d41037f9 /alot/commands.py
parentf2ca6064f9d48ffc7e60cae448d330167beb053e (diff)
fix retagging of threads
Diffstat (limited to 'alot/commands.py')
-rw-r--r--alot/commands.py36
1 files changed, 16 insertions, 20 deletions
diff --git a/alot/commands.py b/alot/commands.py
index acfb69a8..23499734 100644
--- a/alot/commands.py
+++ b/alot/commands.py
@@ -96,15 +96,12 @@ class SearchCommand(Command):
ui.buffer_open(buffer.SearchBuffer(ui, self.query))
-class SearchPromptCommand(Command):
- """prompt the user for a querystring, then start a search"""
+class PromptCommand(Command):
+ def __init__(self, startstring='', **kwargs):
+ self.startstring = startstring
+
def apply(self, ui):
- querystring = ui.prompt('search threads: ',
- completer=completion.QueryCompleter(ui.dbman))
- ui.logger.info("got %s" % querystring)
- if querystring:
- cmd = factory('search', query=querystring)
- ui.apply_command(cmd)
+ ui.commandprompt(self.startstring)
class RefreshCommand(Command):
@@ -404,24 +401,23 @@ class ComposeCommand(Command):
refocus=False))
-class ThreadTagPromptCommand(Command):
+class ThreadTagCommand(Command):
"""prompt the user for labels, then tag thread"""
- def __init__(self, thread, **kwargs):
- assert thread
- self.thread = thread
+ def __init__(self, tagsstring=None, **kwargs):
+ self.tagsstring = tagsstring
Command.__init__(self, **kwargs)
def apply(self, ui):
- initial_tagstring = ','.join(self.thread.get_tags())
- tagsstring = ui.prompt('label thread:',
- text=initial_tagstring,
- completer=completion.TagListCompleter(ui.dbman))
- if tagsstring != None: # esc -> None, enter could return ''
- tags = filter(lambda x: x, tagsstring.split(','))
- ui.logger.info("got %s:%s" % (tagsstring, tags))
+ thread = ui.current_buffer.get_selected_thread()
+ initial_tagstring = ','.join(thread.get_tags())
+ if self.tagsstring == None:
+ ui.commandprompt('retag ' + initial_tagstring)
+ else:
+ tags = filter(lambda x: x, self.tagsstring.split(','))
+ ui.logger.info("got %s:%s" % (self.tagsstring, tags))
try:
- self.thread.set_tags(tags)
+ thread.set_tags(tags)
except DatabaseROError, e:
ui.notify('index in read-only mode')
return