summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2018-09-30 11:09:42 +0200
committerFlorian Bruhin <me@the-compiler.org>2018-09-30 11:09:42 +0200
commitd362299e4ee0751b7df0f32d15387cca033d788e (patch)
treee950e752370bb1d915ec80840e6a9d80f5bd2055
parent2630f779cdbeadaf0438718dd27bcd975deccd7f (diff)
downloadqutebrowser-d362299e4ee0751b7df0f32d15387cca033d788e.tar.gz
qutebrowser-d362299e4ee0751b7df0f32d15387cca033d788e.zip
Repeat last run macro with @@
-rw-r--r--doc/changelog.asciidoc1
-rw-r--r--qutebrowser/keyinput/macros.py9
2 files changed, 10 insertions, 0 deletions
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]: