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)
(let ((make-prefix-checker
(λ (p)
(λ (f) (string-prefix? p (symbol->string (configuration-field-name f)))))))
`((".notmuch-config" `((".notmuch-config"
,(mixed-text-file ,(mixed-text-file
"notmuch-config" "notmuch-config"
"[database]\n" "[database]\n"
(serialize-configuration config (serialize-configuration config
(filter (λ (f) (string-prefix? "database-" (symbol->string (configuration-field-name f)))) (filter (make-prefix-checker "database-")
home-notmuch-configuration-fields)) home-notmuch-configuration-fields))
"\n" "\n"
"[user]\n" "[user]\n"
(serialize-configuration config (serialize-configuration config
(filter (λ (f) (string-prefix? "user-" (symbol->string (configuration-field-name f)))) (filter (make-prefix-checker "user-")
home-notmuch-configuration-fields)) home-notmuch-configuration-fields))
"\n" "\n"
"[new]\n" "[new]\n"
(serialize-configuration config (serialize-configuration config
(filter (λ (f) (string-prefix? "new-" (symbol->string (configuration-field-name f)))) (filter (make-prefix-checker "new-")
home-notmuch-configuration-fields)) home-notmuch-configuration-fields))
"\n" "\n"
"[search]\n" "[search]\n"
(serialize-configuration config (serialize-configuration config
(filter (λ (f) (string-prefix? "search-" (symbol->string (configuration-field-name f)))) (filter (make-prefix-checker "search-")
home-notmuch-configuration-fields)) home-notmuch-configuration-fields))
"\n" "\n"
"[maildir]\n" "[maildir]\n"
(serialize-configuration config (serialize-configuration config
(filter (λ (f) (string-prefix? "maildir-" (symbol->string (configuration-field-name f)))) (filter (make-prefix-checker "maildir-")
home-notmuch-configuration-fields)))))) home-notmuch-configuration-fields)))))))
(define home-notmuch-service-type (define home-notmuch-service-type
(service-type (service-type