summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpazz <patricktotzke@gmail.com>2011-05-29 19:11:11 +0100
committerpazz <patricktotzke@gmail.com>2011-05-29 19:11:11 +0100
commit20cde73a7bb384294eb83fc74c90fc34f7731d5a (patch)
treea6210e749893d2591308cdb847efd0e99f38f34f
parent8ce1082ba4330b5b5dd0bfc5f14455e12b7d554c (diff)
more consistant Command names, at <=1 bufferlist
-rw-r--r--alot/command.py22
-rw-r--r--alot/ui.py3
2 files changed, 14 insertions, 11 deletions
diff --git a/alot/command.py b/alot/command.py
index bf0e2437..5a89d52e 100644
--- a/alot/command.py
+++ b/alot/command.py
@@ -11,7 +11,7 @@ import settings
class Command:
"""base class for commands"""
- def __init__(self, prehook=None, posthook=None):
+ def __init__(self, prehook=None, posthook=None, **ignored):
self.prehook = prehook
self.posthook = posthook
self.undoable = False
@@ -52,8 +52,7 @@ class SearchCommand(Command):
def apply(self, ui):
if not self.force_new:
- open_searches = filter(lambda x: isinstance(x, buffer.SearchBuffer),
- ui.buffers)
+ open_searches = ui.get_buffers_of_type(buffer.SearchBuffer)
to_be_focused = None
for sb in open_searches:
if sb.querystring == self.query:
@@ -191,7 +190,7 @@ class BufferFocusCommand(Command):
ui.buffer_focus(ui.buffers[(idx + self.offset) % num])
-class BufferListCommand(Command):
+class OpenBufferListCommand(Command):
"""
open a bufferlist
"""
@@ -200,13 +199,14 @@ class BufferListCommand(Command):
Command.__init__(self, **kwargs)
def apply(self, ui):
- buf = buffer.BufferListBuffer(ui, self.filtfun)
- ui.buffers.append(buf)
- buf.rebuild()
- ui.buffer_focus(buf)
+ blists = ui.get_buffers_of_type(buffer.BufferListBuffer)
+ if blists:
+ ui.buffer_focus(blists[0])
+ else:
+ ui.buffer_open(buffer.BufferListBuffer(ui, self.filtfun))
-class TagListCommand(Command):
+class OpenTagListCommand(Command):
"""
open a taglist
"""
@@ -288,12 +288,12 @@ class RefineSearchPromptCommand(Command):
commands = {
'buffer_close': (BufferCloseCommand, {}),
'buffer_focus': (BufferFocusCommand, {}),
- 'buffer_list': (BufferListCommand, {}),
+ 'buffer_list': (OpenBufferListCommand, {}),
'buffer_next': (BufferFocusCommand, {'offset': 1}),
'buffer_prev': (BufferFocusCommand, {'offset': -1}),
'call_editor': (EditCommand, {}),
'call_pager': (PagerCommand, {}),
- 'open_taglist': (TagListCommand, {}),
+ 'open_taglist': (OpenTagListCommand, {}),
'open_thread': (OpenThreadCommand, {}),
'search': (SearchCommand, {}),
'search_prompt': (SearchPromptCommand, {}),
diff --git a/alot/ui.py b/alot/ui.py
index b95ea009..747bcd90 100644
--- a/alot/ui.py
+++ b/alot/ui.py
@@ -113,6 +113,9 @@ class UI:
self.current_buffer.rebuild()
self.update()
+ def get_buffers_of_type(self, t):
+ return filter(lambda x: isinstance(x,t), self.buffers)
+
def update(self):
"""
redraw interface