#| -*-Scheme-*-
-$Id: imail-top.scm,v 1.299 2007/03/11 22:30:05 riastradh Exp $
+$Id: imail-top.scm,v 1.300 2007/04/05 01:56:09 riastradh Exp $
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
(message (selected-message)))
(let ((info (car i.m))
(mark (cdr i.m)))
- (set-mime-info-expanded?! info (not (mime-info-expanded? info)))
+ (set-mime-info-expanded?!
+ info mark message
+ (not (mime-info-expanded? info mark message)))
(re-render-mime-entity info mark message)))))
(define-command imail-toggle-wrap-entity
\f
(define (insert-mime-message-inline message body selector context mark)
(maybe-insert-mime-boundary context mark)
- (insert-mime-info (make-mime-info #t #t body selector context)
+ (insert-mime-info (make-mime-info #t body selector context)
message
mark))
(if (not (walk-mime-context-inline-only? context))
(begin
(maybe-insert-mime-boundary context mark)
- (insert-mime-info (make-mime-info #f #f body selector context)
+ (insert-mime-info (make-mime-info #f body selector context)
message
mark))))
(let ((start (mark-right-inserting-copy mark))
(body (mime-info-body info))
(context (mime-info-context info)))
- (if (mime-info-expanded? info)
+ (if (mime-info-expanded? info mark message)
(insert-mime-message-inline* message
body
(mime-info-selector info)
(define-structure mime-info
(inline? #f)
- (expanded? #f)
(body #f read-only #t)
(selector #f read-only #t)
(context #f read-only #t))
+
+(define (mime-info-expanded? info mark message)
+ (let ((expansions (buffer-get (->buffer mark) 'IMAIL-MIME-EXPANSIONS #f))
+ (key (cons message (mime-info-selector info)))
+ (inline? (mime-info-inline? info)))
+ (if expansions
+ (hash-table/get expansions key inline?)
+ inline?)))
+
+(define (set-mime-info-expanded?! info mark message expanded?)
+ (let ((buffer (->buffer mark))
+ (key (cons message (mime-info-selector info))))
+ (if (if (mime-info-inline? info) expanded? (not expanded?))
+ (cond ((buffer-get buffer 'IMAIL-MIME-EXPANSIONS #f)
+ => (lambda (expansions)
+ (hash-table/remove! expansions key)
+ (if (zero? (hash-table/count expansions))
+ (buffer-put! buffer 'IMAIL-MIME-EXPANSIONS #f)))))
+ (hash-table/put!
+ (or (buffer-get buffer 'IMAIL-MIME-EXPANSIONS #f)
+ (let ((expansions (make-equal-hash-table)))
+ (buffer-put! buffer 'IMAIL-MIME-EXPANSIONS expansions)
+ expansions))
+ key
+ expanded?))))
\f
;;;; Automatic wrap/fill