summaryrefslogtreecommitdiff
path: root/scm
diff options
context:
space:
mode:
authorDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2025-06-28 11:17:34 +0300
committerDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2025-06-30 21:57:29 +0300
commitf66172db3b424b221ece6c4436980d25ca3d397d (patch)
tree9d0f0714f9d3f064e213fbd6900a46a305c79528 /scm
parent123c0c1bc8d537382b17c77af5b2909edf2e485f (diff)
mu-scm: add support for references
Message method + test + docs.
Diffstat (limited to 'scm')
-rw-r--r--scm/mu-scm-test.scm20
-rw-r--r--scm/mu-scm.scm16
-rw-r--r--scm/mu-scm.texi13
3 files changed, 43 insertions, 6 deletions
diff --git a/scm/mu-scm-test.scm b/scm/mu-scm-test.scm
index 5ca1e64..e770198 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 b16dfd0..5e6f7fa 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 <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 <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 <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 <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 <message>) flag)
diff --git a/scm/mu-scm.texi b/scm/mu-scm.texi
index 509bedd..1ee1d68 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.