diff options
author | patrick <p.totzke@ed.ac.uk> | 2011-08-09 17:58:22 +0100 |
---|---|---|
committer | patrick <p.totzke@ed.ac.uk> | 2011-08-09 17:58:22 +0100 |
commit | 95e5d1127506a9c0a55672f3ab2200aec4501061 (patch) | |
tree | 696c45e8e12fef228ab504ca44aa77eb674b2c44 /alot | |
parent | 122e7158b94fb811a60cd76a9609c97d2faa37e5 (diff) |
let the user confirm io intensive search for *
Diffstat (limited to 'alot')
-rw-r--r-- | alot/command.py | 33 | ||||
-rw-r--r-- | alot/ui.py | 2 |
2 files changed, 22 insertions, 13 deletions
diff --git a/alot/command.py b/alot/command.py index 73e24abd..3a5b1222 100644 --- a/alot/command.py +++ b/alot/command.py @@ -81,17 +81,19 @@ class OpenThreadCommand(Command): class SearchCommand(Command): """open a new search buffer""" - def __init__(self, query, force_new=False, **kwargs): + def __init__(self, query, **kwargs): """ - @param query initial querystring - @param force_new True forces a new buffer + :param query: initial querystring """ self.query = query - self.force_new = force_new Command.__init__(self, **kwargs) def apply(self, ui): - if not self.force_new: + if self.query: + if self.query == '*': + s = 'really search for all threads? This takes a while..' + if not ui.choice(s) == 'yes': + return open_searches = ui.get_buffers_of_type(buffer.SearchBuffer) to_be_focused = None for sb in open_searches: @@ -102,7 +104,7 @@ class SearchCommand(Command): else: ui.buffer_open(buffer.SearchBuffer(ui, self.query)) else: - ui.buffer_open(buffer.SearchBuffer(ui, self.query)) + ui.notify('empty query string') class PromptCommand(Command): @@ -419,13 +421,20 @@ class RefineCommand(Command): Command.__init__(self, **kwargs) def apply(self, ui): - sbuffer = ui.current_buffer - oldquery = sbuffer.querystring - if self.querystring not in [None, oldquery]: - sbuffer.querystring = self.querystring + if self.querystring: + if self.querystring == '*': + s = 'really search for all threads? This takes a while..' + if not ui.choice(s) == 'yes': + return sbuffer = ui.current_buffer - sbuffer.rebuild() - ui.update() + oldquery = sbuffer.querystring + if self.querystring not in [None, oldquery]: + sbuffer.querystring = self.querystring + sbuffer = ui.current_buffer + sbuffer.rebuild() + ui.update() + else: + ui.notify('empty query string') class RefinePromptCommand(Command): @@ -208,7 +208,7 @@ class UI: self.notificationbar = None self.update() - def choice(self, message, choices={'yes':['y','q'], 'no':['n']}): + def choice(self, message, choices={'yes':['y'], 'no':['n']}): """prompt user to make a choice :param message: string to display before list of choices :type message: unicode |