1 ;;; emu-20.el --- emu API implementation for Emacs 20 and XEmacs/mule
3 ;; Copyright (C) 1997 Free Software Foundation, Inc.
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Version: $Id: emu-20.el,v 7.15 1997/09/07 02:57:51 morioka Exp $
7 ;; Keywords: emulation, compatibility, Mule
9 ;; This file is part of emu.
11 ;; This program is free software; you can redistribute it and/or
12 ;; modify it under the terms of the GNU General Public License as
13 ;; published by the Free Software Foundation; either version 2, or (at
14 ;; your option) any later version.
16 ;; This program is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ;; General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
28 ;; This module requires Emacs 20.0.93, XEmacs 20.3-b5 (with mule)
36 (defmacro as-binary-process (&rest body)
37 `(let (selective-display ; Disable ^M to nl translation.
38 (coding-system-for-read 'binary)
39 (coding-system-for-write 'binary))
42 (defmacro as-binary-input-file (&rest body)
43 `(let ((coding-system-for-read 'binary))
46 (defmacro as-binary-output-file (&rest body)
47 `(let ((coding-system-for-write 'binary))
50 (defun insert-binary-file-contents-literally
51 (filename &optional visit beg end replace)
52 "Like `insert-file-contents-literally', q.v., but don't code conversion.
53 A buffer may be modified in several ways after reading into the buffer due
54 to advanced Emacs features, such as file-name-handlers, format decoding,
56 This function ensures that none of these modifications will take place."
57 (let ((coding-system-for-read 'binary))
58 (insert-file-contents-literally filename visit beg end replace)
61 ;;; @@ Mule emulating aliases
63 ;;; You should not use it.
65 (defconst *noconv* 'binary
66 "Coding-system for binary.
67 This constant is defined to emulate old MULE anything older than MULE
68 2.3. It is obsolete, so don't use it.")
74 (defvar mime-charset-coding-system-alist
76 '((us-ascii . iso-8859-1)
78 (iso-2022-jp-2 . iso-2022-7bit-ss2)
83 (let ((pair (car rest)))
84 (or (find-coding-system (car pair))
85 (setq dest (cons pair dest))
87 (setq rest (cdr rest))
90 "Alist MIME CHARSET vs CODING-SYSTEM.
91 MIME CHARSET and CODING-SYSTEM must be symbol.")
93 (defsubst mime-charset-to-coding-system (charset &optional lbt)
94 "Return coding-system corresponding with CHARSET.
95 CHARSET is a symbol whose name is MIME charset.
96 If optional argument LBT (`unix', `dos' or `mac') is specified, it is
97 used as line break code type of coding-system."
99 (setq charset (intern (downcase charset)))
101 (let ((ret (assq charset mime-charset-coding-system-alist)))
103 (setq charset (cdr ret))
106 (setq charset (intern (format "%s-%s" charset lbt)))
108 (if (find-coding-system charset)
111 (defsubst encode-mime-charset-region (start end charset)
112 "Encode the text between START and END as MIME CHARSET."
113 (let ((cs (mime-charset-to-coding-system charset)))
115 (encode-coding-region start end cs)
118 (defsubst decode-mime-charset-region (start end charset)
119 "Decode the text between START and END as MIME CHARSET."
120 (let ((cs (mime-charset-to-coding-system charset)))
122 (decode-coding-region start end cs)
125 (defsubst encode-mime-charset-string (string charset)
126 "Encode the STRING as MIME CHARSET."
127 (let ((cs (mime-charset-to-coding-system charset)))
129 (encode-coding-string string cs)
132 (defsubst decode-mime-charset-string (string charset)
133 "Decode the STRING as MIME CHARSET."
134 (let ((cs (mime-charset-to-coding-system charset)))
136 (decode-coding-string string cs)
140 (defvar default-mime-charset 'x-ctext
141 "Default value of MIME charset used when MIME charset is not specified.
144 (defsubst detect-mime-charset-region (start end)
145 "Return MIME charset for region between START and END."
146 (charsets-to-mime-charset (find-charset-region start end)))
154 ;;; emu-20.el ends here