From 8e03d75bed51fb135eb1439e979cb912d5801a68 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Wed, 12 Jul 2023 15:50:20 -0700 Subject: [PATCH] Clean up checking prefixes in notmuch configuration --- oni/home/services/notmuch.scm | 57 ++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/oni/home/services/notmuch.scm b/oni/home/services/notmuch.scm index f4a6232..27cc354 100644 --- a/oni/home/services/notmuch.scm +++ b/oni/home/services/notmuch.scm @@ -93,33 +93,36 @@ new\".") (list (home-notmuch-configuration-package config))) (define (home-notmuch-configuration-files config) - `((".notmuch-config" - ,(mixed-text-file - "notmuch-config" - "[database]\n" - (serialize-configuration config - (filter (λ (f) (string-prefix? "database-" (symbol->string (configuration-field-name f)))) - home-notmuch-configuration-fields)) - "\n" - "[user]\n" - (serialize-configuration config - (filter (λ (f) (string-prefix? "user-" (symbol->string (configuration-field-name f)))) - home-notmuch-configuration-fields)) - "\n" - "[new]\n" - (serialize-configuration config - (filter (λ (f) (string-prefix? "new-" (symbol->string (configuration-field-name f)))) - home-notmuch-configuration-fields)) - "\n" - "[search]\n" - (serialize-configuration config - (filter (λ (f) (string-prefix? "search-" (symbol->string (configuration-field-name f)))) - home-notmuch-configuration-fields)) - "\n" - "[maildir]\n" - (serialize-configuration config - (filter (λ (f) (string-prefix? "maildir-" (symbol->string (configuration-field-name f)))) - home-notmuch-configuration-fields)))))) + (let ((make-prefix-checker + (λ (p) + (λ (f) (string-prefix? p (symbol->string (configuration-field-name f))))))) + `((".notmuch-config" + ,(mixed-text-file + "notmuch-config" + "[database]\n" + (serialize-configuration config + (filter (make-prefix-checker "database-") + home-notmuch-configuration-fields)) + "\n" + "[user]\n" + (serialize-configuration config + (filter (make-prefix-checker "user-") + home-notmuch-configuration-fields)) + "\n" + "[new]\n" + (serialize-configuration config + (filter (make-prefix-checker "new-") + home-notmuch-configuration-fields)) + "\n" + "[search]\n" + (serialize-configuration config + (filter (make-prefix-checker "search-") + home-notmuch-configuration-fields)) + "\n" + "[maildir]\n" + (serialize-configuration config + (filter (make-prefix-checker "maildir-") + home-notmuch-configuration-fields))))))) (define home-notmuch-service-type (service-type