diff options
author | Kazuo Teramoto <kaz.rag@gmail.com> | 2012-07-24 18:18:47 -0300 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2012-08-01 22:01:21 +0100 |
commit | f4b1bd29406ba164f48ae02534dc167af04db94f (patch) | |
tree | 15b2f8ae0c484b57e87f781a35fdfb94d335a6e9 /alot | |
parent | d630ba316bd984a18c918730c14d45d2a634f17c (diff) |
Add `bclose!` command
This command is similar to `bclose` but it force closing a buffer
without asking the user.
cf issue #453
Diffstat (limited to 'alot')
-rw-r--r-- | alot/commands/globals.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/alot/commands/globals.py b/alot/commands/globals.py index 43f58a91..3a650815 100644 --- a/alot/commands/globals.py +++ b/alot/commands/globals.py @@ -329,14 +329,18 @@ class CallCommand(Command): @registerCommand(MODE, 'bclose') +@registerCommand(MODE, 'bclose!', forced={'force': True}) class BufferCloseCommand(Command): """close a buffer""" - def __init__(self, buffer=None, **kwargs): + def __init__(self, buffer=None, force=False, **kwargs): """ :param buffer: the buffer to close or None for current :type buffer: `alot.buffers.Buffer` + :param force: force buffer close + :type force: bool """ self.buffer = buffer + self.force = force Command.__init__(self, **kwargs) @inlineCallbacks @@ -346,8 +350,9 @@ class BufferCloseCommand(Command): if (isinstance(self.buffer, buffers.EnvelopeBuffer) and not self.buffer.envelope.sent_time): - if (yield ui.choice('close without sending?', select='yes', - cancel='no', msg_position='left')) == 'no': + if (not self.force and + (yield ui.choice('close without sending?', select='yes', + cancel='no', msg_position='left')) == 'no'): return if len(ui.buffers) == 1: |