summaryrefslogtreecommitdiff
path: root/alot
diff options
context:
space:
mode:
authorChristopher Schwardt <nookieman@gmx.de>2012-11-07 22:49:03 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2013-02-19 18:43:16 +0000
commite823e47b150aff4a1939e8cfddefebf699ab301d (patch)
tree2efe04e17eaa462362c19947c715369ce3cf8f3d /alot
parentecf5a504019b8ed57a903332e6f256225519297e (diff)
add repeat command to make the same action again
The UI object now saves the last executed command (except for RepeatCommands themselves and Promt- and FlushCommands, since they are not user invoked, intended actions). The RepeatCommand then applies the stored command again. This is comparable to the . in vim, so I would recommend you add this line to your config ;) . = repeat
Diffstat (limited to 'alot')
-rw-r--r--alot/commands/globals.py10
-rw-r--r--alot/ui.py9
2 files changed, 19 insertions, 0 deletions
diff --git a/alot/commands/globals.py b/alot/commands/globals.py
index eee6a7c0..3f55bcf2 100644
--- a/alot/commands/globals.py
+++ b/alot/commands/globals.py
@@ -310,6 +310,16 @@ class PythonShellCommand(Command):
ui.mainloop.screen.start()
+@registerCommand(MODE, 'repeat')
+class RepeatCommand(Command):
+ """Repeats the command executed last time"""
+ def apply(self, ui):
+ if ui.last_command != None:
+ ui.apply_command(ui.last_command)
+ else:
+ ui.notify('no last command')
+
+
@registerCommand(MODE, 'call', arguments=[
(['command'], {'help':'python command string to call'})])
class CallCommand(Command):
diff --git a/alot/ui.py b/alot/ui.py
index 68f9bf15..f04e79ff 100644
--- a/alot/ui.py
+++ b/alot/ui.py
@@ -10,6 +10,9 @@ from buffers import BufferlistBuffer
from commands import commandfactory
from alot.commands import CommandParseError
from alot.commands.globals import CommandSequenceCommand
+from alot.commands.globals import FlushCommand
+from alot.commands.globals import PromptCommand
+from alot.commands.globals import RepeatCommand
from alot.helper import string_decode
from alot.helper import split_commandline
from alot.widgets.globals import CompleteEdit
@@ -37,6 +40,8 @@ class UI(object):
"""history of the command line prompt"""
input_queue = []
"""stores partial keyboard input"""
+ last_command = None
+ """saves the last executed command"""
def __init__(self, dbman, initialcmd):
"""
@@ -169,6 +174,10 @@ class UI(object):
else:
cmd = CommandSequenceCommand(cmdlist)
self.apply_command(cmd)
+ if not isinstance(cmd, RepeatCommand) and \
+ not isinstance(cmd, PromptCommand) and \
+ not isinstance(cmd, FlushCommand):
+ self.last_command = cmd
def _unhandeled_input(self, key):
"""