mirror of
https://github.com/nix-community/home-manager.git
synced 2025-12-25 02:10:57 +01:00
neomutt: support list in binds.map (#1885)
* neomutt: support list in binds.map Closes #1245 Adds support for specifying programs.neomutt.binds[].map as a list. If specified as a list, then the binds will be concatenated with a ",". * neomutt: add deprecation warning for (binds|macros).map as string Added note that specifying 'programs.neomutt.(binds|macros).map' as a string is deprecated. Instead, use the list form. * neomutt: note deprecation warning in release notes Added note that specifying 'programs.neomutt.(binds|macros).map' as a single string is deprecated in favor of specifying it as a list * neomutt: add assertion that map is not empty Added an assertion that each 'programs.neomutt.(binds|macros).map' list contains at least one element.
This commit is contained in:
parent
6e3d93d7cc
commit
25a6a6d298
7 changed files with 247 additions and 19 deletions
|
|
@ -54,21 +54,23 @@ let
|
|||
bindModule = types.submodule {
|
||||
options = {
|
||||
map = mkOption {
|
||||
type = types.enum [
|
||||
"alias"
|
||||
"attach"
|
||||
"browser"
|
||||
"compose"
|
||||
"editor"
|
||||
"generic"
|
||||
"index"
|
||||
"mix"
|
||||
"pager"
|
||||
"pgp"
|
||||
"postpone"
|
||||
"query"
|
||||
"smime"
|
||||
];
|
||||
type = let
|
||||
menus = [
|
||||
"alias"
|
||||
"attach"
|
||||
"browser"
|
||||
"compose"
|
||||
"editor"
|
||||
"generic"
|
||||
"index"
|
||||
"mix"
|
||||
"pager"
|
||||
"pgp"
|
||||
"postpone"
|
||||
"query"
|
||||
"smime"
|
||||
];
|
||||
in with types; either (enum menus) (listOf (enum menus));
|
||||
default = "index";
|
||||
description = "Select the menu to bind the command to.";
|
||||
};
|
||||
|
|
@ -154,11 +156,16 @@ let
|
|||
set sidebar_format = '${cfg.sidebar.format}'
|
||||
'';
|
||||
|
||||
bindSection = concatMapStringsSep "\n"
|
||||
(bind: ''bind ${bind.map} ${bind.key} "${bind.action}"'') cfg.binds;
|
||||
genBindMapper = bindType:
|
||||
concatMapStringsSep "\n" (bind:
|
||||
''
|
||||
${bindType} ${
|
||||
concatStringsSep "," (toList bind.map)
|
||||
} ${bind.key} "${bind.action}"'');
|
||||
|
||||
macroSection = concatMapStringsSep "\n"
|
||||
(bind: ''macro ${bind.map} ${bind.key} "${bind.action}"'') cfg.macros;
|
||||
bindSection = (genBindMapper "bind") cfg.binds;
|
||||
|
||||
macroSection = (genBindMapper "macro") cfg.macros;
|
||||
|
||||
mailCheckSection = ''
|
||||
set mail_check_stats
|
||||
|
|
@ -316,5 +323,19 @@ in {
|
|||
source ${accountFilename primary}
|
||||
'';
|
||||
};
|
||||
|
||||
assertions = [{
|
||||
assertion =
|
||||
((filter (b: (length (toList b.map)) == 0) (cfg.binds ++ cfg.macros))
|
||||
== [ ]);
|
||||
message =
|
||||
"The 'programs.neomutt.(binds|macros).map' list must contain at least one element.";
|
||||
}];
|
||||
|
||||
warnings =
|
||||
let hasOldBinds = binds: (filter (b: !(isList b.map)) binds) != [ ];
|
||||
in mkIf (hasOldBinds (cfg.binds ++ cfg.macros)) [
|
||||
"Specifying 'programs.neomutt.(binds|macros).map' as a string is deprecated, use a list of strings instead. See https://github.com/nix-community/home-manager/pull/1885."
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue