Add repeat-command (.) command

This commit is contained in:
Jan Verbeek 2016-06-27 17:38:11 +02:00
parent 72e5bf35e1
commit f654013372
3 changed files with 25 additions and 1 deletions

View File

@ -1972,3 +1972,17 @@ class CommandDispatcher:
key: mark identifier; capital indicates a global mark
"""
self._tabbed_browser.jump_mark(key)
@cmdutils.register(instance='command-dispatcher', scope='window')
@cmdutils.argument('count', count=True)
def repeat_command(self, count=None):
"""Repeat the last executed command, like '.' in vi.
Args:
count: Which numeric argument to give the command.
"""
if runners._last_command == None:
raise cmdexc.CommandError("You didn't do anything yet.")
runners.CommandRunner(self._win_id).run(
runners._last_command[0],
count if count != None else runners._last_command[1])

View File

@ -26,12 +26,13 @@ from PyQt5.QtCore import pyqtSlot, QUrl, QObject
from qutebrowser.config import config, configexc
from qutebrowser.commands import cmdexc, cmdutils
from qutebrowser.utils import message, log, objreg, qtutils
from qutebrowser.utils import message, log, objreg, qtutils, usertypes
from qutebrowser.misc import split
ParseResult = collections.namedtuple('ParseResult', ['cmd', 'args', 'cmdline',
'count'])
_last_command = None
def _current_url(tabbed_browser):
@ -285,6 +286,14 @@ class CommandRunner(QObject):
else:
result.cmd.run(self._win_id, args)
if (result.cmdline[0] != 'repeat-command' and
(result.cmd._modes == None or
usertypes.KeyMode.normal in result.cmd._modes) and
(result.cmd._not_modes == None or
usertypes.KeyMode.normal not in result.cmd._not_modes)):
global _last_command
_last_command = (text, count)
@pyqtSlot(str, int)
@pyqtSlot(str)
def run_safely(self, text, count=None):

View File

@ -1550,6 +1550,7 @@ KEY_DATA = collections.OrderedDict([
('open qute:settings', ['Ss']),
('follow-selected', RETURN_KEYS),
('follow-selected -t', ['<Ctrl-Return>', '<Ctrl-Enter>']),
('repeat-command', ['.']),
])),
('insert', collections.OrderedDict([