From d362299e4ee0751b7df0f32d15387cca033d788e Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sun, 30 Sep 2018 11:09:42 +0200 Subject: Repeat last run macro with @@ --- doc/changelog.asciidoc | 1 + qutebrowser/keyinput/macros.py | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/doc/changelog.asciidoc b/doc/changelog.asciidoc index 28992a1ea..70274a591 100644 --- a/doc/changelog.asciidoc +++ b/doc/changelog.asciidoc @@ -82,6 +82,7 @@ Changed - The `scrolling.bar` setting now takes three values instead of being a boolean: `always`, `never`, and `when-searching` (which only displays it while a search is active). +- '@@' now repeats the last run macro. Fixed ~~~~~ diff --git a/qutebrowser/keyinput/macros.py b/qutebrowser/keyinput/macros.py index 08740d80d..97b0b103b 100644 --- a/qutebrowser/keyinput/macros.py +++ b/qutebrowser/keyinput/macros.py @@ -34,12 +34,14 @@ class MacroRecorder: _macro_count: The count passed to run_macro_command for each window. Stored for use by run_macro, which may be called from keyinput/modeparsers.py after a key input. + _last_register: The macro which did run last. """ def __init__(self): self._macros = {} self._recording_macro = None self._macro_count = {} + self._last_register = None @cmdutils.register(instance='macro-recorder', name='record-macro') @cmdutils.argument('win_id', win_id=True) @@ -85,9 +87,16 @@ class MacroRecorder: def run_macro(self, win_id, register): """Run a recorded macro.""" + if register == '@': + if self._last_register is None: + raise cmdexc.CommandError("No previous macro") + register = self._last_register + self._last_register = register + if register not in self._macros: raise cmdexc.CommandError( "No macro recorded in '{}'!".format(register)) + commandrunner = runners.CommandRunner(win_id) for _ in range(self._macro_count[win_id]): for cmd in self._macros[register]: -- cgit v1.2.3-54-g00ecf