;;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
;;; Maintainer: MORIOKA Tomohiko <morioka@jaist.ac.jp>
;;; Created: 1994/08/21 renamed from mime.el
-;;; Version: $Revision: 7.60 $
+;;; Version: $Revision: 7.70 $
;;; Keywords: mail, news, MIME, multimedia, multilingual
;;;
;;; This file is part of tm (Tools for MIME).
;;;
(defconst mime-editor/RCS-ID
- "$Id: tm-edit.el,v 7.60 1996/05/12 17:13:39 morioka Exp $")
+ "$Id: tm-edit.el,v 7.70 1996/07/09 13:30:32 morioka Exp $")
(defconst mime-editor/version (get-version-string mime-editor/RCS-ID))
(defvar mime-prefix "\C-c\C-x"
"*Keymap prefix for MIME commands.")
-(defvar mime-signature-file "~/.signature.rtf"
- "*Signature file to be included as a part of a multipart message.")
-
(defvar mime-ignore-preceding-spaces nil
"*Ignore preceding white spaces if non-nil.")
(defvar mime-editor/translate-hook nil
"*Hook called before translating into a MIME compliant message.
-To insert a signature file specified by mime-signature-file
-(`.signature.rtf' by default) automatically, call the function
+To insert a signature file automatically, call the function
`mime-editor/insert-signature' from this hook.")
(defvar mime-editor/exit-hook nil
nil
"attachment" (("filename" . file))
)
+ ("\\.patch$"
+ "application" "octet-stream" (("type" . "patch"))
+ nil
+ "attachment" (("filename" . file))
+ )
("\\.signature"
"text" "plain" nil nil)
(".*"
;;;
(defvar mime-editor/yank-ignored-field-list
- '("Received" "Sender" "Approved" "Path" "Status" "X-VM-.*" "X-UIDL")
+ '("Received" "Approved" "Path" "Replied" "Status" "X-VM-.*" "X-UIDL")
"Delete these fields from original message when it is inserted
as message/rfc822 part.
Each elements are regexp of field-name. [tm-edit.el]")
(defvar mime-editor/split-blind-field-regexp
"\\(^[BDFbdf]cc:\\|^cc:[ \t]*$\\)")
-(defvar mime-editor/message-default-sender-alist
- '((mail-mode . mail-send-and-exit)
- (mh-letter-mode . mh-send-letter)
- (news-reply-mode . gnus-inews-news)
- ))
-
(defvar mime-editor/split-message-sender-alist
- '((mail-mode
- . (lambda ()
- (interactive)
- (sendmail-send-it)
- ))
- (mh-letter-mode
+ '((mh-letter-mode
. (lambda (&optional arg)
(interactive "P")
(write-region (point-min) (point-max)
))
))
-(defvar mime-editor/window-config-alist
- '((mail-mode . nil)
- (mh-letter-mode . mh-previous-window-config)
- (news-reply-mode . (cond ((boundp 'gnus-winconf-post-news)
- (prog1
- gnus-winconf-post-news
- (setq gnus-winconf-post-news nil)
- ))
- ((boundp 'gnus-prev-winconf)
- (prog1
- gnus-prev-winconf
- (setq gnus-prev-winconf nil)
- ))
- ))
- ))
-
(defvar mime-editor/news-reply-mode-server-running nil)
(defconst mime-editor/mime-map (make-sparse-keymap)
"Keymap for MIME commands.")
+(defconst mime-editor/minor-mime-map nil
+ "Keymap for MIME commands.")
+
;;; @ keymap and menu
;;;
(defvar mime/editor-mode-flag nil)
(make-variable-buffer-local 'mime/editor-mode-flag)
-(set-alist 'minor-mode-alist
- 'mime/editor-mode-flag
- '((" MIME-Edit " mime-editor/transfer-level-string)))
-
(defun mime-editor/define-keymap (keymap)
"Add mime-editor commands to KEYMAP."
(if (not (keymapp keymap))
(mime-editor/define-keymap mime-editor/mime-map)
+(if mime-editor/minor-mime-map
+ ()
+ (setq mime-editor/minor-mime-map
+ (make-sparse-keymap 'mime-editor/minor-mime-map))
+ (define-key mime-editor/minor-mime-map mime-prefix mime-editor/mime-map))
+
+(defun mime-editor/toggle-mode ()
+ (interactive)
+ (if mime/editor-mode-flag
+ (mime-editor/exit 'nomime)
+ (mime/editor-mode)
+ ))
+
+(if running-xemacs
+ (add-minor-mode 'mime/editor-mode-flag
+ '((" MIME-Edit " mime-editor/transfer-level-string))
+ mime-editor/minor-mime-map
+ nil
+ 'mime-editor/toggle-mode)
+ (set-alist 'minor-mode-alist
+ 'mime/editor-mode-flag
+ '((" MIME-Edit " mime-editor/transfer-level-string))))
+
(defconst mime-editor/menu-title "MIME-Edit")
(defconst mime-editor/menu-list
mime-prefix
Specifies a key prefix for MIME minor mode commands.
- mime-signature-file
- Specifies a signature file to be included as part of a multipart
- message.
-
mime-ignore-preceding-spaces
Preceding white spaces in a message body are ignored if non-nil.
;; Restore previous state.
(setq mime/editor-mode-flag nil)
(cond (running-xemacs
- ;; mime-prefix only defined if binding was nil
- (if (eq (lookup-key (current-local-map) mime-prefix)
- mime-editor/mime-map)
- (define-key (current-local-map) mime-prefix nil))
(delete-menu-item (list mime-editor/menu-title)))
(t
(use-local-map mime/editor-mode-old-local-map)))
)))
(defun mime-editor/insert-signature (&optional arg)
- "Insert a signature file specified by mime-signature-file."
+ "Insert a signature file."
(interactive "P")
(let ((signature-insert-hook
(function
(lambda ()
(apply (function mime-editor/insert-tag)
- (mime-find-file-type signature))
+ (mime-find-file-type signature-file-name))
)))
)
(insert-signature arg)
(insert-buffer-substring buffer)
;; Encode binary message if necessary.
(if encoding
- (mime-encode-region encoding start (point-max))))
+ (mime-encode-region start (point-max) encoding)
+ ))
(if hide-p
(progn
(mime-flag-region (point-min) (1- (point-max)) ?\^M)
(insert (format "Content-Transfer-Encoding: %s\n" encoding))
)
(insert "\n")
- (or (let ((program-coding-system-alist
- (cons (cons (cons nil ".*pgp.*")
- (cons *noconv* *noconv*))
- program-coding-system-alist))
- )
- (mc-pgp-sign-region beg (point-max))
- )
+ (or (as-binary-process (mc-pgp-sign-region beg (point-max)))
(throw 'mime-editor/error 'pgp-error)
)
(goto-char beg)
(insert (format "Content-Transfer-Encoding: %s\n" encoding))
)
(insert "\n")
- (or (let ((program-coding-system-alist
- (cons (cons (cons nil ".*pgp.*")
- (cons *noconv* *noconv*))
- program-coding-system-alist))
- )
- (mc-pgp-encrypt-region
- (mc-split "\\([ \t\n]*,[ \t\n]*\\)+" recipients)
- beg (point-max))
- )
+ (or (as-binary-process
+ (mc-pgp-encrypt-region
+ (mc-split "\\([ \t\n]*,[ \t\n]*\\)+" recipients)
+ beg (point-max))
+ )
(throw 'mime-editor/error 'pgp-error)
)
(goto-char beg)
)
(mime-charset-encode-region beg (mime-editor/content-end)
charset)
- (mime-encode-region encoding beg (mime-editor/content-end))
+ (mime-encode-region beg (mime-editor/content-end) encoding)
(mime-editor/define-encoding encoding)
))
(forward-line 1)
(end (mime-editor/content-end))
(body (buffer-substring beg end))
)
- (mime-encode-region encoding beg end)
+ (mime-encode-region beg end encoding)
(mime-editor/define-encoding encoding))
(forward-line 1)
)
(make-temp-name
(expand-file-name "tm-draft" mime/tmp-dir))))
(separator mail-header-separator)
- (config
- (eval (cdr (assq major-mode mime-editor/window-config-alist))))
(id (concat "\""
(replace-space-with-underline (current-time-string))
"@" (system-name) "\"")))
(run-hooks 'mime-editor/before-split-hook)
- (let* ((header (rfc822/get-header-string-except
- mime-editor/split-ignored-field-regexp separator))
- (subject (mail-fetch-field "subject"))
- (total (+ (/ lines mime-editor/message-max-length)
- (if (> (mod lines mime-editor/message-max-length) 0)
- 1)))
- (the-buf (current-buffer))
- (buf (get-buffer "*tmp-send*"))
- (command
- (or cmd
- (cdr
- (assq major-mode
- mime-editor/split-message-sender-alist))
- (cdr
- (assq major-mode
- mime-editor/message-default-sender-alist))
- ))
- data)
- (goto-char (point-min))
- (if (re-search-forward (concat "^" (regexp-quote separator) "$")
- nil t)
- (replace-match "")
- )
- (if buf
- (progn
- (switch-to-buffer buf)
- (erase-buffer)
- (switch-to-buffer the-buf)
- )
- (setq buf (get-buffer-create "*tmp-send*"))
- )
- (switch-to-buffer buf)
- (make-local-variable 'mail-header-separator)
- (setq mail-header-separator separator)
- (switch-to-buffer the-buf)
- (goto-char (point-min))
- (re-search-forward "^$" nil t)
- (let ((mime-editor/partial-number 1))
- (setq data (buffer-substring
- (point-min)
- (progn
- (goto-line mime-editor/message-max-length)
- (point))
- ))
- (delete-region (point-min)(point))
- (switch-to-buffer buf)
- (mime-editor/insert-partial-header
- header subject id mime-editor/partial-number total separator)
- (insert data)
- (save-excursion
- (save-restriction
- (goto-char (point-min))
- (search-forward (concat "\n" mail-header-separator "\n"))
- (narrow-to-region
- (match-end 0)
- (if (re-search-forward "^$" nil t)
- (match-beginning 0)
- (point-max)
+ (let ((the-buf (current-buffer))
+ (copy-buf (get-buffer-create " *Original Message*"))
+ (header (rfc822/get-header-string-except
+ mime-editor/split-ignored-field-regexp separator))
+ (subject (mail-fetch-field "subject"))
+ (total (+ (/ lines mime-editor/message-max-length)
+ (if (> (mod lines mime-editor/message-max-length) 0)
+ 1)))
+ (command
+ (or cmd
+ (cdr
+ (assq major-mode
+ mime-editor/split-message-sender-alist))
))
- (goto-char (point-min))
- (while (re-search-forward
- mime-editor/split-blind-field-regexp nil t)
- (delete-region (match-beginning 0)
- (let ((e (rfc822/field-end)))
- (if (< e (point-max))
- (1+ e)
- e)))
- )
- ))
- (save-excursion
- (message (format "Sending %d/%d..."
- mime-editor/partial-number total))
- (call-interactively command)
- (message (format "Sending %d/%d... done"
- mime-editor/partial-number total))
- )
+ (mime-editor/partial-number 1)
+ data)
+ (save-excursion
+ (set-buffer copy-buf)
(erase-buffer)
- (switch-to-buffer the-buf)
- (setq mime-editor/partial-number 2)
- (while (< mime-editor/partial-number total)
+ (insert-buffer the-buf)
+ (save-restriction
+ (if (re-search-forward
+ (concat "^" (regexp-quote separator) "$") nil t)
+ (let ((he (match-beginning 0)))
+ (replace-match "")
+ (narrow-to-region (point-min) he)
+ ))
+ (goto-char (point-min))
+ (while (re-search-forward mime-editor/split-blind-field-regexp nil t)
+ (delete-region (match-beginning 0)
+ (1+ (rfc822/field-end)))
+ )))
+ (while (< mime-editor/partial-number total)
+ (erase-buffer)
+ (save-excursion
+ (set-buffer copy-buf)
(setq data (buffer-substring
(point-min)
(progn
(point))
))
(delete-region (point-min)(point))
- (switch-to-buffer buf)
- (mime-editor/insert-partial-header
- header subject id mime-editor/partial-number total separator)
- (insert data)
- (save-excursion
- (message (format "Sending %d/%d..."
- mime-editor/partial-number total))
- (call-interactively command)
- (message (format "Sending %d/%d... done"
- mime-editor/partial-number total))
- )
- (erase-buffer)
- (switch-to-buffer the-buf)
- (setq mime-editor/partial-number
- (1+ mime-editor/partial-number))
)
- (goto-char (point-min))
(mime-editor/insert-partial-header
header subject id mime-editor/partial-number total separator)
+ (insert data)
+ (save-excursion
+ (message (format "Sending %d/%d..."
+ mime-editor/partial-number total))
+ (call-interactively command)
+ (message (format "Sending %d/%d... done"
+ mime-editor/partial-number total))
+ )
+ (setq mime-editor/partial-number
+ (1+ mime-editor/partial-number))
+ )
+ (erase-buffer)
+ (save-excursion
+ (set-buffer copy-buf)
+ (setq data (buffer-string))
+ (erase-buffer)
+ )
+ (mime-editor/insert-partial-header
+ header subject id mime-editor/partial-number total separator)
+ (insert data)
+ (save-excursion
(message (format "Sending %d/%d..."
mime-editor/partial-number total))
- ))))
+ (message (format "Sending %d/%d... done"
+ mime-editor/partial-number total))
+ )
+ )))
(defun mime-editor/maybe-split-and-send (&optional cmd)
(interactive)
)))
))
(t
- (let* ((str (rfc822/get-header-string-except
- "^Content-Type" ""))
- charset
+ (let* (charset
(pstr
(mapconcat (function
(lambda (attr)
)
))
params ""))
- )
- (if code-conversion
+ encoding
+ encoded)
+ (save-excursion
+ (if (re-search-forward
+ "Content-Transfer-Encoding:" nil t)
+ (let ((beg (match-beginning 0))
+ (hbeg (match-end 0))
+ (end (rfc822/field-end)))
+ (setq encoding
+ (eliminate-top-spaces
+ (rfc822/unfolding-string
+ (buffer-substring hbeg end))))
+ (if (or charset (string-equal type "text"))
+ (progn
+ (delete-region beg (1+ end))
+ (goto-char (point-min))
+ (if (search-forward "\n\n" nil t)
+ (progn
+ (mime-decode-region
+ (match-end 0)(point-max) encoding)
+ (setq encoded t
+ encoding nil)
+ )))))))
+ (if (or code-conversion encoded)
(if charset
(mime-charset-decode-region (point-min)(point-max)
charset)
(character-decode-region (point-min)(point-max)
mime/default-coding-system)
))
- (and str
- (setq pstr (concat pstr "\n" str))
- )
(let ((he
(if (re-search-forward "^$" nil t)
(match-end 0)
(insert
(concat
"\n"
- (mime-create-tag (concat type "/" stype))
+ (mime-create-tag
+ (concat type "/" stype pstr) encoding)
))
)
(delete-region (point-min) he)
(insert
- (concat "\n" (mime-create-tag
- (concat type "/" stype pstr))))
+ (concat "\n"
+ (mime-create-tag
+ (concat type "/" stype pstr) encoding)
+ ))
))
))))
(if code-conversion