#| -*-Scheme-*-
-$Id: edwin.pkg,v 1.308 2008/07/19 00:56:19 cph Exp $
+$Id: edwin.pkg,v 1.309 2008/08/11 22:48:50 riastradh Exp $
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
(export (edwin)
rfc822:addresses->string
rfc822:canonicalize-address-string
+ rfc822:canonicalize-named-address-string
rfc822:first-address
rfc822:header-field-name?
rfc822:parse-addr-spec
rfc822:parse-msg-id
rfc822:parse-word
rfc822:quote-string
- rfc822:unquote-string
+ rfc822:unquote-string
rfc822:received-header-components
rfc822:string->addresses
+ rfc822:string->named-addresses
rfc822:string->tokens
- rfc822:string-tokenizer
+ rfc822:string-tokenizer
rfc822:strip-comments
rfc822:strip-quoted-names
rfc822:tokens->string))
#| -*-Scheme-*-
-$Id: rfc822.scm,v 3.10 2008/01/30 20:02:05 cph Exp $
+$Id: rfc822.scm,v 3.11 2008/08/11 22:48:50 riastradh Exp $
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
(decorated-string-append "" ", " "" addresses))
(define (rfc822:string->addresses string)
- (let ((address-list
- (rfc822:strip-quoted-names
- (rfc822:string->non-ignored-tokens string))))
- (if (and address-list (null? (cdr address-list)))
- (car address-list)
- (map (lambda (string)
- (let ((string (string-trim string)))
- (let ((end (string-length string)))
- (let loop ((start 0))
- (let ((index
- (substring-find-next-char-in-set
- string start end char-set:whitespace)))
- (if index
- (begin
- (string-set! string index #\space)
- (loop (fix:+ index 1)))))))
- string))
- (burst-string string #\, #f)))))
+ (let ((tokens (rfc822:string->non-ignored-tokens string)))
+ (let ((address-list (rfc822:strip-quoted-names tokens)))
+ (if (and address-list (null? (cdr address-list)))
+ (car address-list)
+ (rfc822:split-address-tokens tokens)))))
+
+(define (rfc822:string->named-addresses string)
+ (rfc822:split-address-tokens (rfc822:string->tokens string)))
+
+(define (rfc822:split-address-tokens tokens)
+ (let recur ((tokens tokens))
+ (receive (tokens tokens*)
+ (span (lambda (token) (not (eqv? token #\,))) tokens)
+ (cons (rfc822:tokens->string tokens)
+ (if (pair? tokens*) (recur (cdr tokens*)) '())))))
(define (rfc822:canonicalize-address-string string)
(rfc822:addresses->string (rfc822:string->addresses string)))
+
+(define (rfc822:canonicalize-named-address-string string)
+ (rfc822:addresses->string (rfc822:string->named-addresses string)))
\f
;;;; Parsers
#| -*-Scheme-*-
-$Id: sendmail.scm,v 1.97 2008/06/20 06:10:13 riastradh Exp $
+$Id: sendmail.scm,v 1.98 2008/08/11 22:48:50 riastradh Exp $
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
(ref-mode-object mail)))
(local-set-variable! mail-reply-buffer reply-buffer buffer)
(let ((headers (add-standard-headers headers buffer))
- (point (mark-left-inserting-copy (buffer-start buffer)))
- (fill
- (lambda (start end)
- (fill-region-as-paragraph start end
- "\t" (ref-variable fill-column buffer)
- #f))))
+ (point (mark-left-inserting-copy (buffer-start buffer))))
(let ((start (mark-right-inserting-copy point)))
(for-each
(lambda (header)
(or (string-ci=? key "to")
(string-ci=? key "cc"))
(caddr header)))
- (fill start point))
+ (fill-mail-addresses start point))
(insert-newline point)))))
headers)
(mark-temporary! start))
(buffer-not-modified! buffer))))
(event-distributor/invoke! (ref-variable mail-setup-hook buffer) buffer))
\f
+(define (fill-mail-addresses start end)
+ ;; This totally loses on quoted or commented names, which it
+ ;; probably shouldn't split up.
+ (let ((column (ref-variable fill-column start))
+ (mark (char-search-forward #\, start end)))
+ (if mark
+ (let loop ((start start) (mark mark))
+ (let ((mark* (char-search-forward #\, mark end)))
+ (if mark*
+ (if (< (mark-column mark*) column)
+ (loop start mark*)
+ (let ((mark
+ (mark-permanent-copy
+ ;; Skip addresses that are too long.
+ (if (mark= mark start) mark* mark))))
+ (delete-horizontal-space mark)
+ (insert-newline mark)
+ (insert-char #\tab mark)
+ (mark-temporary! mark)
+ (loop mark mark)))))))))
+
(define (add-standard-headers headers buffer)
(let ((add
(lambda (key value)
#| -*-Scheme-*-
-$Id: imail-top.scm,v 1.308 2008/08/11 17:53:51 riastradh Exp $
+$Id: imail-top.scm,v 1.309 2008/08/11 22:48:50 riastradh Exp $
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
(and (pair? strings)
(decorated-string-append "" ", " "" strings)))))
`(("To"
- ,(rfc822:canonicalize-address-string
+ ,(rfc822:canonicalize-named-address-string
(or resent-reply-to
(concat (get-all-header-field-values message "reply-to"))
from)))
(and cc
(let ((addresses
(imail-dont-reply-to
- (rfc822:string->addresses cc))))
+ (rfc822:string->named-addresses cc))))
(and (pair? addresses)
(rfc822:addresses->string addresses))))))))
("In-reply-to"
#t)))
(let loop ((addresses addresses))
(if (pair? addresses)
- (if (re-string-match pattern (car addresses))
+ (if (re-string-match pattern
+ (rfc822:canonicalize-address-string
+ (car addresses)))
(loop (cdr addresses))
(cons (car addresses) (loop (cdr addresses))))
'()))))