2 ;;; $Id: tm-comp.el,v 2.0 1994/10/17 06:55:56 morioka Exp $
10 (defvar mime/message-max-length 1000)
12 (defvar mime/message-sender-alist
13 '((mail-mode . sendmail-send-it)
14 (mh-letter-mode . (lambda ()
15 (write-region (point-min) (point-max)
18 (expand-file-name mh-send-prog mh-progs)
19 nil nil nil mime/draft-file-name)
21 (news-reply-mode . gnus-inews-article)
24 (defvar mime/window-config-alist
26 (mh-letter-mode . mh-previous-window-config)
27 (news-reply-mode . (prog1
28 gnus-winconf-post-news
29 (setq gnus-winconf-post-news nil)
33 (defun mime/split-and-send (&optional cmd)
36 (setq cmd (cdr (assq major-mode mime/message-sender-alist)))
38 (let ((mime/draft-file-name (buffer-file-name))
39 (lines (count-lines (point-min)(point-max)))
40 (separator mail-header-separator)
41 (config (eval (cdr (assq major-mode mime/window-config-alist))))
43 (if (null mime/draft-file-name)
44 (setq mime/draft-file-name
45 (make-temp-name (expand-file-name "tm-draft" mime/tmp-dir)))
47 (if (and (boundp 'mime-mode-flag) mime-mode-flag)
49 (if (<= lines mime/message-max-length)
51 (let ((header (message/get-header-string-except
52 "\\(^[Cc]ontent-\\|^[Ss]ubject:\\)" separator))
53 (subject (mail-fetch-field "subject"))
55 (replace-space-with-underline (current-time-string))
56 "@" (system-name) "\""))
58 (goto-char (point-min))
59 (if (re-search-forward (concat "^" (regexp-quote separator) "$")
63 (let* ((total (+ (/ lines mime/message-max-length)
64 (if (> (mod lines mime/message-max-length) 0)
66 (i 0)(l mime/message-max-length)
67 (the-buf (current-buffer))
68 (buf (get-buffer "*tmp-send*"))
72 (switch-to-buffer buf)
74 (switch-to-buffer the-buf)
76 (setq buf (get-buffer-create "*tmp-send*"))
78 (switch-to-buffer buf)
79 (make-variable-buffer-local 'mail-header-separator)
80 (setq mail-header-separator separator)
81 (switch-to-buffer the-buf)
82 (goto-char (point-min))
84 (setq buf (get-buffer "*tmp-send*"))
86 (setq data (buffer-substring
92 (switch-to-buffer buf)
95 (format "Subject: %s (%d/%d)\n" subject (+ i 1) total))
98 "Content-Type: message/partial; id=%s; number=%d; total=%d\n%s\n"
99 id (+ i 1) total separator))
103 (switch-to-buffer the-buf)
104 (setq l (+ l mime/message-max-length))
108 (set-buffer-modified-p nil)
109 (kill-buffer (current-buffer))
111 (set-window-configuration config)
115 (add-hook 'mime-mode-hook
118 (if (not (fboundp 'default-mime-mode-exit-and-run))
120 (make-variable-buffer-local 'mime/send-message-method)
121 (fset 'default-mime-mode-exit-and-run
122 'mime-mode-exit-and-run)
123 (fset 'mime-mode-exit-and-run
124 'mime/split-and-send)
127 (defun message/get-header-string-except (pat boundary)
130 (narrow-to-region (goto-char (point-min))
133 (concat "^\\(" (regexp-quote boundary) "\\)?$")
137 (goto-char (point-min))
139 (while (re-search-forward message/field-regexp nil t)
140 (setq field (buffer-substring (match-beginning 0)
143 (if (not (string-match pat field))
144 (setq header (concat header field "\n"))
149 (defun replace-space-with-underline (str)