diff --git a/doc/changelog.asciidoc b/doc/changelog.asciidoc index 48d0d9b9f..d42990d34 100644 --- a/doc/changelog.asciidoc +++ b/doc/changelog.asciidoc @@ -25,6 +25,8 @@ Added opened from a page should stack on each other or not. - New `completion.open_categories` setting which allows to configure which categories are shown in the `:open` completion, and how they are ordered. +- New `:config-add-dict` and `:config-add-list` commands to easily add a new + element to a dict/list setting. Changed ~~~~~~~ diff --git a/doc/help/commands.asciidoc b/doc/help/commands.asciidoc index eab0d6bba..21e9e05ee 100644 --- a/doc/help/commands.asciidoc +++ b/doc/help/commands.asciidoc @@ -36,6 +36,8 @@ It is possible to run or bind multiple commands by separating them with `;;`. |<>|Clear all message notifications. |<>|Click the element matching the given filter. |<>|Close the current window. +|<>|Add a key/value pair to a dictionary option. +|<>|Append a value to a config option that is a list. |<>|Set all settings back to their default. |<>|Cycle an option between multiple values. |<>|Open the config.py file in the editor. @@ -266,6 +268,35 @@ The given filter needs to result in exactly one element, otherwise, an error is === close Close the current window. +[[config-add-dict]] +=== config-add-dict +Syntax: +:config-add-dict [*--temp*] [*--replace*] 'option' 'key' 'value'+ + +Add a key/value pair to a dictionary option. + +==== positional arguments +* +'option'+: The name of the option. +* +'key'+: The key to use. +* +'value'+: The value to place in the dictionary. + +==== optional arguments +* +*-t*+, +*--temp*+: Set value temporarily until qutebrowser is closed. +* +*-r*+, +*--replace*+: Replace existing values. By default, existing values are not overwritten. + + +[[config-add-list]] +=== config-add-list +Syntax: +:config-add-list [*--temp*] 'option' 'value'+ + +Append a value to a config option that is a list. + +==== positional arguments +* +'option'+: The name of the option. +* +'value'+: The value to append to the end of the list. + +==== optional arguments +* +*-t*+, +*--temp*+: Set value temporarily until qutebrowser is closed. + [[config-clear]] === config-clear Syntax: +:config-clear [*--save*]+ @@ -326,7 +357,7 @@ This sets an option back to its default and removes it from autoconfig.yml. * +'option'+: The name of the option. ==== optional arguments -* +*-t*+, +*--temp*+: Don't touch autoconfig.yml. +* +*-t*+, +*--temp*+: Set value temporarily until qutebrowser is closed. [[config-write-py]] === config-write-py diff --git a/qutebrowser/completion/models/configmodel.py b/qutebrowser/completion/models/configmodel.py index 3a225fedf..c70fef7f7 100644 --- a/qutebrowser/completion/models/configmodel.py +++ b/qutebrowser/completion/models/configmodel.py @@ -55,13 +55,13 @@ def dict_option(*, info): def _option(info, title, predicate): - """A CompletionModel that is generified for several option sets. + """A CompletionModel that is generated for several option sets. Args: info: The config info that can be passed through. title: The title of the options. predicate: The function for filtering out the options. Takes a single - argument. + argument. """ model = completionmodel.CompletionModel(column_widths=(20, 70, 10)) options = ((opt.name, opt.description, info.config.get_str(opt.name)) diff --git a/qutebrowser/config/configcommands.py b/qutebrowser/config/configcommands.py index 228cee59d..6c5fa847e 100644 --- a/qutebrowser/config/configcommands.py +++ b/qutebrowser/config/configcommands.py @@ -274,17 +274,15 @@ class ConfigCommands: @cmdutils.register(instance='config-commands') @cmdutils.argument('option', completion=configmodel.dict_option) def config_add_dict(self, option, key, value, temp=False, replace=False): - """Add a value at the key within the option specified. - - This adds an element to a dictionary. --replace is needed to override - existing values. + """Add a key/value pair to a dictionary option. Args: option: The name of the option. key: The key to use. value: The value to place in the dictionary. temp: Set value temporarily until qutebrowser is closed. - replace: Whether or not we should replace, default is not. + replace: Replace existing values. By default, existing values are + not overwritten. """ opt = self._config.get_opt(option) if not isinstance(opt.typ, configtypes.Dict):