diff --git a/qutebrowser/app.py b/qutebrowser/app.py index 234d2dd7a..359f7cd3d 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -758,7 +758,8 @@ class Application(QApplication): else: return True - @cmdutils.register(instance='app', maxsplit=0, debug=True) + @cmdutils.register(instance='app', maxsplit=0, debug=True, + no_cmd_split=True) def debug_pyeval(self, s): """Evaluate a python string and display the results as a web page. diff --git a/qutebrowser/commands/cmdutils.py b/qutebrowser/commands/cmdutils.py index 5a5b5db0c..8fc29a0dc 100644 --- a/qutebrowser/commands/cmdutils.py +++ b/qutebrowser/commands/cmdutils.py @@ -116,7 +116,7 @@ class register: # pylint: disable=invalid-name def __init__(self, instance=None, name=None, maxsplit=None, hide=False, completion=None, modes=None, not_modes=None, needs_js=False, debug=False, ignore_args=False, deprecated=False, - scope='global'): + no_cmd_split=False, scope='global'): """Save decorator arguments. Gets called on parse-time with the decorator arguments. @@ -139,6 +139,7 @@ class register: # pylint: disable=invalid-name self._deprecated = deprecated self._debug = debug self._ignore_args = ignore_args + self._no_cmd_split = no_cmd_split if modes is not None: for m in modes: if not isinstance(m, usertypes.KeyMode): @@ -196,7 +197,8 @@ class register: # pylint: disable=invalid-name completion=self._completion, modes=self._modes, not_modes=self._not_modes, needs_js=self._needs_js, is_debug=self._debug, ignore_args=self._ignore_args, - deprecated=self._deprecated, handler=func) + deprecated=self._deprecated, no_cmd_split=self._no_cmd_split, + handler=func) for name in names: cmd_dict[name] = cmd aliases += names[1:] diff --git a/qutebrowser/commands/command.py b/qutebrowser/commands/command.py index 1781f25a5..87d09627d 100644 --- a/qutebrowser/commands/command.py +++ b/qutebrowser/commands/command.py @@ -46,6 +46,7 @@ class Command: special_params: A dict with the names of the special parameters as values. flags_with_args: A list of flags which take an argument. + no_cmd_split: If true, ';;' to split sub-commands is ignored. _type_conv: A mapping of conversion functions for arguments. _name_conv: A mapping of argument names to parameter names. _needs_js: Whether the command needs javascript enabled @@ -65,7 +66,7 @@ class Command: def __init__(self, name, maxsplit, hide, instance, completion, modes, not_modes, needs_js, is_debug, ignore_args, deprecated, - handler, scope): + no_cmd_split, handler, scope): # I really don't know how to solve this in a better way, I tried. # pylint: disable=too-many-arguments,too-many-locals self.name = name @@ -81,6 +82,7 @@ class Command: self.debug = is_debug self.ignore_args = ignore_args self.handler = handler + self.no_cmd_split = no_cmd_split self.docparser = docutils.DocstringParser(handler) self.parser = argparser.ArgumentParser( name, description=self.docparser.short_desc, diff --git a/qutebrowser/commands/runners.py b/qutebrowser/commands/runners.py index 478bf87df..a0cde9992 100644 --- a/qutebrowser/commands/runners.py +++ b/qutebrowser/commands/runners.py @@ -279,11 +279,14 @@ class CommandRunner(QObject): text: The text to parse. count: The count to pass to the command. """ - if ';;' in text: - for sub in text.split(';;'): - self.run(sub, count) - return self.parse(text) + if ';;' in text: + # Get the first command and check if it doesn't want to have ;; + # split. + if not self._cmd.no_cmd_split: + for sub in text.split(';;'): + self.run(sub, count) + return args = replace_variables(self._win_id, self._args) if count is not None: self._cmd.run(self._win_id, args, count=count) diff --git a/qutebrowser/config/parsers/keyconf.py b/qutebrowser/config/parsers/keyconf.py index 5487afb11..5d94a26fc 100644 --- a/qutebrowser/config/parsers/keyconf.py +++ b/qutebrowser/config/parsers/keyconf.py @@ -139,7 +139,7 @@ class KeyConfigParser(QObject): data = str(self) f.write(data) - @cmdutils.register(instance='key-config', maxsplit=1) + @cmdutils.register(instance='key-config', maxsplit=1, no_cmd_split=True) def bind(self, key, command, *, mode=None, force=False): """Bind a key to a command. diff --git a/qutebrowser/misc/utilcmds.py b/qutebrowser/misc/utilcmds.py index 5d34af984..9d4295da2 100644 --- a/qutebrowser/misc/utilcmds.py +++ b/qutebrowser/misc/utilcmds.py @@ -34,7 +34,7 @@ from qutebrowser.config import style from qutebrowser.misc import consolewidget -@cmdutils.register(scope='window', maxsplit=1) +@cmdutils.register(scope='window', maxsplit=1, no_cmd_split=True) def later(ms: {'type': int}, command, win_id: {'special': 'win_id'}): """Execute a command after some time. @@ -63,7 +63,7 @@ def later(ms: {'type': int}, command, win_id: {'special': 'win_id'}): raise -@cmdutils.register(scope='window', maxsplit=1) +@cmdutils.register(scope='window', maxsplit=1, no_cmd_split=True) def repeat(times: {'type': int}, command, win_id: {'special': 'win_id'}): """Repeat a given command. @@ -122,7 +122,7 @@ def debug_console(): con_widget.show() -@cmdutils.register(debug=True, maxsplit=0) +@cmdutils.register(debug=True, maxsplit=0, no_cmd_split=True) def debug_trace(expr=""): """Trace executed code via hunter.