summaryrefslogtreecommitdiff
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
parentf2ca6064f9d48ffc7e60cae448d330167beb053e (diff)
fix retagging of threads
-rw-r--r--alot/commandfactory.py9
-rw-r--r--alot/commands.py36
-rw-r--r--alot/settings.py3
3 files changed, 22 insertions, 26 deletions
diff --git a/alot/commandfactory.py b/alot/commandfactory.py
index 5c000a18..01a52412 100644
--- a/alot/commandfactory.py
+++ b/alot/commandfactory.py
@@ -45,9 +45,8 @@ COMMANDS = {
'compose': (commands.ComposeCommand, {}),
'open_envelope': (commands.OpenEnvelopeCommand, {}),
- 'searchprompt': (commands.SearchPromptCommand, {}),
'send': (commands.SendMailCommand, {}),
- 'thread_tag_prompt': (commands.ThreadTagPromptCommand, {}),
+ 'retag': (commands.ThreadTagCommand, {}),
}
@@ -97,7 +96,7 @@ globalcomands = [
]
ALLOWED_COMMANDS = {
- 'search': ['refine', 'toggletag', 'openthread'] + globalcomands,
+ 'search': ['refine', 'toggletag', 'openthread', 'retag'] + globalcomands,
'envelope': ['send'] + globalcomands,
'bufferlist': ['buffer focus', 'buffer close focussed'] + globalcomands,
'taglist': globalcomands,
@@ -134,7 +133,7 @@ def interpret_commandline(cmdline, mode):
if cmd in ['exit', 'flush', 'pyshell', 'taglist', 'buffer close',
'buffer close focussed', 'buffer next', 'buffer previous',
'buffer refresh', 'bufferlist', 'refine', 'openthread',
- 'buffer focus']:
+ 'buffer focus', 'retag']:
return commandfactory(cmd)
else:
return None
@@ -147,6 +146,8 @@ def interpret_commandline(cmdline, mode):
return commandfactory(cmd, commandstring=params)
elif cmd == 'toggletag':
return commandfactory(cmd, tag=params[0])
+ elif cmd == 'retag':
+ return commandfactory(cmd, tagsstring=params[0])
elif cmd == 'edit':
filepath = params[0]
if os.path.isfile(filepath):
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
diff --git a/alot/settings.py b/alot/settings.py
index 10d473e1..a0e7a8eb 100644
--- a/alot/settings.py
+++ b/alot/settings.py
@@ -325,8 +325,7 @@ MAPPING = {
'search': {
'|': ('refine',''),
'enter': ('openthread', ''),
- 'l': ('thread_tag_prompt', ''),
- '|': ('refine', ''),
+ 'l': ('retag', ''),
'a': ('toggletag inbox', ''),
'&': ('toggletag killed', ''),
},