2 ;;; $Id: tm-comp.el,v 1.2 1994/09/26 12:37:03 morioka Exp $
9 (defvar mime/tmp-dir (or (getenv "TM_TMPDIR") "/tmp/"))
11 (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)
23 (defvar mime/window-config-alist
25 (mh-letter-mode . mh-previous-window-config)
26 (news-reply-mode . (prog1
27 gnus-winconf-post-news
28 (setq gnus-winconf-post-news nil)
32 (defun mime/split-and-send (&optional cmd)
35 (setq cmd (cdr (assq major-mode mime/message-sender-alist)))
37 (let ((mime/draft-file-name (buffer-file-name))
38 (lines (count-lines (point-min)(point-max)))
39 (separator mail-header-separator)
40 (config (eval (cdr (assq major-mode mime/window-config-alist))))
42 (if (null mime/draft-file-name)
43 (setq mime/draft-file-name
44 (make-temp-name (expand-file-name "tm-draft" mime/tmp-dir)))
46 (if (and (boundp 'mime-mode-flag) mime-mode-flag)
48 (if (<= lines mime/message-max-length)
50 (let ((header (message/get-header-string-except
51 "\\(^[Cc]ontent-\\|^[Ss]ubject:\\)" separator))
52 (subject (mail-fetch-field "subject"))
54 (replace-space-with-underline (current-time-string))
55 "@" (system-name) "\""))
57 (goto-char (point-min))
58 (if (re-search-forward (concat "^" (regexp-quote separator) "$")
62 (let* ((total (+ (/ lines mime/message-max-length)
63 (if (> (mod lines mime/message-max-length) 0)
65 (i 0)(l mime/message-max-length)
66 (the-buf (current-buffer))
67 (buf (get-buffer "*tmp-send*"))
71 (switch-to-buffer buf)
73 (switch-to-buffer the-buf)
75 (setq buf (get-buffer-create "*tmp-send*"))
77 (switch-to-buffer buf)
78 (make-variable-buffer-local 'mail-header-separator)
79 (setq mail-header-separator separator)
80 (switch-to-buffer the-buf)
81 (goto-char (point-min))
83 (setq buf (get-buffer "*tmp-send*"))
85 (setq data (buffer-substring
91 (switch-to-buffer buf)
94 (format "Subject: %s (%d/%d)\n" subject (+ i 1) total))
97 "Content-Type: message/partial; id=%s; number=%d; total=%d\n%s\n"
98 id (+ i 1) total separator))
102 (switch-to-buffer the-buf)
103 (setq l (+ l mime/message-max-length))
107 (set-buffer-modified-p nil)
108 (kill-buffer (current-buffer))
110 (set-window-configuration config)
114 (add-hook 'mime-mode-hook
117 (if (not (fboundp 'default-mime-mode-exit-and-run))
119 (make-variable-buffer-local 'mime/send-message-method)
120 (fset 'default-mime-mode-exit-and-run
121 'mime-mode-exit-and-run)
122 (fset 'mime-mode-exit-and-run
123 'mime/split-and-send)
126 (defun message/get-header-string-except (pat boundary)
129 (narrow-to-region (goto-char (point-min))
132 (concat "^\\(" (regexp-quote boundary) "\\)?$")
136 (goto-char (point-min))
138 (while (re-search-forward message/field-regexp nil t)
139 (setq field (buffer-substring (match-beginning 0)
142 (if (not (string-match pat field))
143 (setq header (concat header field "\n"))
148 (defun replace-space-with-underline (str)