1 ;;; emu.el --- Emulation module for each Emacs variants
3 ;; Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc.
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Keywords: emulation, compatibility, NEmacs, MULE, Emacs/mule, XEmacs
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.
29 (defvar running-emacs-18 (<= emacs-major-version 18))
30 (defvar running-xemacs (featurep 'xemacs))
32 (defvar running-mule-merged-emacs (and (not (boundp 'MULE))
33 (not running-xemacs) (featurep 'mule)))
34 (defvar running-xemacs-with-mule (and running-xemacs (featurep 'mule)))
36 (defvar running-emacs-19 (and (not running-xemacs) (= emacs-major-version 19)))
37 (defvar running-emacs-19_29-or-later
38 (or (and running-emacs-19 (>= emacs-minor-version 29))
39 (and (not running-xemacs)(>= emacs-major-version 20))))
41 (defvar running-xemacs-19 (and running-xemacs
42 (= emacs-major-version 19)))
43 (defvar running-xemacs-20-or-later (and running-xemacs
44 (>= emacs-major-version 20)))
45 (defvar running-xemacs-19_14-or-later
46 (or (and running-xemacs-19 (>= emacs-minor-version 14))
47 running-xemacs-20-or-later))
51 (defvar mouse-button-1 'button1)
52 (defvar mouse-button-2 'button2)
53 (defvar mouse-button-3 'button3)
55 ((>= emacs-major-version 19)
57 (defvar mouse-button-1 [mouse-1])
58 (defvar mouse-button-2 [mouse-2])
59 (defvar mouse-button-3 [down-mouse-3])
63 (defvar mouse-button-1 nil)
64 (defvar mouse-button-2 nil)
65 (defvar mouse-button-3 nil)
69 (unless (fboundp 'tl:make-overlay)
70 (defalias 'tl:make-overlay 'make-overlay)
71 (make-obsolete 'tl:make-overlay 'make-overlay)
73 (unless (fboundp 'tl:overlay-put)
74 (defalias 'tl:overlay-put 'overlay-put)
75 (make-obsolete 'tl:overlay-put 'overlay-put)
77 (unless (fboundp 'tl:overlay-put)
78 (defalias 'tl:overlay-buffer 'overlay-buffer)
79 (make-obsolete 'tl:overlay-buffer 'overlay-buffer)
85 (cond ((featurep 'mule)
86 (cond ((featurep 'xemacs) ; for XEmacs with MULE
87 ;; old Mule emulating aliases
89 ;;(defalias 'char-leading-char 'char-charset)
91 (defun char-category (character)
92 "Return string of category mnemonics for CHAR in TABLE.
93 CHAR can be any multilingual character
94 TABLE defaults to the current buffer's category table."
95 (mapconcat (lambda (chr)
96 (char-to-string (int-char chr)))
97 (char-category-list character)
100 ((>= emacs-major-version 20) ; for Emacs 20
101 (defalias 'insert-binary-file-contents-literally
102 'insert-file-contents-literally)
104 ;; old Mule emulating aliases
105 (defun char-category (character)
106 "Return string of category mnemonics for CHAR in TABLE.
107 CHAR can be any multilingual character
108 TABLE defaults to the current buffer's category table."
109 (category-set-mnemonics (char-category-set character)))
111 (t ; for MULE 1.* and 2.*
116 ;; for NEmacs and NEpoch
118 ;; old MULE emulation
119 (defconst *noconv* 0)
123 (defconst *internal* 3)
124 (defconst *euc-japan* 3)
126 (defun code-convert-string (str ic oc)
127 "Convert code in STRING from SOURCE code to TARGET code,
128 On successful converion, returns the result string,
129 else returns nil. [emu-nemacs.el; Mule emulating function]"
131 (convert-string-kanji-code str ic oc)
134 (defun code-convert-region (beg end ic oc)
135 "Convert code of the text between BEGIN and END from SOURCE
136 to TARGET. On successful conversion returns t,
137 else returns nil. [emu-nemacs.el; Mule emulating function]"
141 (narrow-to-region beg end)
142 (convert-region-kanji-code beg end ic oc)))
146 ;; for Emacs 19 and XEmacs without MULE
148 ;; old MULE emulation
149 (defconst *internal* nil)
150 (defconst *ctext* nil)
151 (defconst *noconv* nil)
153 (defun code-convert-string (str ic oc)
154 "Convert code in STRING from SOURCE code to TARGET code,
155 On successful converion, returns the result string,
156 else returns nil. [emu-latin1.el; old MULE emulating function]"
159 (defun code-convert-region (beg end ic oc)
160 "Convert code of the text between BEGIN and END from SOURCE
161 to TARGET. On successful conversion returns t,
162 else returns nil. [emu-latin1.el; old MULE emulating function]"
167 ;;; @ Mule emulating aliases
169 ;;; You should not use it.
171 (or (boundp '*noconv*)
172 (defconst *noconv* 'binary
173 "Coding-system for binary.
174 This constant is defined to emulate old MULE anything older than MULE 2.3.
175 It is obsolete, so don't use it."))
178 ;;; @ without code-conversion
181 (defalias 'insert-binary-file-contents 'insert-file-contents-as-binary)
182 (make-obsolete 'insert-binary-file-contents 'insert-file-contents-as-binary)
184 (defun-maybe insert-binary-file-contents-literally (filename
187 "Like `insert-file-contents-literally', q.v., but don't code conversion.
188 A buffer may be modified in several ways after reading into the buffer due
189 to advanced Emacs features, such as file-name-handlers, format decoding,
190 find-file-hooks, etc.
191 This function ensures that none of these modifications will take place.
193 (as-binary-input-file
194 ;; Returns list absolute file name and length of data inserted.
195 (insert-file-contents-literally filename visit beg end replace)))
198 ;;; @ for text/richtext and text/enriched
201 (cond ((fboundp 'richtext-decode)
204 ((or running-emacs-19_29-or-later running-xemacs-19_14-or-later)
206 (autoload 'richtext-decode "richtext")
207 (or (assq 'text/richtext format-alist)
211 '("Extended MIME text/richtext format."
212 "Content-[Tt]ype:[ \t]*text/richtext"
213 richtext-decode richtext-encode t enriched-mode))
217 ;; don't have enriched.el
218 (autoload 'richtext-decode "tinyrich")
219 (autoload 'enriched-decode "tinyrich")