;;; mime-edit.el --- Simple MIME Composer for GNU Emacs
-;; Copyright (C) 1993,94,95,96,97,98,99,2000 Free Software Foundation, Inc.
+;; Copyright (C) 1993,94,95,96,97,98,99,2000,01,02,03
+;; Free Software Foundation, Inc.
;; Author: UMEDA Masanobu <umerin@mse.kyutech.ac.jp>
;; MORIOKA Tomohiko <tomo@kanji.zinbun.kyoto-u.ac.jp>
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
;;; Commentary:
(require 'sendmail)
(require 'mail-utils)
(require 'mel)
-(require 'eword-encode) ; eword-encode-field-body
(require 'mime-view)
(require 'signature)
(require 'alist)
("enriched")
("html")
("css") ; rfc2318
+ ("csv") ; rfc4180
("xml") ; rfc2376
("x-latex")
;; ("x-rot13-47-48")
("news")
)
("application"
+ ("javascript")
+ ("msword")
("octet-stream" ("type" "" "tar" "shar"))
("postscript")
+ ("pdf")
+ ("rtf")
+ ("zip")
+ ("x-shockwave-flash")
+ ("x-7z-compressed")
+
+ ; OpenOffice
+ ("vnd.oasis.opendocument.text")
+ ("vnd.oasis.opendocument.spreadsheet")
+ ("vnd.oasis.opendocument.graphics")
+ ("vnd.oasis.opendocument.chart")
+ ("vnd.oasis.opendocument.formula")
+ ("vnd.oasis.opendocument.text-master")
+ ("vnd.oasis.opendocument.presentation")
+ ("vnd.oasis.opendocument.text-template")
+ ("vnd.oasis.opendocument.spreadsheet-template")
+ ("vnd.oasis.opendocument.presentation-template")
+ ("vnd.oasis.opendocument.graphics-template")
+
+ ("msword")
+ ("vnd.ms-excel")
("vnd.ms-powerpoint")
+ ; Microsoft Office (OpenXML)
+ ("vnd.ms-excel.addin.macroEnabled.12")
+ ("vnd.ms-excel.sheet.binary.macroEnabled.12")
+ ("vnd.ms-excel.sheet.macroEnabled.12")
+ ("vnd.ms-excel.template.macroEnabled.12")
+ ("vnd.ms-powerpoint.addin.macroEnabled.12")
+ ("vnd.ms-powerpoint.presentation.macroEnabled.12")
+ ("vnd.ms-powerpoint.slideshow.macroEnabled.12")
+ ("vnd.ms-powerpoint.template.macroEnabled.12")
+ ("vnd.ms-word.document.macroEnabled.12")
+ ("vnd.ms-word.template.macroEnabled.12")
+ ("vnd.openxmlformats-officedocument.presentationml.presentation")
+ ("vnd.openxmlformats-officedocument.presentationml.slideshow")
+ ("vnd.openxmlformats-officedocument.presentationml.template")
+ ("vnd.openxmlformats-officedocument.spreadsheetml.sheet")
+ ("vnd.openxmlformats-officedocument.spreadsheetml.template")
+ ("vnd.openxmlformats-officedocument.wordprocessingml.document")
+ ("vnd.openxmlformats-officedocument.wordprocessingml.template")
+ ("vnd.ms-xpsdocument")
+ ; Microsoft Project
+ ("vnd.ms-project")
("x-kiss" ("x-cnf")))
("image"
+ ("bmp")
("gif")
("jpeg")
("png")
+ ("svg+xml")
("tiff")
("x-pic")
("x-mag")
("x-xwd")
- ("x-xbm")
- )
- ("audio" ("basic"))
- ("video" ("mpeg"))
- )
+ ("x-xbm"))
+ ("audio"
+ ("basic")
+ ("mpeg")
+ ("ogg")
+ ("vorbis"))
+ ("video"
+ ("mpeg")
+ ("ogg")
+ ("mp4")
+ ("quicktime")
+ ("x-flv")))
"*Alist of content-type, subtype, parameters and its values.")
(defcustom mime-file-types
;; Text or translated text
- ("\\.txt$"
+ ("\\.txt$\\|\\.pln$"
"text" "plain" nil
nil
"inline" (("filename" . file))
)
+ ("\\.css$"
+ "text" "css" nil
+ nil
+ "inline" (("filename" . file))
+ )
+
+ ("\\.csv$"
+ "text" "csv" nil
+ nil
+ "inline" (("filename" . file))
+ )
+
+ ("\\.tex$\\|\\.latex$"
+ "text" "x-latex" nil
+ nil
+ "inline" (("filename" . file))
+ )
+
;; .rc : procmail modules pm-xxxx.rc
;; *rc : other resource files
"text" "plain" nil nil nil nil)
- ;; Octect binary text
+ ("\\.js$"
+ "application" "javascript" nil
+ nil
+ "inline" (("filename" . file))
+ )
+
+ ;; Microsoft Project
+ ("\\.mpp$"
+ "application" "vnd.ms-project" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
+
+
+ ;; Microsoft Office (none-OpenXML)
+
+ ("\\.rtf$" ; Rich text format
+ "application" "rtf" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
("\\.doc$" ;MS Word
"application" "msword" nil
"base64"
"attachment" (("filename" . file))
)
+ ("\\.xls$" ; MS Excel
+ "application" "vnd.ms-excel" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
("\\.ppt$" ; MS Power Point
"application" "vnd.ms-powerpoint" nil
"base64"
"attachment" (("filename" . file))
)
- ("\\.pln$"
- "text" "plain" nil
- nil
- "inline" (("filename" . file))
+
+ ;; Microsoft Office (OpenXML)
+
+ ; MS Word
+ ("\\.docm$"
+ "application" "vnd.ms-word.document.macroEnabled.12" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
+ ("\\.docx$"
+ "application" "vnd.openxmlformats-officedocument.wordprocessingml.document" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
+ ("\\.dotm$"
+ "application" "vnd.ms-word.template.macroEnabled.12" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
+ ("\\.dotx$"
+ "application" "vnd.openxmlformats-officedocument.wordprocessingml.template" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
+
+ ; MS Power Point
+ ("\\.potm$"
+ "application" "vnd.ms-powerpoint.template.macroEnabled.12" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
+ ("\\.potx$"
+ "application" "vnd.openxmlformats-officedocument.presentationml.template" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
+ ("\\.ppam$"
+ "application" "vnd.ms-powerpoint.addin.macroEnabled.12" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
+ ("\\.ppsm$"
+ "application" "vnd.ms-powerpoint.slideshow.macroEnabled.12" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
+ ("\\.ppsx$"
+ "application" "vnd.openxmlformats-officedocument.presentationml.slideshow" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
+ ("\\.pptm$"
+ "application" "vnd.ms-powerpoint.presentation.macroEnabled.12" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
+ ("\\.pptx$"
+ "application" "vnd.openxmlformats-officedocument.presentationml.presentation" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
+
+ ; MS Excel
+ ("\\.xlam$"
+ "application" "vnd.ms-excel.addin.macroEnabled.12" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
+ ("\\.xlsb$"
+ "application" "vnd.ms-excel.sheet.binary.macroEnabled.12" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
+ ("\\.xlsm$"
+ "application" "vnd.ms-excel.sheet.macroEnabled.12" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
+ ("\\.xlsx$"
+ "application" "vnd.openxmlformats-officedocument.spreadsheetml.sheet" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
+ ("\\.xltm$"
+ "application" "vnd.ms-excel.template.macroEnabled.12" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
+ ("\\.xltx$"
+ "application" "vnd.openxmlformats-officedocument.spreadsheetml.template" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
+
+
+ ;; Open Office
+ ("\\.odt$"
+ "application" "vnd.oasis.opendocument.text" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
+ ("\\.ods$"
+ "application" "vnd.oasis.opendocument.spreadsheet" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
+ ("\\.odg$"
+ "application" "vnd.oasis.opendocument.graphics" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
+ ("\\.odf$"
+ "application" "vnd.oasis.opendocument.formula" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
+ ("\\.odm$"
+ "application" "vnd.oasis.opendocument.text-master" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
+ ("\\.odp$"
+ "application" "vnd.oasis.opendocument.presentation" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
+ ("\\.ott$"
+ "application" "vnd.oasis.opendocument.text-template" nil
+ "base64"
+ "attachment" (("filename" . file))
)
+ ("\\.ots$"
+ "application" "vnd.oasis.opendocument.spreadsheet-template" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
+ ("\\.otp$"
+ "application" "vnd.oasis.opendocument.presentation-template" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
+ ("\\.otg$"
+ "application" "vnd.oasis.opendocument.graphics-template" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
+
+ ;; Postscript and PDF
("\\.ps$"
"application" "postscript" nil
- "quoted-printable"
+ "base64"
+ "attachment" (("filename" . file))
+ )
+ ("\\.pdf$"
+ "application" "pdf" nil
+ "base64"
"attachment" (("filename" . file))
)
;; Pure binary
- ("\\.jpg$"
+ ("\\.jpg$\\|\\.jpeg$"
"image" "jpeg" nil
"base64"
"inline" (("filename" . file))
"base64"
"inline" (("filename" . file))
)
+ ("\\.bmp$"
+ "image" "bmp" nil
+ "base64"
+ "inline" (("filename" . file))
+ )
+ ("\\.svg$"
+ "image" "svg+xml" nil
+ "base64"
+ "inline" (("filename" . file))
+ )
("\\.tiff$"
"image" "tiff" nil
"base64"
"base64"
"inline" (("filename" . file))
)
- ("\\.au$"
+
+ ;; Audio and video
+
+ ("\\.au$\\|\\.snd$"
"audio" "basic" nil
"base64"
"attachment" (("filename" . file))
)
- ("\\.mpg$"
+ ("\\.mp[234]\\|\\.m4[abp]$"
+ "audio" "mpeg" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
+ ("\\.ogg$"
+ "audio" "ogg" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
+ ("\\.ogg$"
+ "audio" "vorbis" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
+ ("\\.mpg\\|\\.mpeg$"
"video" "mpeg" nil
"base64"
"attachment" (("filename" . file))
)
+ ("\\.mp4\\|\\.m4v$"
+ "video" "mp4" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
+ ("\\.qt$\\|\\.mov$"
+ "video" "quicktime" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
+ ("\\.flv$"
+ "video" "x-flv" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
+ ("\\.swf$"
+ "application" "x-shockwave-flash" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
+
+
+ ;; Compressed files
+
("\\.tar\\.gz$"
"application" "octet-stream" (("type" . "tar+gzip"))
"base64"
"base64"
"attachment" (("filename" . file))
)
+ ("\\.7z$"
+ "application" "x-7z-compressed" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
;; Rest
(iso-8859-7 8 "quoted-printable")
(iso-8859-8 8 "quoted-printable")
(iso-8859-9 8 "quoted-printable")
+ (iso-8859-14 8 "quoted-printable")
+ (iso-8859-15 8 "quoted-printable")
(iso-2022-jp 7 "base64")
(iso-2022-jp-3 7 "base64")
(iso-2022-kr 7 "base64")
(if (fboundp 'apel-version)
(concat (apel-version) " "))
(if (featurep 'xemacs)
- (concat (cond ((featurep 'utf-2000)
+ (concat (cond ((and (featurep 'chise)
+ (boundp 'xemacs-chise-version))
+ (concat "CHISE-MULE/" xemacs-chise-version))
+ ((featurep 'utf-2000)
(concat "UTF-2000-MULE/" utf-2000-version))
((featurep 'mule) "MULE"))
" XEmacs"
;; XEmacs versions earlier than 21.1.1.
(format " (patch %d)" emacs-patch-level))
(t ""))
- " (" xemacs-codename ") ("
+ " (" xemacs-codename ")"
+ ;; `xemacs-extra-name' has appeared in the
+ ;; development version of XEmacs 21.5-b8.
+ (if (and (boundp 'xemacs-extra-name)
+ (symbol-value 'xemacs-extra-name))
+ (concat " " (symbol-value 'xemacs-extra-name))
+ "")
+ " ("
system-configuration ")")
" (" emacs-version ")"))
(let ((ver (if (string-match "\\.[0-9]+$" emacs-version)
(defconst mime-edit-mime-version-field-for-message/partial
(concat "MIME-Version:"
- (eword-encode-field-body
+ (mime-encode-field-body
(concat " 1.0 (split by " mime-edit-version ")\n")
- "MIME-Version:"))
+ "MIME-Version"))
"MIME version field for message/partial.")
(encrypted "Enclose as encrypted" mime-edit-enclose-pgp-encrypted-region)
(quote "Verbatim region" mime-edit-enclose-quote-region)
(key "Insert Public Key" mime-edit-insert-key)
- (split "About split" mime-edit-set-split)
- (sign "About sign" mime-edit-set-sign)
- (encrypt "About encryption" mime-edit-set-encrypt)
+ (split "Set splitting" mime-edit-set-split)
+ (sign "PGP sign" mime-edit-set-sign)
+ (encrypt "PGP encrypt" mime-edit-set-encrypt)
(preview "Preview Message" mime-edit-preview-message)
(level "Toggle transfer-level" mime-edit-toggle-transfer-level)
)
(enable-invisible)
- ;; I don't care about saving these.
+ (make-local-variable 'paragraph-start)
(setq paragraph-start
(regexp-or mime-edit-single-part-tag-regexp
paragraph-start))
+ (make-local-variable 'paragraph-separate)
(setq paragraph-separate
(regexp-or mime-edit-single-part-tag-regexp
paragraph-separate))
(run-hooks 'mime-edit-mode-hook)
(message
+ "%s"
(substitute-command-keys
"Type \\[mime-edit-exit] to exit MIME mode, and type \\[mime-edit-help] to get help."))
))
(disposition-type (nth 4 guess))
(disposition-params (nth 5 guess))
)
- (if verbose
- (setq type (mime-prompt-for-type type)
- subtype (mime-prompt-for-subtype type subtype)
- ))
(if (or (interactive-p) verbose)
- (setq encoding (mime-prompt-for-encoding encoding))
- )
+ (setq type (mime-prompt-for-type type)
+ subtype (mime-prompt-for-subtype type subtype)
+ encoding (mime-prompt-for-encoding encoding)))
(if (or (consp parameters) (stringp disposition-type))
(let ((rest parameters) cell attribute value)
(setq parameters "")
;; Change value
(concat (substring ctype 0 (match-beginning 1))
parameter "=" value
- (substring contype (match-end 1))
+ (substring ctype (match-end 1))
opt-fields)
(concat ctype "; " parameter "=" value opt-fields)
)))
(defun mime-prompt-for-parameter (parameter)
"Ask for PARAMETER.
-Parameter must be '(PROMPT CHOICE1 (CHOISE2 ...))."
+Parameter must be '(PROMPT CHOICE1 (CHOICE2...))."
(let* ((prompt (car parameter))
(choices (mapcar (function
(lambda (e)
(defun mime-edit-translate-header ()
"Encode the message header into network representation."
- (eword-encode-header 'code-conversion)
- (run-hooks 'mime-edit-translate-header-hook)
- )
+ (mime-encode-header-in-buffer 'code-conversion)
+ (run-hooks 'mime-edit-translate-header-hook))
(defun mime-edit-translate-buffer ()
"Encode the tagged MIME message in current buffer in MIME compliant message."
)
(delete-region beg end)
(or (looking-at mime-edit-beginning-tag-regexp)
+ (looking-at mime-edit-multipart-end-regexp)
(eobp)
(insert (concat (mime-make-text-tag) "\n"))
)))
(defvar mime-edit-pgp-user-id nil)
+(defun mime-edit-delete-trailing-whitespace ()
+ (save-match-data
+ (save-excursion
+ (goto-char (point-min))
+ (while (re-search-forward "[ \t]+$" nil t)
+ (delete-region (match-beginning 0) (match-end 0))))))
+
(defun mime-edit-sign-pgp-mime (beg end boundary)
(save-excursion
(save-restriction
(encoding (nth 1 ret))
(pgp-boundary (concat "pgp-sign-" boundary))
micalg)
+ (mime-edit-delete-trailing-whitespace) ; RFC3156
(goto-char beg)
(insert (format "Content-Type: %s\n" ctype))
(if encoding
(or mime-edit-pgp-user-id
(if from
(nth 1 (std11-extract-address-components from))
- pgg-default-user-id))))
+ pgg-default-user-id)))
+ (pgg-text-mode t))
(pgg-sign-region (point-min)(point-max)))
(throw 'mime-edit-error 'pgp-error)
)
(insert (format "Content-Transfer-Encoding: %s\n" encoding))
)
(insert "\n")
- (eword-encode-header)
+ (mime-encode-header-in-buffer)
(or (let ((pgg-default-user-id
(or mime-edit-pgp-user-id
(if from
(nth 1 (std11-extract-address-components from))
- pgg-default-user-id))))
+ pgg-default-user-id)))
+ (pgg-text-mode t))
(pgg-encrypt-region
(point-min) (point-max)
(mapcar (lambda (recipient)
--%s
Content-Type: application/pgp-encrypted
+Version: 1
--%s
Content-Type: application/octet-stream
Content-Transfer-Encoding: 7bit
(insert "Content-Type: " contype "\n")
(if encoding
(insert "Content-Transfer-Encoding: " encoding "\n"))
- (eword-encode-header)
- )
+ (mime-encode-header-in-buffer))
(cons (and contype
(downcase contype))
(and encoding
(narrow-to-region beg (mime-edit-content-end))
(goto-char beg)
(while (re-search-forward "\\(\\=\\|[^\r]\\)\n" nil t)
- (replace-match "\\1\r\n"))))
+ ;; In a certain period, `replace-match' with "\\N"
+ ;; converted 8-bit characters into multibyte string,
+ ;; but it has been fixed at 2004-01-15.
+ ;;(replace-match "\\1\r\n"))))
+ (backward-char 1)
+ (insert "\r")
+ (forward-char 1))))
(goto-char beg)
(mime-encode-region beg (mime-edit-content-end)
(or encoding "7bit"))
(setq mime-edit-pgp-processing
(nconc mime-edit-pgp-processing
(copy-sequence '(encrypt)))))
- (message "This message will be encrypt.")
+ (message "This message will be encrypted.")
)
(setq mime-edit-pgp-processing
(delq 'encrypt mime-edit-pgp-processing))
- (message "This message will not be encrypt.")
+ (message "This message will not be encrypted.")
))
(defun mime-edit-pgp-enclose-buffer ()
(match-end 0)
)))
)
- (if beg
- (dolist (pgp-processing mime-edit-pgp-processing)
- (case pgp-processing
- (sign
- (mime-edit-enclose-pgp-signed-region
- beg (point-max))
- )
- (encrypt
- (mime-edit-enclose-pgp-encrypted-region
- beg (point-max))
- )))
+ (when beg
+ (if (memq 'sign mime-edit-pgp-processing)
+ (mime-edit-enclose-pgp-signed-region beg (point-max)))
+ (if (memq 'encrypt mime-edit-pgp-processing)
+ (mime-edit-enclose-pgp-encrypted-region beg (point-max)))
)))
-
;;; @ split
;;;
(or (cdr (assq major-mode mime-edit-message-max-lines-alist))
mime-edit-message-default-max-lines))
)
- (let* ((mime-edit-draft-file-name
- (or (buffer-file-name)
- (make-temp-name
- (expand-file-name "mime-draft" temporary-file-directory))))
- (separator mail-header-separator)
- (id (concat "\""
- (replace-space-with-underline (current-time-string))
- "@" (system-name) "\"")))
+ (let ((separator mail-header-separator)
+ (id (concat "\""
+ (replace-space-with-underline (current-time-string))
+ "@" (system-name) "\"")))
(run-hooks 'mime-edit-before-split-hook)
(let ((the-buf (current-buffer))
(copy-buf (get-buffer-create " *Original Message*"))
(message (format "Sending %d/%d..."
mime-edit-partial-number total))
(call-interactively command)
- (message (format "Sending %d/%d... done"
+ (message (format "Sending %d/%d...done"
mime-edit-partial-number total))
)
(setq mime-edit-partial-number
(save-excursion
(message (format "Sending %d/%d..."
mime-edit-partial-number total))
- (message (format "Sending %d/%d... done"
+ (message (format "Sending %d/%d...done"
mime-edit-partial-number total))
)
)))
;;;
(defvar mime-edit-buffer nil) ; buffer local variable
+(defvar mime-edit-temp-message-buffer nil) ; buffer local variable
(defun mime-edit-preview-message ()
"preview editing MIME message."
(setq encoded t
encoding nil)
)))))))
- (if (or encoded (not not-decode-text))
+ (if (and (eq type 'text)
+ (or encoded (not not-decode-text)))
(progn
(save-excursion
(goto-char (point-min))