mu-scm: add support for thread-id

Code + doc + test
This commit is contained in:
Dirk-Jan C. Binnema
2025-06-28 12:21:19 +03:00
parent cc39c9cae6
commit f2699a4b95
3 changed files with 38 additions and 6 deletions

View File

@ -78,13 +78,16 @@
(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)))
(references msg))
(test-equal "439C1136.90504@euler.org" (thread-id msg)))
(let ((msg (car (mfind "subject:\"gcc include search order\""))))
(test-equal "gcc include search order" (subject msg))
(test-equal "klub" (header msg "precedence"))
(test-equal "gcc-help.gcc.gnu.org" (mailing-list msg))
(test-equal #f (references msg)))
(test-equal #f (references msg))
(test-equal "3BE9E6535E3029448670913581E7A1A20D852173@emss35m06.us.lmco.com" (message-id msg))
(test-equal "3BE9E6535E3029448670913581E7A1A20D852173@emss35m06.us.lmco.com" (thread-id msg)))
(test-end "test-message-more"))
(define (test-options)

View File

@ -41,6 +41,8 @@
subject
references
thread-id
mailing-list
language
@ -223,6 +225,15 @@ fake-message-id (see impls) are filtered out. If there are no references, return
#f."
(find-field message ':references))
(define-method (thread-id (message <message>))
"Get the oldest (first) reference for MESSAGE, or message-id if there are none.
If neither are available, return #f.
This is method is useful to determine the thread a message is in."
(let ((refs (references message)))
(if (and refs (not (null? refs)))
(car refs)
(message-id message))))
(define-method (mailing-list (message <message>))
"Get the mailing-list id for MESSAGE or #f if not available."
(find-field message ':list))

View File

@ -638,6 +638,24 @@ For example:
439A1E03.3090604@@euler.org" "20051211184308.GB13513@@gauss.org")
@end lisp
@deffn {Scheme Procedure} thread-id message
@end deffn
Get the oldest reference for the message or its message-id if there is none.
This is useful to identify the thread some message lives in.
For example:
@lisp
(thread-id msg)
=> "439C1136.90504@@euler.org"
@end lisp
For example:
@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
@deffn {Scheme Procedure} mailing-list message
@end deffn