Allow binding to an alias.

Fix #1813: Cannot :bind to alias
This commit is contained in:
Ryan Roden-Corrent 2016-08-09 07:35:26 -04:00
parent 00673ef7da
commit 245212efa1
2 changed files with 15 additions and 2 deletions

View File

@ -25,7 +25,7 @@ import itertools
from PyQt5.QtCore import pyqtSignal, QObject from PyQt5.QtCore import pyqtSignal, QObject
from qutebrowser.config import configdata, textwrapper from qutebrowser.config import configdata, textwrapper, config
from qutebrowser.commands import cmdutils, cmdexc from qutebrowser.commands import cmdutils, cmdexc
from qutebrowser.utils import log, utils, qtutils, message, usertypes from qutebrowser.utils import log, utils, qtutils, message, usertypes
@ -352,7 +352,8 @@ class KeyConfigParser(QObject):
line)) line))
commands = [c.split(maxsplit=1)[0].strip() for c in commands] commands = [c.split(maxsplit=1)[0].strip() for c in commands]
for cmd in commands: for cmd in commands:
if cmd not in cmdutils.cmd_dict: aliases = config.section('aliases')
if cmd not in cmdutils.cmd_dict and cmd not in aliases:
raise KeyConfigError("Invalid command '{}'!".format(cmd)) raise KeyConfigError("Invalid command '{}'!".format(cmd))
def _read_command(self, line): def _read_command(self, line):

View File

@ -61,6 +61,18 @@ Feature: Keyboard input
And I run :bind <ctrl-test23> And I run :bind <ctrl-test23>
Then the message "<ctrl-test23> is bound to 'message-info bar' in normal mode" should be shown Then the message "<ctrl-test23> is bound to 'message-info bar' in normal mode" should be shown
Scenario: Binding to an alias
When I run :set aliases 'mib' 'message-info baz'
And I run :bind test25 mib
And I press the keys "test25"
Then the message "baz" should be shown
Scenario: Printing a bound alias
When I run :set aliases 'mib' 'message-info baz'
And I run :bind <test26> mib
And I run :bind <test26>
Then the message "<test26> is bound to 'mib' in normal mode" should be shown
# :unbind # :unbind
Scenario: Binding and unbinding a keychain Scenario: Binding and unbinding a keychain