;;;
;;; tm-edit.el --- Simple MIME Composer for GNU Emacs
;;;
-
-;; Copyright (C) 1993 UMEDA Masanobu
-;; Copyright (C) 1994,1995 MORIOKA Tomohiko
-
-;; Author: UMEDA Masanobu <umerin@mse.kyutech.ac.jp>
-;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
-;; Version: $Revision: 7.35 $
-;; Keywords: mail, news, MIME, multimedia, multilingual
-
-;; This file is not part of GNU Emacs.
-
-;; GNU Emacs is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-;; GNU General Public License for more details.
-
-;; 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, 675 Mass Ave, Cambridge, MA 02139, USA.
+;;; Copyright (C) 1993 UMEDA Masanobu
+;;; Copyright (C) 1994,1995 MORIOKA Tomohiko
+;;;
+;;; Author: UMEDA Masanobu <umerin@mse.kyutech.ac.jp>
+;;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
+;;; Maintainer: MORIOKA Tomohiko <morioka@jaist.ac.jp>
+;;; Created: 1994/08/21 renamed from mime.el
+;;; Version: $Revision: 7.41 $
+;;; Keywords: mail, news, MIME, multimedia, multilingual
+;;;
+;;; This file is part of tm (Tools for MIME).
+;;;
+;;; This program is free software; you can redistribute it and/or
+;;; modify it under the terms of the GNU General Public License as
+;;; published by the Free Software Foundation; either version 2, or
+;;; (at your option) any later version.
+;;;
+;;; This program is distributed in the hope that it will be useful,
+;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;;; General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with This program. If not, write to the Free Software
+;;; Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
;;; Commentary:
;; definition to load mime/editor-mode automatically:
;;
;; (autoload 'mime/editor-mode "tm-edit"
-;; "Minor mode for editing MIME message." t)
+;; "Minor mode for editing MIME message." t)
;;
;; In case of Mail mode (includes VM mode), you need the following
;; hook definition:
;;
;;--[[audio/basic][base64]]^M...audio encoded in base64 comes here...
-;; LCD Archive Entry:
-;; mime|Masanobu UMEDA|umerin@mse.kyutech.ac.jp|
-;; Simple MIME Composer|
-;; $Date: 1995/12/15 15:02:14 $|$Revision: 7.35 $|~/misc/mime.el.Z|
-
;;; Code:
(require 'sendmail)
;;;
(defconst mime-editor/RCS-ID
- "$Id: tm-edit.el,v 7.35 1995/12/15 15:02:14 morioka Exp $")
+ "$Id: tm-edit.el,v 7.41 1996/01/18 17:49:17 morioka Exp $")
(defconst mime-editor/version (get-version-string mime-editor/RCS-ID))
(defvar mime-auto-hide-body t
"*Hide non-textual body encoded in base64 after insertion if non-nil.")
-(defvar mime-body-charset-chooser
- (cond ((boundp 'NEMACS)
- (function mime-body-charset-chooser-for-nemacs))
- ((featurep 'mule)
- (function mime-body-charset-chooser-for-mule))
- ((string-match "^19\\." emacs-version)
- (function mime-body-charset-chooser-for-emacs19))
- (t ;ASCII only emacs
- (function mime-body-charset-chooser-for-emacs18)))
- "*Function to identify charset and encoding of a text in a given region.
-The value is a form of (CHARSET . ENCODING), where ENCODING must be a
-full name, such as base64.")
-
(defvar mime-string-encoder
(cond ((boundp 'NEMACS)
(function mime-string-encoder-for-nemacs))
("rfc822")
)
("application"
- ("octet-stream"
- ("name")
- ("type" "" "tar" "shar")
- ("conversions"))
+ ("octet-stream" ("type" "" "tar" "shar"))
("postscript")
("x-kiss" ("x-cnf")))
("image"
("jpeg")
("tiff")
("x-pic")
+ ("x-mag")
("x-xwd")
("x-xbm")
)
(defvar mime-file-types
'(("\\.rtf$"
- "text" "richtext" nil nil)
+ "text" "richtext" nil
+ nil
+ nil nil)
("\\.html$"
- "text" "html" nil nil)
+ "text" "html" nil
+ nil
+ nil nil)
("\\.ps$"
- "application" "postscript" nil "quoted-printable")
- ("\\.gif$"
- "image" "gif" nil "base64"
- (("Content-Description" . file))
+ "application" "postscript" nil
+ "quoted-printable"
+ "attachment" (("filename" . file))
)
("\\.jpg$"
- "image" "jpeg" nil "base64")
- ("\\.xwd$"
- "image" "x-xwd" nil "base64")
- ("\\.xbm$"
- "image" "x-xbm" nil "base64")
- ("\\.pic$"
- "image" "x-pic" nil "base64"
- (("Content-Description" . file))
+ "image" "jpeg" nil
+ "base64"
+ "inline" (("filename" . file))
+ )
+ ("\\.gif$"
+ "image" "gif" nil
+ "base64"
+ "inline" (("filename" . file))
)
("\\.tiff$"
- "image" "tiff" nil "base64")
+ "image" "tiff" nil
+ "base64"
+ "inline" (("filename" . file))
+ )
+ ("\\.pic$"
+ "image" "x-pic" nil
+ "base64"
+ "inline" (("filename" . file))
+ )
+ ("\\.mag$"
+ "image" "x-mag" nil
+ "base64"
+ "inline" (("filename" . file))
+ )
+ ("\\.xbm$"
+ "image" "x-xbm" nil
+ "base64"
+ "inline" (("filename" . file))
+ )
+ ("\\.xwd$"
+ "image" "x-xwd" nil
+ "base64"
+ "inline" (("filename" . file))
+ )
("\\.au$"
- "audio" "basic" nil "base64")
+ "audio" "basic" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
("\\.mpg$"
- "video" "mpeg" nil "base64")
+ "video" "mpeg" nil
+ "base64"
+ "attachment" (("filename" . file))
+ )
("\\.el$"
- "application" "octet-stream" (("name" . file)
- ("type" . "emacs-lisp")) "7bit")
+ "application" "octet-stream" (("type" . "emacs-lisp"))
+ "7bit"
+ "attachment" (("filename" . file))
+ )
("\\.lsp$"
- "application" "octet-stream" (("name" . file)
- ("type" . "common-lisp")) "7bit")
- ("\\.tar.gz$"
- "application" "octet-stream" (("name" . file)
- ("type" . "tar")
- ("conversions" . "gzip")) nil)
+ "application" "octet-stream" (("type" . "common-lisp"))
+ "7bit"
+ "attachment" (("filename" . file))
+ )
+ ("\\.tar\\.gz$"
+ "application" "octet-stream" (("type" . "tar+gzip"))
+ nil
+ "attachment" (("filename" . file))
+ )
+ ("\\.tgz$"
+ "application" "octet-stream" (("type" . "tar+gzip"))
+ nil
+ "attachment" (("filename" . file))
+ )
+ ("\\.tar\\.Z$"
+ "application" "octet-stream" (("type" . "tar+compress"))
+ nil
+ "attachment" (("filename" . file))
+ )
+ ("\\.taz$"
+ "application" "octet-stream" (("type" . "tar+compress"))
+ nil
+ "attachment" (("filename" . file))
+ )
+ ("\\.gz$"
+ "application" "octet-stream" (("type" . "gzip"))
+ nil
+ "attachment" (("filename" . file))
+ )
+ ("\\.Z$"
+ "application" "octet-stream" (("type" . "compress"))
+ nil
+ "attachment" (("filename" . file))
+ )
+ ("\\.lzh$"
+ "application" "octet-stream" (("type" . "lha"))
+ nil
+ "attachment" (("filename" . file))
+ )
+ ("\\.zip$"
+ "application" "zip" nil
+ nil
+ "attachment" (("filename" . file))
+ )
("\\.diff$"
- "application" "octet-stream" (("name" . file)
- ("type" . "patch")) nil)
+ "application" "octet-stream" (("type" . "patch"))
+ nil
+ "attachment" (("filename" . file))
+ )
("\\.signature"
"text" "plain" nil nil)
- (".*" nil nil nil nil)
+ (".*"
+ "application" "octet-stream" nil
+ nil
+ "attachment" (("filename" . file))
+ )
)
"*Alist of file name, types, parameters, and default encoding.
If encoding is nil, it is determined from its contents.")
"*PGP signing type (pgp-elkins, pgp-kazu or nil). [tm-edit.el]")
(defvar mime-editor/encrypting-type nil
- "*PGP encrypting type (pgp-elkins, pgp-kazu or nil).
-Sorry `pgp-elkins' is not supported yet. [tm-edit.el]")
+ "*PGP encrypting type (pgp-elkins, pgp-kazu or nil). [tm-edit.el]")
(if (or mime-editor/signing-type mime-editor/encrypting-type)
(require 'mailcrypt)
Hide a non-textual body message encoded in base64 after insertion
if non-nil.
- mime-body-charset-chooser
- Specifies a function to identify charset and encoding of a text in
- a given region. The value is a form of (CHARSET . ENCODING),
- where ENCODING must be a full name, such as base64.
-
mime-string-encoder
Specifies a function to encode a string for given encoding method.
The method is a form of (CHARSET . ENCODING).
(setq selective-display t)
;; I don't care about saving these.
(setq paragraph-start
- (concat mime-editor/single-part-tag-regexp "\\|" paragraph-start))
+ (regexp-or mime-editor/single-part-tag-regexp
+ paragraph-start))
(setq paragraph-separate
- (concat mime-editor/single-part-tag-regexp "\\|" paragraph-separate))
+ (regexp-or mime-editor/single-part-tag-regexp
+ paragraph-separate))
(run-hooks 'mime/editor-mode-hook)
(message
(substitute-command-keys
(defun mime-editor/insert-text ()
"Insert a text message.
-Charset is automatically obtained from the mime-body-charset-chooser."
+Charset is automatically obtained from the `mime/lc-charset-alist'."
(interactive)
(if (and (mime-editor/insert-tag "text" nil nil)
(looking-at mime-editor/single-part-tag-regexp))
(subtype (nth 1 guess))
(parameters (nth 2 guess))
(default (nth 3 guess)) ;Guess encoding from its file name.
- (fields (nth 4 guess))
+ (disposition-type (nth 4 guess))
+ (disposition-params (nth 5 guess))
(encoding
(if (not (interactive-p))
default
mime-encoding-method-alist nil t nil))))
(if (string-equal encoding "")
(setq encoding default))
- (if (or (consp parameters) (consp fields))
+ (if (or (consp parameters) (stringp disposition-type))
(let ((rest parameters) cell attribute value)
(setq parameters "")
(while rest
(setq attribute (car cell))
(setq value (cdr cell))
(if (eq value 'file)
- (setq value (file-name-nondirectory file))
+ (setq value (rfc822/wrap-as-quoted-string
+ (file-name-nondirectory file)))
)
(setq parameters (concat parameters "; " attribute "=" value))
(setq rest (cdr rest))
)
- (setq rest fields)
- (while rest
- (setq cell (car rest))
- (setq attribute (car cell))
- (setq value (cdr cell))
- (if (eq value 'file)
- (setq value (file-name-nondirectory file))
- )
- (setq parameters (concat parameters "\n" attribute ": " value))
- (setq rest (cdr rest))
- )
+ (if disposition-type
+ (progn
+ (setq parameters
+ (concat parameters "\n"
+ "Content-Disposition: " disposition-type))
+ (setq rest disposition-params)
+ (while rest
+ (setq cell (car rest))
+ (setq attribute (car cell))
+ (setq value (cdr cell))
+ (if (eq value 'file)
+ (setq value (rfc822/wrap-as-quoted-string
+ (file-name-nondirectory file)))
+ )
+ (setq parameters
+ (concat parameters "; " attribute "=" value))
+ (setq rest (cdr rest))
+ )
+ ))
))
(mime-editor/insert-tag pritype subtype parameters)
(mime-editor/insert-binary-file file encoding)
(exist-next-tag (save-excursion
(insert "\n")
)))
- ;; (beginning-of-line)
- ;; (cond ((and oldtag ;Text
- ;; (not (eobp))
- ;; (save-excursion
- ;; (forward-line -1)
- ;; (looking-at mime-editor/beginning-tag-regexp)
- ;; )
- ;; (or mime-ignore-same-text-tag
- ;; (not (string-equal oldtag newtag))))
- ;; ;; If point is at the next of current tag, move to the
- ;; ;; beginning of the tag to disable insertion of extra tag.
- ;; (forward-line -1))
- ;; ((and oldtag ;Text
- ;; (not (eobp))
- ;; (not (looking-at mime-editor/tag-regexp))
- ;; (or mime-ignore-same-text-tag
- ;; (not (string-equal oldtag newtag))))
- ;; ;; Copy current tag to break a text into two.
- ;; (save-excursion
- ;; (insert oldtag "\n")))
- ;; ((and (null oldtag) ;Not text
- ;; (not (looking-at mime-editor/tag-regexp)))
- ;; ;; Adjust insertion point. In the middle of text, it is
- ;; ;; okay to break the text into two. However, it should not
- ;; ;; be broken into two, if otherwise.
- ;; (goto-char (mime-editor/content-end))
- ;; (if (eolp)
- ;; (forward-line 1))
- ;; (if (not (bolp))
- ;; (insert "\n"))
- ;; ))
(if (not (bolp))
(if exist-prev-tag
(forward-line 1)
(defun mime-editor/choose-charset ()
"Choose charset of a text following current point."
- (save-excursion
- (let* ((beg (point))
- (end (mime-editor/content-end)))
- (car (funcall mime-body-charset-chooser beg end)))))
-
-(defun mime-editor/choose-encoding ()
- "Choose encoding of a text following current point."
- (save-excursion
- (let* ((beg (point))
- (end (mime-editor/content-end)))
- (cdr (funcall mime-body-charset-chooser beg end)))))
+ (mime/find-charset-region (point) (mime-editor/content-end))
+ )
(defun mime-make-text-tag (&optional subtype)
"Make a tag for a text after current point.
))
((string= type "encrypted")
(cond ((eq mime-editor/signing-type 'pgp-elkins)
- (message "Sorry, it is not supported yet")
+ (mime-editor/encrypt-pgp-elkins bb eb boundary)
)
((eq mime-editor/signing-type 'pgp-kazu)
(mime-editor/process-pgp-kazu 'mc-encrypt
))
boundary))))
-(defun mc-tmpgp-generic-parser (result)
- (if (or (not (eq result 0))
- (mc-message "^\aError: +Bad pass phrase\\.$" (current-buffer))
- )
- (progn
- (mc-deactivate-passwd t)
- nil)
- result))
+(defun tm:mc-pgp-generic-parser (result)
+ (let ((ret (mc-pgp-generic-parser result)))
+ (if (consp ret)
+ (vector (car ret)(cdr ret))
+ )))
+
+(autoload 'mc-pgp-lookup-key "mc-pgp")
-(defvar mc-tmpgp-path "tmpgp")
+(defun tm:mc-process-region
+ (beg end passwd program args parser &optional buffer boundary)
+ (let ((obuf (current-buffer))
+ (process-connection-type nil)
+ mybuf result rgn proc)
+ (unwind-protect
+ (progn
+ (setq mybuf (or buffer (generate-new-buffer " *mailcrypt temp")))
+ (set-buffer mybuf)
+ (erase-buffer)
+ (set-buffer obuf)
+ (buffer-disable-undo mybuf)
+ (setq proc
+ (apply 'start-process "*PGP*" mybuf program args))
+ (if passwd
+ (progn
+ (process-send-string proc (concat passwd "\n"))
+ (or mc-passwd-timeout (mc-deactivate-passwd t))))
+ (process-send-region proc beg end)
+ (process-send-eof proc)
+ (while (eq 'run (process-status proc))
+ (accept-process-output proc 5))
+ (setq result (process-exit-status proc))
+ ;; Hack to force a status_notify() in Emacs 19.29
+ (delete-process proc)
+ (set-buffer mybuf)
+ (goto-char (point-max))
+ (if (re-search-backward "\nProcess \\*PGP.*\n\\'" nil t)
+ (delete-region (match-beginning 0) (match-end 0)))
+ (goto-char (point-min))
+ ;; CRNL -> NL
+ (while (search-forward "\r\n" nil t)
+ (replace-match "\n"))
+ ;; Hurm. FIXME; must get better result codes.
+ (if (stringp result)
+ (error "%s exited abnormally: '%s'" program result)
+ (setq rgn (funcall parser result))
+ ;; If the parser found something, migrate it
+ (if (consp rgn)
+ (progn
+ (set-buffer obuf)
+ (if boundary
+ (save-restriction
+ (narrow-to-region beg end)
+ (goto-char beg)
+ (insert (format "--%s\n" boundary))
+ (goto-char (point-max))
+ (insert (format "\n--%s
+Content-Type: application/pgp-signature
+Content-Transfer-Encoding: 7bit
+
+" boundary))
+ (insert-buffer-substring mybuf (car rgn) (cdr rgn))
+ (goto-char (point-max))
+ (insert (format "\n--%s--\n" boundary))
+ )
+ (delete-region beg end)
+ (goto-char beg)
+ (insert-buffer-substring mybuf (car rgn) (cdr rgn))
+ )
+ (set-buffer mybuf)
+ (delete-region (car rgn) (cdr rgn)))))
+ ;; Return nil on failure and exit code on success
+ (if rgn result))
+ ;; Cleanup even on nonlocal exit
+ (if (and proc (eq 'run (process-status proc)))
+ (interrupt-process proc))
+ (set-buffer obuf)
+ (or buffer (null mybuf) (kill-buffer mybuf)))))
(defun tm:mc-pgp-sign-region (start end &optional id unclear boundary)
(if (not (boundp 'mc-pgp-user-id))
)
(let ((process-environment process-environment)
(buffer (get-buffer-create mc-buffer-name))
- passwd args key parser pgp-path
- signature-file)
+ passwd args key
+ (parser (function mc-pgp-generic-parser))
+ (pgp-path mc-pgp-path)
+ )
(setq key (mc-pgp-lookup-key (or id mc-pgp-user-id)))
(setq passwd
(mc-activate-passwd
(format "PGP passphrase for %s (%s): " (car key) (cdr key))))
(setenv "PGPPASSFD" "0")
(setq args
- (list "+verbose=1" "+language=en"
- (format "+clearsig=%s" (if unclear "off" "on"))
- "+batchmode" "-u" (cdr key)))
- (if boundary
- (progn
- (setq parser 'mc-tmpgp-generic-parser
- pgp-path mc-tmpgp-path
- signature-file (make-temp-name
- (expand-file-name "tm-sign" mime/tmp-dir))
- args (cons "-fbst" args))
- (if mc-pgp-comment
- (setq args (cons (format "+comment=%s" mc-pgp-comment) args))
- )
- (setq args (cons signature-file args))
- )
- (setq parser 'mc-pgp-generic-parser
- pgp-path mc-pgp-path
- args (cons "-fast" args)
- )
- (if mc-pgp-comment
- (setq args (cons (format "+comment=%s" mc-pgp-comment) args))
- )
+ (cons
+ (if boundary
+ "-fbast"
+ "-fast")
+ (list "+verbose=1" "+language=en"
+ (format "+clearsig=%s" (if unclear "off" "on"))
+ "+batchmode" "-u" (cdr key))))
+ (if mc-pgp-comment
+ (setq args (cons (format "+comment=%s" mc-pgp-comment) args))
)
(message "Signing as %s ..." (car key))
- (if (mc-process-region start end passwd pgp-path args parser buffer)
+ (if (tm:mc-process-region
+ start end passwd pgp-path args parser buffer boundary)
(progn
(if boundary
(progn
(insert
(format "\
--[[multipart/signed; protocol=\"application/pgp-signature\";
- boundary=\"%s\"; micalg=pgp-md5][7bit]]
---%s\n" boundary boundary))
- (goto-char (point-max))
- (insert (format "\n--%s\n" boundary))
- (insert "Content-Type: application/pgp-signature
-Content-Transfer-Encoding: base64
-
-")
- (insert-file-contents signature-file)
- (goto-char (point-max))
- (insert (format "\n--%s--\n" boundary))
+ boundary=\"%s\"; micalg=pgp-md5][7bit]]\n" boundary))
))
- (delete-file signature-file)
(message "Signing as %s ... Done." (car key))
t)
nil)))
)
))))
+(defun mime-editor/encrypt-pgp-elkins (beg end boundary)
+ (save-excursion
+ (save-restriction
+ (narrow-to-region beg end)
+ (let* ((ret
+ (mime-editor/translate-region beg end boundary))
+ (ctype (car ret))
+ (encoding (nth 1 ret))
+ (parts (nth 3 ret))
+ (pgp-boundary (concat "pgp-" boundary))
+ )
+ (goto-char beg)
+ (insert (format "Content-Type: %s\n" ctype))
+ (if encoding
+ (insert (format "Content-Transfer-Encoding: %s\n" encoding))
+ )
+ (insert "\n")
+ (if (null
+ (progn
+ (goto-char beg)
+ (insert "=\n")
+ (prog1
+ (let ((mail-header-separator "="))
+ (call-interactively 'mc-encrypt)
+ )
+ (goto-char beg)
+ (and (search-forward "=\n")
+ (replace-match ""))
+ )))
+ (throw 'mime-editor/error 'pgp-error)
+ )
+ (goto-char beg)
+ (insert (format "--[[multipart/encrypted;
+ boundary=\"%s\";
+ protocol=\"application/pgp-encrypted\"][7bit]]
+--%s
+Content-Type: application/pgp-encrypted
+
+--%s
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: 7bit
+
+" pgp-boundary pgp-boundary pgp-boundary))
+ (goto-char (point-max))
+ (insert (format "\n--%s--\n" pgp-boundary))
+ ))
+ ))
+
(defun mime-editor/process-pgp-kazu (type beg end boundary)
(save-excursion
(save-restriction
(interactive)
(save-excursion
(let ((boundary
- (concat mime-multipart-boundary " " (current-time-string)))
+ (concat mime-multipart-boundary "_"
+ (replace-space-with-underline (current-time-string))
+ ))
(i 1)
- (time (current-time-string))
ret)
(while (mime-editor/process-multipart-1
- (format "%s %s-%d" mime-multipart-boundary time i))
+ (format "%s-%d" boundary i))
(setq i (1+ i))
)
(save-restriction
(point))))
(setq ret (mime-editor/translate-region
beg end
- (format "%s %s-%d" mime-multipart-boundary time i)))
+ (format "%s-%d" boundary i)))
))
(let ((contype (car ret)) ;Content-Type
(encoding (nth 1 ret)) ;Content-Transfer-Encoding
(defun mime-editor/translate-region (beg end &optional boundary multipart)
(if (null boundary)
(setq boundary
- (concat mime-multipart-boundary " " (current-time-string)))
+ (concat mime-multipart-boundary "_"
+ (replace-space-with-underline (current-time-string))))
)
(save-excursion
(save-restriction
;; Point is now on current tag.
;; Define encoding and encode text if necessary.
(if (null encoding) ;Encoding is not specified.
- (let* ((encoding (mime-editor/choose-encoding))
+ (let* ((encoding
+ (cdr
+ (assoc charset mime/charset-default-encoding-alist)
+ ))
(beg (mime-editor/content-beginning))
(end (mime-editor/content-end))
(body (buffer-substring beg end))
;; Emacs 18 implementations
-(defun mime-body-charset-chooser-for-emacs18 (begin end)
- "Return a cons of charset and encoding of a message in a given region.
-Encoding name must be a canonical name, such as `base64'."
- '("US-ASCII" . nil) ;Default charset of MIME.
- )
-
(defun mime-string-encoder-for-emacs18 (method string)
"For given METHOD that is a cons of charset and encoding, encode a STRING."
(let ((charset (car method))
\f
;; Emacs 19 implementations
-(defun mime-body-charset-chooser-for-emacs19 (begin end)
- "Return a cons of charset and encoding of a message in a given region.
-Encoding name must be a canonical name, such as `base64'.
-US-ASCII and ISO-8859-1 are supported on Emacs 19."
- (cond ((save-excursion
- (goto-char begin)
- (re-search-forward "[\200-\377]" end t))
- '("ISO-8859-1" . "quoted-printable"))
- (t
- '("US-ASCII" . nil)) ;Default charset of MIME.
- ))
-
(defun mime-string-encoder-for-emacs19 (method string)
"For given METHOD that is a cons of charset and encoding, encode a STRING."
(let ((charset (car method))
\f
;; NEmacs implementations
-(defun mime-body-charset-chooser-for-nemacs (begin end)
- "Return a cons of charset and encoding of a message in a given region.
-Encoding name must be a canonical name, such as `base64'.
-US-ASCII and ISO-2022-JP are supported on NEmacs."
- (cond ((check-region-kanji-code begin end)
- ;; The following are safe encoding methods for use in
- ;; USENET News systems that strip off all ESCs.
- ;; '("ISO-2022-JP" . "quoted-printable")
- ;; '("ISO-2022-JP" . "base64")
- ;; The following expects transport systems are all MIME
- ;; compliants. For instance, ESCs are never stripped off.
- '("ISO-2022-JP" . nil))
- (t
- '("US-ASCII" . nil)) ;Default charset of MIME.
- ))
-
(defun mime-string-encoder-for-nemacs (method string)
"For given METHOD that is a cons of charset and encoding, encode a STRING.
US-ASCII and ISO-2022-JP are supported on NEmacs."
;; Thanks to contributions by wkenji@flab.fujitsu.co.jp (Kenji
;; WAKAMIYA) and handa@etl.go.jp (Kenichi Handa).
-(defun mime-body-charset-chooser-for-mule (begin end)
- "Return a cons of charset and encoding of a message in a given
-region. Encoding name must be a canonical name, such as `base64'.
-US-ASCII, ISO-8859-* (except for ISO-8859-6), ISO-2022-JP,
-ISO-2022-JP-2 and ISO-2022-INT-1 are supported on Mule. Either of
-charset ISO-2022-JP-2 or ISO-2022-INT-1 is used for multilingual text
-in Mule."
- (let ((lclist (find-charset-region begin end)))
- (cond ((null lclist)
- '("US-ASCII" . nil)) ;Default charset of MIME.
- ;; Multilingual capability requred.
- ((and (> (length lclist) 1)
- (boundp '*iso-2022-int-1*))
- '("ISO-2022-INT-1" . nil))
- ((> (length lclist) 1)
- '("ISO-2022-JP-2" . nil))
- ;; Simple charset.
- ((memq lc-ltn1 lclist)
- '("ISO-8859-1" . "quoted-printable"))
- ((memq lc-ltn2 lclist)
- '("ISO-8859-2" . "quoted-printable"))
- ((memq lc-ltn3 lclist)
- '("ISO-8859-3" . "quoted-printable"))
- ((memq lc-ltn4 lclist)
- '("ISO-8859-4" . "quoted-printable"))
- ((memq lc-crl lclist)
- '("ISO-8859-5" . "quoted-printable"))
- ;;((memq lc-arb lclist)
- ;; '("ISO-8859-6" . "quoted-printable"))
- ((memq lc-grk lclist)
- '("ISO-8859-7" . "quoted-printable"))
- ((memq lc-hbw lclist)
- '("ISO-8859-8" . "quoted-printable"))
- ((memq lc-ltn5 lclist)
- '("ISO-8859-9" . "quoted-printable"))
- ((memq lc-jp lclist)
- '("ISO-2022-JP" . nil))
- ((memq lc-kr lclist)
- '("ISO-2022-KR" . nil))
- ;; Unknown charset.
- ((boundp '*iso-2022-int-1*)
- '("ISO-2022-INT-1" . nil))
- (t
- '("ISO-2022-JP-2" . nil))
- )))
-
(defun mime-string-encoder-for-mule (method string)
"For given METHOD that is a cons of charset and encoding, encode a
STRING. US-ASCII, ISO-8859-* (except for ISO-8859-6), ISO-2022-JP,