From 096d9c04b3e9438855aa65e24129b97a998bd3d9 Mon Sep 17 00:00:00 2001 From: Kylie McClain Date: Thu, 18 Jan 2024 12:13:01 -0500 Subject: [PATCH] qutebrowser: actually implement unbinding The documentation for the option says... > If you want a default binding to be passed through to the website, > bind it to null. but if you actually try to set a key to `null`, it causes an error. > A definition for option > `programs.qutebrowser.keyBindings."".normal' is not > of type `strings concatenated with " ;; "'. So this commit implements unbinding as it is documented. --- modules/programs/qutebrowser.nix | 9 ++++++--- tests/modules/programs/qutebrowser/keybindings.nix | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/programs/qutebrowser.nix b/modules/programs/qutebrowser.nix index b6cc41ead..9c3ad6a86 100644 --- a/modules/programs/qutebrowser.nix +++ b/modules/programs/qutebrowser.nix @@ -9,7 +9,7 @@ let formatLine = o: n: v: let formatValue = v: - if builtins.isNull v then + if v == null then "None" else if builtins.isBool v then (if v then "True" else "False") @@ -29,7 +29,10 @@ let formatKeyBindings = m: b: let formatKeyBinding = m: k: c: - ''config.bind("${k}", "${escape [ ''"'' ] c}", mode="${m}")''; + if c == null then + ''config.unbind("${k}", mode="${m}")'' + else + ''config.bind("${k}", "${escape [ ''"'' ] c}", mode="${m}")''; in concatStringsSep "\n" (mapAttrsToList (formatKeyBinding m) b); formatQuickmarks = n: s: "${n} ${s}"; @@ -131,7 +134,7 @@ in { }; keyBindings = mkOption { - type = with types; attrsOf (attrsOf (separatedString " ;; ")); + type = with types; attrsOf (attrsOf (nullOr (separatedString " ;; "))); default = { }; description = '' Key bindings mapping keys to commands in different modes. This setting diff --git a/tests/modules/programs/qutebrowser/keybindings.nix b/tests/modules/programs/qutebrowser/keybindings.nix index 00e730efa..37ccfeba3 100644 --- a/tests/modules/programs/qutebrowser/keybindings.nix +++ b/tests/modules/programs/qutebrowser/keybindings.nix @@ -8,6 +8,7 @@ keyBindings = { normal = { + ":" = null; "" = "spawn mpv {url}"; ",l" = ''config-cycle spellcheck.languages ["en-GB"] ["en-US"]''; "" = lib.mkMerge [ @@ -35,6 +36,7 @@ config.load_autoconfig(False) c.bindings.default = {} config.bind(",l", "config-cycle spellcheck.languages [\"en-GB\"] [\"en-US\"]", mode="normal") + config.unbind(":", mode="normal") config.bind("", "spawn mpv {url}", mode="normal") config.bind("", "config-cycle tabs.show never always ;; config-cycle statusbar.show in-mode always ;; config-cycle scrolling.bar never always", mode="normal") config.bind("", "prompt-yes", mode="prompt")''