X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=mcs-20.el;h=944384b0502e13a618cdb0bd4598f4e373df2ec6;hb=88c8299d6a8a3da16b3054a976ccf2e94ee57fd6;hp=77911a46d2dc79f3987f9864dd50199645764b40;hpb=8ea0cf57c248b6a4ba2f73288cc1b7cad582e171;p=elisp%2Fapel.git diff --git a/mcs-20.el b/mcs-20.el index 77911a4..944384b 100644 --- a/mcs-20.el +++ b/mcs-20.el @@ -1,8 +1,8 @@ ;;; mcs-20.el --- MIME charset implementation for Emacs 20 and XEmacs/mule -;; Copyright (C) 1997,1998,1999 Free Software Foundation, Inc. +;; Copyright (C) 1997,1998,1999,2000 Free Software Foundation, Inc. -;; Author: MORIOKA Tomohiko +;; Author: MORIOKA Tomohiko ;; Keywords: emulation, compatibility, Mule ;; This file is part of APEL (A Portable Emacs Library). @@ -19,8 +19,8 @@ ;; 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: @@ -29,10 +29,13 @@ ;;; Code: -(require 'poem) -(require 'pcustom) +(require 'custom) (eval-when-compile (require 'wid-edit)) +(if (featurep 'xemacs) + (require 'mcs-xm) + (require 'mcs-e20)) + ;;; @ MIME charset ;;; @@ -43,6 +46,7 @@ (gb2312 . cn-gb-2312) (cn-gb . cn-gb-2312) (iso-2022-jp-2 . iso-2022-7bit-ss2) + (iso-2022-jp-3 . iso-2022-7bit-ss2) (tis-620 . tis620) (windows-874 . tis-620) (cp874 . tis-620) @@ -99,6 +103,8 @@ is specified, it is used as line break code type of coding-system." charset lbt cs) )))) +(defalias 'mime-charset-p 'mime-charset-to-coding-system) + (defvar widget-mime-charset-prompt-value-history nil "History of input to `widget-mime-charset-prompt-value'.") @@ -131,17 +137,85 @@ is specified, it is used as line break code type of coding-system." (widget-apply widget :notify widget event) (widget-setup))) -(defcustom default-mime-charset 'x-ctext +(defcustom default-mime-charset 'x-unknown "Default value of MIME-charset. It is used when MIME-charset is not specified. It must be symbol." :group 'i18n :type 'mime-charset) +(cond ((featurep 'utf-2000) +;; for CHISE Architecture +(defun mcs-region-repertoire-p (start end charsets &optional buffer) + (save-excursion + (if buffer + (set-buffer buffer)) + (save-restriction + (narrow-to-region start end) + (goto-char (point-min)) + (catch 'tag + (let (ch) + (while (not (eobp)) + (setq ch (char-after (point))) + (unless (some (lambda (ccs) + (encode-char ch ccs)) + charsets) + (throw 'tag nil)) + (forward-char))) + t)))) + +(defun mcs-string-repertoire-p (string charsets &optional start end) + (let ((i (if start + (if (< start 0) + (error 'args-out-of-range string start end) + start) + 0)) + ch) + (if end + (if (> end (length string)) + (error 'args-out-of-range string start end)) + (setq end (length string))) + (catch 'tag + (while (< i end) + (setq ch (aref string i)) + (unless (some (lambda (ccs) + (encode-char ch ccs)) + charsets) + (throw 'tag nil)) + (setq i (1+ i))) + t))) + +(defun detect-mime-charset-region (start end) + "Return MIME charset for region between START and END." + (let ((rest charsets-mime-charset-alist) + cell) + (catch 'tag + (while rest + (setq cell (car rest)) + (if (mcs-region-repertoire-p start end (car cell)) + (throw 'tag (cdr cell))) + (setq rest (cdr rest))) + default-mime-charset-for-write))) + +(defun detect-mime-charset-string (string) + "Return MIME charset for STRING." + (let ((rest charsets-mime-charset-alist) + cell) + (catch 'tag + (while rest + (setq cell (car rest)) + (if (mcs-string-repertoire-p string (car cell)) + (throw 'tag (cdr cell))) + (setq rest (cdr rest))) + default-mime-charset-for-write))) +) +(t +;; for legacy Mule (defun detect-mime-charset-region (start end) "Return MIME charset for region between START and END." (find-mime-charset-by-charsets (find-charset-region start end) 'region start end)) +)) (defun write-region-as-mime-charset (charset start end filename &optional append visit lockname)