diff --git a/scm/mu-scm-test.scm b/scm/mu-scm-test.scm index 5ca1e64d..e7701987 100644 --- a/scm/mu-scm-test.scm +++ b/scm/mu-scm-test.scm @@ -70,13 +70,26 @@ (test-end "test-message-full"))) -(define (test-misc) +(define (test-message-more) + (test-begin "test-message-more") + (let ((msg (car (mfind "to:dfgh@floppydisk.nl")))) + (test-equal "Re: xyz" (subject msg)) + (test-equal "Mozilla Thunderbird 1.0.7 (X11/20051010)" (header msg "User-Agent")) + (test-equal '("439C1136.90504@euler.org" "4399DD94.5070309@euler.org" + "20051209233303.GA13812@gauss.org" "439B41ED.2080402@euler.org" + "439A1E03.3090604@euler.org" "20051211184308.GB13513@gauss.org") + (references msg))) + (test-end "test-message-more")) + +(define (test-options) + (test-begin "test-options") (let ((opts (options))) (test-assert (>= (length opts) 4)) (test-equal (assoc-ref opts 'quiet) #f) (test-equal (assoc-ref opts 'debug) #f) (test-equal (assoc-ref opts 'verbose) #f) - (test-equal (assoc-ref opts 'muhome) #f))) + (test-equal (assoc-ref opts 'muhome) #f)) + (test-end "test-options")) (define (test-helpers) (test-begin "test-helpers") @@ -96,7 +109,8 @@ (test-basic-mfind) (test-mfind) (test-message-full) - (test-misc) + (test-message-more) + (test-options) (test-helpers) (test-end "mu-scm-tests") diff --git a/scm/mu-scm.scm b/scm/mu-scm.scm index b16dfd02..5e6f7fa7 100644 --- a/scm/mu-scm.scm +++ b/scm/mu-scm.scm @@ -41,6 +41,8 @@ priority subject + references + language size @@ -201,7 +203,7 @@ A symbol, either 'high, 'low or 'normal, or #f if not found." (find-field message ':priority)) (define-method (language (message )) - "Get the ISO-639-1 language code for the message as a symbol, if detected. + "Get the ISO-639-1 language code for the MESSAGE as a symbol, if detected. Return #f otherwise." (let ((lang (find-field message ':language))) (if lang @@ -210,13 +212,21 @@ Return #f otherwise." ;; if-let would be nice! (define-method (size (message )) - "Get the size of the message in bytes or #f if not available." + "Get the size of the MESSAGE in bytes or #f if not available." (find-field message ':size)) +(define-method (references (message )) + "Get the list of reference of MESSAGE or #f if not available. + with the oldest first and the direct parent as the last one. Note, any +reference (message-id) will appear at most once, duplicates and +fake-message-id (see impls) are filtered out. If there are no references, return +#f." + (find-field message ':references)) + ;; Flags. (define-method (flags (message )) - "Get the size of the message in bytes or #f if not available." + "Get the size of the MESSAGE in bytes or #f if not available." (find-field message ':flags)) (define-method (flag? (message ) flag) diff --git a/scm/mu-scm.texi b/scm/mu-scm.texi index 509bedda..1ee1d68e 100644 --- a/scm/mu-scm.texi +++ b/scm/mu-scm.texi @@ -624,6 +624,19 @@ For example: => #f @end lisp +@deffn {Scheme Procedure} references message +@end deffn +Get the list of references (message-ids of related messages) for this message. +This combines the @t{References} and @t{In-Reply-To} fields, from oldest to the +immediate parent. Returns @code{#f} if there are no references. + +@lisp +(references msg) +=> ("439C1136.90504@@euler.org" "4399DD94.5070309@@euler.org" + "20051209233303.GA13812@@gauss.org" "439B41ED.2080402@@euler.org" + 439A1E03.3090604@@euler.org" "20051211184308.GB13513@@gauss.org") +@end lisp + @c @deffn {Scheme Procedure} sexp message @c @end deffn @c Get the message's s-expression.