From 81dae2f88eaff306f36b9072d2cb752f82dbc60a Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Tue, 5 Feb 2019 15:03:04 +0900 Subject: [PATCH] alot: support contact completion Make choice of contact completion easier. --- modules/accounts/email.nix | 4 ++-- modules/programs/alot-accounts.nix | 29 +++++++++++++++++++++++++++++ modules/programs/alot.nix | 2 ++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/modules/accounts/email.nix b/modules/accounts/email.nix index 857622c0..ea9955d1 100644 --- a/modules/accounts/email.nix +++ b/modules/accounts/email.nix @@ -1,4 +1,4 @@ -{ config, lib, ... }: +{ config, lib, pkgs, ... }: with lib; @@ -379,7 +379,7 @@ in accounts = mkOption { type = types.attrsOf (types.submodule [ mailAccountOpts - (import ../programs/alot-accounts.nix) + (import ../programs/alot-accounts.nix pkgs) (import ../programs/astroid-accounts.nix) (import ../programs/mbsync-accounts.nix) (import ../programs/msmtp-accounts.nix) diff --git a/modules/programs/alot-accounts.nix b/modules/programs/alot-accounts.nix index ad7be0d8..2def5fd1 100644 --- a/modules/programs/alot-accounts.nix +++ b/modules/programs/alot-accounts.nix @@ -1,3 +1,4 @@ +pkgs: { config, lib, ... }: with lib; @@ -13,6 +14,34 @@ with lib; ''; }; + contactCompletion = mkOption { + type = types.attrsOf types.str; + default = { + type = "shellcommand"; + command = "'${pkgs.notmuch}/bin/notmuch address --format=json --output=recipients date:6M..'"; + regexp = + "'\[?{" + + ''"name": "(?P.*)", '' + + ''"address": "(?P.+)", '' + + ''"name-addr": ".*"'' + + "}[,\]]?'"; + shellcommand_external_filtering = "False"; + }; + example = literalExample '' + { + type = "shellcommand"; + command = "abook --mutt-query"; + regexp = "'^(?P[^@]+@[^\t]+)\t+(?P[^\t]+)'"; + ignorecase = "True"; + } + ''; + description = '' + Contact completion configuration as expected per alot. + See alot's wiki for + explanation about possible values. + ''; + }; + extraConfig = mkOption { type = types.lines; default = ""; diff --git a/modules/programs/alot.nix b/modules/programs/alot.nix index ea5a5d11..39c701e5 100644 --- a/modules/programs/alot.nix +++ b/modules/programs/alot.nix @@ -33,6 +33,8 @@ let boolStr (signature.showSignature == "attach"); } ) + ++ [ "[[[abook]]]" ] + ++ mapAttrsToList (n: v: n + "=" + v) alot.contactCompletion ) + "\n" + alot.extraConfig;