Clean up checking prefixes in notmuch configuration

This commit is contained in:
Tom Willemse 2023-07-12 15:50:20 -07:00
parent 6445a90dfd
commit 8e03d75bed

View file

@ -93,33 +93,36 @@ new\".")
(list (home-notmuch-configuration-package config))) (list (home-notmuch-configuration-package config)))
(define (home-notmuch-configuration-files config) (define (home-notmuch-configuration-files config)
`((".notmuch-config" (let ((make-prefix-checker
,(mixed-text-file (λ (p)
"notmuch-config" (λ (f) (string-prefix? p (symbol->string (configuration-field-name f)))))))
"[database]\n" `((".notmuch-config"
(serialize-configuration config ,(mixed-text-file
(filter (λ (f) (string-prefix? "database-" (symbol->string (configuration-field-name f)))) "notmuch-config"
home-notmuch-configuration-fields)) "[database]\n"
"\n" (serialize-configuration config
"[user]\n" (filter (make-prefix-checker "database-")
(serialize-configuration config home-notmuch-configuration-fields))
(filter (λ (f) (string-prefix? "user-" (symbol->string (configuration-field-name f)))) "\n"
home-notmuch-configuration-fields)) "[user]\n"
"\n" (serialize-configuration config
"[new]\n" (filter (make-prefix-checker "user-")
(serialize-configuration config home-notmuch-configuration-fields))
(filter (λ (f) (string-prefix? "new-" (symbol->string (configuration-field-name f)))) "\n"
home-notmuch-configuration-fields)) "[new]\n"
"\n" (serialize-configuration config
"[search]\n" (filter (make-prefix-checker "new-")
(serialize-configuration config home-notmuch-configuration-fields))
(filter (λ (f) (string-prefix? "search-" (symbol->string (configuration-field-name f)))) "\n"
home-notmuch-configuration-fields)) "[search]\n"
"\n" (serialize-configuration config
"[maildir]\n" (filter (make-prefix-checker "search-")
(serialize-configuration config home-notmuch-configuration-fields))
(filter (λ (f) (string-prefix? "maildir-" (symbol->string (configuration-field-name f)))) "\n"
home-notmuch-configuration-fields)))))) "[maildir]\n"
(serialize-configuration config
(filter (make-prefix-checker "maildir-")
home-notmuch-configuration-fields)))))))
(define home-notmuch-service-type (define home-notmuch-service-type
(service-type (service-type