scm: add convenience methods root-maildir, personal-addresses

For a store, so to avoid assoc-ref.
This commit is contained in:
Dirk-Jan C. Binnema
2025-11-29 12:43:38 +02:00
committed by Seth Ladygo
parent 52f44653b0
commit 8afef75b30
4 changed files with 30 additions and 5 deletions

View File

@ -13,6 +13,9 @@
(test-assert (personal? "user@example.com"))
(test-assert (not (personal? "user@anotherexample.com")))
(test-equal (root-maildir) (string-append (getenv "MU_TESTDATADIR") "/testdir"))
(test-equal (personal-addresses) '("user@example.com"))
(let ((info (store->alist)))
(test-equal 50000 (assoc-ref info 'batch-size))
(test-equal 100000000 (assoc-ref info 'max-message-size)))

View File

@ -93,8 +93,9 @@
cfind
labels
personal?
root-maildir
personal-addresses
store->alist
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Other
@ -563,8 +564,24 @@ The pattern is mandatory; the other (keyword) arguments are optional.
#:max-results max. number of matches. Default: false (unlimited))."
(cc-store-cfind (cc-store store) pattern personal? after max-results))
(define-method (root-maildir (store <store>))
;; "Get the root-maildir for the messages in STORE."
(assoc-ref (store->alist store) 'root-maildir))
(define-method (root-maildir)
"Get the root-maildir for the messages in the default-store."
(root-maildir %default-store))
(define-method (personal-addresses (store <store>))
;; "Get the list of personal addresses in STORE."
(or (assoc-ref (store->alist store) 'personal-addresses) '()))
(define-method (personal-addresses)
"Get the list of personal addresses in the default-store."
(personal-addresses %default-store))
(define-method (mcount (store <store>))
;; "Get the number of messages in STORE."
;; "Get the number of messages in STORE."
(cc-store-mcount (cc-store store)))
(define-method (mcount)

View File

@ -393,7 +393,8 @@ implicit.
The store currently only exposes a few methods, described below.
@deffn {Scheme Procedure} mfind query [#:related? #f] [#:skip-dups? #f] [#:sort-field 'date]
@deffn {Scheme Procedure} mfind query [#:related? #f] [#:skip-dups? #f]
[#:sort-field 'date]
[#:reverse? #f] [#:max-results #f]
@end deffn
@ -491,8 +492,9 @@ This is equivalent to @code{(assoc-ref (store->alist) 'root-maildir)}.
Get the list of personal-addresses as defined in the @code{mu} database, which
may be empty.
This is equivalent to @code{(assoc-ref (store->alist) 'personal-addresses)}. Any
element in this list is either a plain e-mail address, or a PCRE-compatible
This is equivalent to @code{(or (assoc-ref (store->alist) 'personal-addresses) '())},
Any element in this list is either a plain e-mail address, or a PCRE-compatible
regular expression when the first and last characters are @t{/} (forward-slash);
see @t{pcre(3)} for further details.