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.18 1997/11/04 08:36:40 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)
39 (defmacro as-binary-process (&rest body)
40 `(let (selective-display ; Disable ^M to nl translation.
41 (coding-system-for-read 'binary)
42 (coding-system-for-write 'binary))
45 (defmacro as-binary-input-file (&rest body)
46 `(let ((coding-system-for-read 'binary))
49 (defmacro as-binary-output-file (&rest body)
50 `(let ((coding-system-for-write 'binary))
53 (defun insert-binary-file-contents-literally
54 (filename &optional visit beg end replace)
55 "Like `insert-file-contents-literally', q.v., but don't code conversion.
56 A buffer may be modified in several ways after reading into the buffer due
57 to advanced Emacs features, such as file-name-handlers, format decoding,
59 This function ensures that none of these modifications will take place."
60 (let ((coding-system-for-read 'binary))
61 (insert-file-contents-literally filename visit beg end replace)
64 ;;; @@ Mule emulating aliases
66 ;;; You should not use it.
68 (defconst *noconv* 'binary
69 "Coding-system for binary.
70 This constant is defined to emulate old MULE anything older than MULE
71 2.3. It is obsolete, so don't use it.")
77 (defvar mime-charset-coding-system-alist
79 '((us-ascii . iso-8859-1)
81 (iso-2022-jp-2 . iso-2022-7bit-ss2)
86 (let ((pair (car rest)))
87 (or (find-coding-system (car pair))
88 (setq dest (cons pair dest))
90 (setq rest (cdr rest))
93 "Alist MIME CHARSET vs CODING-SYSTEM.
94 MIME CHARSET and CODING-SYSTEM must be symbol.")
96 (defsubst mime-charset-to-coding-system (charset &optional lbt)
97 "Return coding-system corresponding with CHARSET.
98 CHARSET is a symbol whose name is MIME charset.
99 If optional argument LBT (`unix', `dos' or `mac') is specified, it is
100 used as line break code type of coding-system."
101 (if (stringp charset)
102 (setq charset (intern (downcase charset)))
104 (let ((ret (assq charset mime-charset-coding-system-alist)))
106 (setq charset (cdr ret))
109 (setq charset (intern (format "%s-%s" charset lbt)))
111 (if (find-coding-system charset)
114 (defsubst mime-charset-list ()
115 "Return a list of all existing MIME-charset."
116 (nconc (mapcar (function car) mime-charset-coding-system-alist)
117 (coding-system-list)))
120 (defvar widget-mime-charset-prompt-value-history nil
121 "History of input to `widget-mime-charset-prompt-value'.")
123 (define-widget 'mime-charset 'coding-system
127 :prompt-history 'widget-mime-charset-prompt-value-history
128 :prompt-value 'widget-mime-charset-prompt-value
129 :action 'widget-mime-charset-action)
131 (defun widget-mime-charset-prompt-value (widget prompt value unbound)
132 ;; Read mime-charset from minibuffer.
134 (completing-read (format "%s (default %s) " prompt value)
137 (list (symbol-name sym))
139 (mime-charset-list)))))
141 (defun widget-mime-charset-action (widget &optional event)
142 ;; Read a mime-charset from the minibuffer.
144 (widget-mime-charset-prompt-value
146 (widget-apply widget :menu-tag-get)
147 (widget-value widget)
149 (widget-value-set widget answer)
150 (widget-apply widget :notify widget event)
153 (defcustom default-mime-charset 'x-ctext
154 "Default value of MIME-charset.
155 It is used when MIME-charset is not specified.
160 (defsubst detect-mime-charset-region (start end)
161 "Return MIME charset for region between START and END."
162 (charsets-to-mime-charset (find-charset-region start end)))
170 ;;; emu-20.el ends here