Add new editor variable imail-auto-summary that allows a summary
authorChris Hanson <org/chris-hanson/cph>
Fri, 20 Oct 2000 04:07:53 +0000 (04:07 +0000)
committerChris Hanson <org/chris-hanson/cph>
Fri, 20 Oct 2000 04:07:53 +0000 (04:07 +0000)
buffer to be automatically selected whenever an imail buffer is.

v7/src/imail/imail-top.scm
v7/src/imail/imail.pkg

index ef632ab12fdd9e4a3c178bfede02b1658d530668..ee5732c615f20d01a53990b04b88d0f2e986c731 100644 (file)
@@ -1,6 +1,6 @@
 ;;; -*-Scheme-*-
 ;;;
-;;; $Id: imail-top.scm,v 1.215 2000/09/30 00:21:55 cph Exp $
+;;; $Id: imail-top.scm,v 1.216 2000/10/20 04:07:53 cph Exp $
 ;;;
 ;;; Copyright (c) 1999-2000 Massachusetts Institute of Technology
 ;;;
@@ -192,6 +192,15 @@ Otherwise, only one of the parts is shown."
 Otherwise, only the IMAIL buffer for that folder has an indicator."
   #t
   boolean?)
+
+(define-variable imail-auto-summary
+  "If true, selecting an imail buffer automatically selects its summary.
+The variable can take three values:
+#F means no auto-selection is done.
+#T means select the summary only if it already exists.
+CREATE means always select the summary, creating it if needed."
+  #f
+  (lambda (x) (or (boolean? x) (eq? x 'CREATE))))
 \f
 (define-command imail
   "Read and edit incoming mail.
@@ -280,6 +289,7 @@ regardless of the folder type."
   (lambda (buffer)
     (buffer-put! buffer 'REVERT-BUFFER-METHOD imail-revert-buffer)
     (add-kill-buffer-hook buffer imail-kill-buffer)
+    (add-pre-select-buffer-hook buffer imail-pre-select-buffer-hook)
     (buffer-put! buffer 'MAIL-YANK-ORIGINAL-METHOD imail-yank-original)
     (local-set-variable! mode-line-modified "--- " buffer)
     (imail-adjust-adaptive-fill buffer)
@@ -287,7 +297,7 @@ regardless of the folder type."
     (set-buffer-read-only! buffer)
     (disable-group-undo! (buffer-group buffer))
     (event-distributor/invoke! (ref-variable imail-mode-hook buffer) buffer)))
-
+\f
 (define-variable imail-mode-hook
   "An event distributor that is invoked when entering IMAIL mode."
   (make-event-distributor))
@@ -306,6 +316,30 @@ regardless of the folder type."
    (string-append regexp "\\|"
                  (ref-variable adaptive-fill-first-line-regexp #f))
    buffer))
+
+(define (imail-pre-select-buffer-hook buffer window select continue)
+  (let ((auto-summary (ref-variable imail-auto-summary buffer)))
+    (if (and auto-summary (null? (buffer-windows buffer)))
+       (let ((folder (selected-folder #f buffer)))
+         (if folder
+             (let ((folder-buffer (imail-folder->buffer folder #f))
+                   (summary-buffer (imail-folder->summary-buffer folder #f)))
+               (if (and folder-buffer
+                        (or (eq? buffer folder-buffer)
+                            (eq? buffer summary-buffer))
+                        (null? (buffer-windows folder-buffer))
+                        (if summary-buffer
+                            (null? (buffer-windows summary-buffer))
+                            (eq? auto-summary 'CREATE)))
+                   (begin
+                     (select)          ;finish pending selection
+                     (delete-other-windows window)
+                     (if (eq? buffer folder-buffer)
+                         ((ref-command imail-summary))
+                         (imail-summary-pop-up-message-buffer buffer)))
+                   (continue)))
+             (continue)))
+       (continue))))
 \f
 (define imail-mode-description
   "IMAIL mode is used by \\[imail] for editing mail folders.
index 132d30d799487f05bf8ffa4fde5f1c8724a23dc6..a228500cda4648d2c833073f74366dc3fdca9cc3 100644 (file)
@@ -1,6 +1,6 @@
 ;;; -*-Scheme-*-
 ;;;
-;;; $Id: imail.pkg,v 1.74 2000/07/05 00:34:24 cph Exp $
+;;; $Id: imail.pkg,v 1.75 2000/10/20 04:07:50 cph Exp $
 ;;;
 ;;; Copyright (c) 2000 Massachusetts Institute of Technology
 ;;;
          edwin-command$imail-undelete-forward
          edwin-command$imail-undelete-previous-message
          edwin-mode$imail
+         edwin-variable$imail-auto-summary
          edwin-variable$imail-auto-wrap
          edwin-variable$imail-body-cache-limit
          edwin-variable$imail-default-dont-reply-to-names