1 ;;; emu-20.el --- emu API implementation for Emacs 20 and XEmacs/mule
3 ;; Copyright (C) 1997,1998 Free Software Foundation, Inc.
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Keywords: emulation, compatibility, Mule
8 ;; This file is part of emu.
10 ;; This program is free software; you can redistribute it and/or
11 ;; modify it under the terms of the GNU General Public License as
12 ;; published by the Free Software Foundation; either version 2, or (at
13 ;; your option) any later version.
15 ;; This program is distributed in the hope that it will be useful, but
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ;; General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
27 ;; This module requires Emacs 20.0.93, XEmacs 20.3-b5 (with mule)
38 (defmacro as-binary-process (&rest body)
39 `(let (selective-display ; Disable ^M to nl translation.
40 (coding-system-for-read 'binary)
41 (coding-system-for-write 'binary))
44 (defmacro as-binary-input-file (&rest body)
45 `(let ((coding-system-for-read 'binary))
48 (defmacro as-binary-output-file (&rest body)
49 `(let ((coding-system-for-write 'binary))
52 (defun write-region-as-binary (start end filename
53 &optional append visit lockname)
54 "Like `write-region', q.v., but don't code conversion."
55 (let ((coding-system-for-read 'binary))
56 (write-region start end filename append visit lockname)
60 ;;; @@ Mule emulating aliases
62 ;;; You should not use it.
64 (defconst *noconv* 'binary
65 "Coding-system for binary.
66 This constant is defined to emulate old MULE anything older than MULE
67 2.3. It is obsolete, so don't use it.")
73 (defvar mime-charset-coding-system-alist
75 '((us-ascii . iso-8859-1)
77 (iso-2022-jp-2 . iso-2022-7bit-ss2)
82 (let ((pair (car rest)))
83 (or (find-coding-system (car pair))
84 (setq dest (cons pair dest))
86 (setq rest (cdr rest))
89 "Alist MIME CHARSET vs CODING-SYSTEM.
90 MIME CHARSET and CODING-SYSTEM must be symbol.")
92 (defsubst mime-charset-to-coding-system (charset &optional lbt)
93 "Return coding-system corresponding with CHARSET.
94 CHARSET is a symbol whose name is MIME charset.
95 If optional argument LBT (`unix', `dos' or `mac') is specified, it is
96 used as line break code type of coding-system."
98 (setq charset (intern (downcase charset)))
100 (let ((ret (assq charset mime-charset-coding-system-alist)))
102 (setq charset (cdr ret))
105 (setq charset (intern (format "%s-%s" charset lbt)))
107 (if (find-coding-system charset)
110 (defsubst mime-charset-list ()
111 "Return a list of all existing MIME-charset."
112 (nconc (mapcar (function car) mime-charset-coding-system-alist)
113 (coding-system-list)))
116 (defvar widget-mime-charset-prompt-value-history nil
117 "History of input to `widget-mime-charset-prompt-value'.")
119 (define-widget 'mime-charset 'coding-system
123 :prompt-history 'widget-mime-charset-prompt-value-history
124 :prompt-value 'widget-mime-charset-prompt-value
125 :action 'widget-mime-charset-action)
127 (defun widget-mime-charset-prompt-value (widget prompt value unbound)
128 ;; Read mime-charset from minibuffer.
130 (completing-read (format "%s (default %s) " prompt value)
133 (list (symbol-name sym))
135 (mime-charset-list)))))
137 (defun widget-mime-charset-action (widget &optional event)
138 ;; Read a mime-charset from the minibuffer.
140 (widget-mime-charset-prompt-value
142 (widget-apply widget :menu-tag-get)
143 (widget-value widget)
145 (widget-value-set widget answer)
146 (widget-apply widget :notify widget event)
149 (defcustom default-mime-charset 'x-ctext
150 "Default value of MIME-charset.
151 It is used when MIME-charset is not specified.
156 (defsubst detect-mime-charset-region (start end)
157 "Return MIME charset for region between START and END."
158 (charsets-to-mime-charset (find-charset-region start end)))
166 ;;; emu-20.el ends here