diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2011-12-17 12:54:15 +0000 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2011-12-17 12:54:15 +0000 |
commit | 41e9e6df6ba0498f18466b34d630b0ffbacdbfad (patch) | |
tree | 0d14e05c314056776bb2ed41f896fa8f75955b93 /alot/ui.py | |
parent | 46238e661c1541da24a91517fef7659bad69d8cb (diff) |
feature: make quit on last bclose configurable
issue #159
Diffstat (limited to 'alot/ui.py')
-rw-r--r-- | alot/ui.py | 30 |
1 files changed, 12 insertions, 18 deletions
@@ -201,31 +201,25 @@ class UI(object): """ closes given :class:`~alot.buffers.Buffer`. - This shuts down alot in case its the last - active buffer. Otherwise it removes it from the bufferlist - and calls its cleanup() method. + This it removes it from the bufferlist and calls its cleanup() method. """ buffers = self.buffers if buf not in buffers: string = 'tried to close unknown buffer: %s. \n\ni have:%s' self.logger.error(string % (buf, self.buffers)) - elif len(buffers) == 1: - self.logger.info('closing the last buffer, exiting') - cmd = commandfactory('exit') - self.apply_command(cmd) + elif self.current_buffer == buf: + self.logger.debug('UI: closing current buffer %s' % buf) + index = buffers.index(buf) + buffers.remove(buf) + offset = config.getint('general', 'bufferclose_focus_offset') + nextbuffer = buffers[(index + offset) % len(buffers)] + self.buffer_focus(nextbuffer) + buf.cleanup() else: - if self.current_buffer == buf: - self.logger.debug('UI: closing current buffer %s' % buf) - index = buffers.index(buf) - buffers.remove(buf) - offset = config.getint('general', 'bufferclose_focus_offset') - nextbuffer = buffers[(index + offset) % len(buffers)] - self.buffer_focus(nextbuffer) - else: - string = 'closing buffer %d:%s' - self.logger.debug(string % (buffers.index(buf), buf)) - buffers.remove(buf) + string = 'closing buffer %d:%s' + self.logger.debug(string % (buffers.index(buf), buf)) + buffers.remove(buf) buf.cleanup() def buffer_focus(self, buf): |