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)))
(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