#| -*-Scheme-*-
-$Id: imail-summary.scm,v 1.57 2008/02/11 22:49:10 riastradh Exp $
+$Id: imail-summary.scm,v 1.58 2008/08/27 14:55:48 riastradh Exp $
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
(define-command imail-summary
"Display a summary of the selected folder, one line per message."
()
- (lambda () (imail-summary "All" #f)))
+ (lambda ()
+ (imail-summary-by-predicate "All" (lambda (m) m #t))))
(define-command imail-summary-by-flags
"Display a summary of all messages with one or more FLAGS.
(lambda ()
(list (imail-prompt-for-flags "Flags to summarize by")))
(lambda (flags-string)
- (imail-summary (string-append "Flags " flags-string)
- (let ((flags (burst-comma-list-string flags-string)))
- (lambda (m)
- (there-exists? (message-flags m)
- (lambda (flag)
- (flags-member? flag flags))))))))
+ (imail-summary-by-predicate
+ (string-append "Flags " flags-string)
+ (let ((flags (burst-comma-list-string flags-string)))
+ (lambda (m)
+ (there-exists? (message-flags m)
+ (lambda (flag)
+ (flags-member? flag flags))))))))
(define-command imail-summary-by-recipients
"Display a summary of all messages with the given RECIPIENTS.
RECIPIENTS is a string of regexps separated by commas."
"sRecipients to summarize by\nP"
(lambda (recipients-string primary-only?)
- (imail-summary
+ (imail-summary-by-predicate
(string-append "Recipients " recipients-string)
(let ((regexp
(apply regexp-group (burst-comma-list-string recipients-string))))
(try (get-first-header-field-value m "to" #f))
(and (not primary-only?)
(try (get-first-header-field-value m "cc" #f))))))))))
-
+\f
(define-command imail-summary-by-regexp
"Display a summary of all messages according to regexp REGEXP.
If the regular expression is found in the header of the message
Edwin will list the header line in the summary."
"sRegexp to summarize by"
(lambda (regexp)
- (imail-summary
+ (imail-summary-by-predicate
(string-append "Regular expression " regexp)
(let ((case-fold? (ref-variable case-fold-search)))
(lambda (m)
SUBJECT is a string of regexps separated by commas."
"sTopics to summarize by"
(lambda (regexps-string)
- (imail-summary
+ (imail-summary-by-predicate
(string-append "About " regexps-string)
(let ((regexp
(apply regexp-group (burst-comma-list-string regexps-string)))
(let ((s (get-first-header-field-value m "subject" #f)))
(and s
(re-string-search-forward regexp s case-fold?))))))))
+
+(define-command imail-search-summary
+ "Display a summary of the search results for a string of text."
+ "sSearch string"
+ (lambda (pattern)
+ (imail-summary (string-append "Search: " pattern)
+ (lambda (folder)
+ ((imail-ui:message-wrapper "Searching for " pattern)
+ (lambda ()
+ (map (lambda (index)
+ (get-message folder index))
+ (search-folder folder pattern))))))))
\f
-(define (imail-summary description predicate)
+(define (imail-summary description procedure)
(let* ((folder (selected-folder))
(folder-buffer (imail-folder->buffer folder #t))
(buffer
(list buffer folder-buffer)))))
buffer)))))
(buffer-put! buffer 'IMAIL-SUMMARY-DESCRIPTION description)
- (buffer-put! buffer 'IMAIL-SUMMARY-PREDICATE predicate)
+ (buffer-put! buffer 'IMAIL-SUMMARY-PROCEDURE procedure)
(if (not (selected-buffer? buffer))
(let ((windows (buffer-windows buffer)))
(if (pair? windows)
(preload-folder-outlines folder)
(rebuild-imail-summary-buffer buffer)))
+(define (imail-summary-by-predicate description predicate)
+ (imail-summary
+ description
+ (lambda (folder)
+ (let ((end (folder-length folder)))
+ (let loop ((i 0) (messages '()))
+ (if (< i end)
+ (loop (+ i 1)
+ (let ((message (get-message folder i)))
+ (if (predicate message)
+ (cons message messages)
+ messages)))
+ (reverse! messages)))))))
+\f
(define (imail-summary-detach buffer)
(let ((folder-buffer (buffer-get buffer 'IMAIL-FOLDER-BUFFER #f)))
(if folder-buffer
(let ((w (window-split-vertically! window (imail-summary-height window))))
(if w
(select-buffer folder-buffer w)))))
-\f
+
(define (imail-summary-modification-event folder type parameters)
(let ((buffer (imail-folder->summary-buffer folder #f)))
(if buffer
(fill-imail-summary-buffer! buffer
folder
(buffer-get buffer
- 'IMAIL-SUMMARY-PREDICATE
+ 'IMAIL-SUMMARY-PROCEDURE
#f))))
(set-buffer-major-mode! buffer (ref-mode-object imail-summary))
(buffer-not-modified! buffer)
(if message
(imail-summary-select-message buffer message)))))))
-(define (fill-imail-summary-buffer! buffer folder predicate)
+(define (fill-imail-summary-buffer! buffer folder procedure)
(buffer-remove! buffer 'IMAIL-SUMMARY-MESSAGES)
(let ((end (folder-length folder)))
- (let ((messages
- (let loop ((i 0) (messages '()))
- (if (< i end)
- (loop (+ i 1)
- (let ((message (get-message folder i)))
- (if (or (not predicate)
- (predicate message))
- (cons message messages)
- messages)))
- (reverse! messages))))
+ (let ((messages (procedure folder))
(index-digits (exact-nonnegative-integer-digits end))
(show-date? (ref-variable imail-summary-show-date buffer)))
(let ((mark (mark-left-inserting-copy (buffer-start buffer))))