From 836a5e04a5789bcbd9184ea892079d501745dd07 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 2 May 2014 06:59:46 +0200 Subject: [PATCH] Allow empty keys in config --- TODO | 1 - qutebrowser/config/_conftypes.py | 2 ++ qutebrowser/keyinput/_basekeyparser.py | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/TODO b/TODO index 6866092c1..7bb301e30 100644 --- a/TODO +++ b/TODO @@ -40,7 +40,6 @@ Ctrl+A/X to increase/decrease last number in URL command completion gets hidden when doing a new ValueList value logging contexts catch import errors for PyQt and QtWebKit -Allow binding to empty values for keys to override defaults How do we handle empty values in input bar? - Add more element-selection-detection code (with options?) based on: -> javascript: http://stackoverflow.com/a/2848120/2085149 diff --git a/qutebrowser/config/_conftypes.py b/qutebrowser/config/_conftypes.py index cb2660ec0..168ff9c3b 100644 --- a/qutebrowser/config/_conftypes.py +++ b/qutebrowser/config/_conftypes.py @@ -430,6 +430,8 @@ class Command(BaseType): typestr = 'command' def validate(self, value): + if not value: + return if value.split()[0] not in cmdutils.cmd_dict: raise ValidationError(value, "must be a valid command!") diff --git a/qutebrowser/keyinput/_basekeyparser.py b/qutebrowser/keyinput/_basekeyparser.py index 54284052f..95015da7e 100644 --- a/qutebrowser/keyinput/_basekeyparser.py +++ b/qutebrowser/keyinput/_basekeyparser.py @@ -309,7 +309,9 @@ class BaseKeyParser(QObject): if not sect.items(): logging.warn("No keybindings defined!") for (key, cmd) in sect.items(): - if key.startswith('<') and key.endswith('>'): + if not cmd: + continue + elif key.startswith('<') and key.endswith('>'): keystr = self._normalize_keystr(key[1:-1]) logging.debug("registered special key: {} -> {}".format(keystr, cmd))