From 5248903dc3a46dcc114ce7df54fb10016a02f1da Mon Sep 17 00:00:00 2001 From: "Taylor R. Campbell" Date: Thu, 5 Apr 2007 01:56:09 +0000 Subject: [PATCH] Remember when MIME entities are collapsed or expanded, in a hash table per IMAIL folder buffer. (This information will still be forgotten when the buffer is killed and the folder reopened, but that probably doesn't matter.) --- v7/src/imail/imail-top.scm | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/v7/src/imail/imail-top.scm b/v7/src/imail/imail-top.scm index 5725d8a31..c6509130d 100644 --- a/v7/src/imail/imail-top.scm +++ b/v7/src/imail/imail-top.scm @@ -1,6 +1,6 @@ #| -*-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, @@ -960,7 +960,9 @@ With prefix argument, prompt even when point is on an attachment." (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 @@ -2537,7 +2539,7 @@ Negative argument means search in reverse." (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)) @@ -2545,7 +2547,7 @@ Negative argument means search in reverse." (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)))) @@ -2553,7 +2555,7 @@ Negative argument means search in reverse." (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) @@ -2709,10 +2711,34 @@ Negative argument means search in reverse." (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?)))) ;;;; Automatic wrap/fill -- 2.25.1