Have 'times' multiply with [count] by default

This commit is contained in:
wishfort36 2018-08-11 18:31:17 +02:00
parent b085a8a7de
commit f27195d360
2 changed files with 5 additions and 7 deletions

View File

@ -910,7 +910,7 @@ The tab index to reload.
[[repeat]] [[repeat]]
=== repeat === repeat
Syntax: +:repeat [*--mulcount*] 'times' 'command'+ Syntax: +:repeat 'times' 'command'+
Repeat a given command. Repeat a given command.
@ -918,8 +918,8 @@ Repeat a given command.
* +'times'+: How many times to repeat. * +'times'+: How many times to repeat.
* +'command'+: The command to run, with optional args. * +'command'+: The command to run, with optional args.
==== optional arguments ==== count
* +*-c*+, +*--mulcount*+: When given, 'times' will be multiplied with [count]. Multiplies with 'times' when given
==== note ==== note
* This command does not split arguments after the last argument and handles quotes literally. * This command does not split arguments after the last argument and handles quotes literally.

View File

@ -75,17 +75,15 @@ def later(ms: int, command, win_id):
@cmdutils.register(maxsplit=1, no_cmd_split=True, no_replace_variables=True) @cmdutils.register(maxsplit=1, no_cmd_split=True, no_replace_variables=True)
@cmdutils.argument('win_id', win_id=True) @cmdutils.argument('win_id', win_id=True)
@cmdutils.argument('count', count=True) @cmdutils.argument('count', count=True)
@cmdutils.argument('mulcount', flag='c') def repeat(times: int, command, win_id, count=None):
def repeat(times: int, command, win_id, count=None, mulcount=False):
"""Repeat a given command. """Repeat a given command.
Args: Args:
times: How many times to repeat. times: How many times to repeat.
command: The command to run, with optional args. command: The command to run, with optional args.
mulcount: Multiply 'times' with [count].
""" """
if mulcount and count is not None: if count is not None:
times *= count times *= count
if times < 0: if times < 0: