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 (defalias 'tl:make-overlay 'make-overlay)
58 (defalias 'tl:overlay-put 'overlay-put)
59 (defalias 'tl:overlay-buffer 'overlay-buffer)
61 (make-obsolete 'tl:make-overlay 'make-overlay)
62 (make-obsolete 'tl:overlay-put 'overlay-put)
63 (make-obsolete 'tl:overlay-buffer 'overlay-buffer)
66 (defvar mouse-button-1 [mouse-1])
67 (defvar mouse-button-2 [mouse-2])
68 (defvar mouse-button-3 [down-mouse-3])
72 (defvar mouse-button-1 nil)
73 (defvar mouse-button-2 nil)
74 (defvar mouse-button-3 nil)
82 ;; for XEmacs with MULE
84 ;; for XEmacs without MULE
87 (running-mule-merged-emacs
88 ;; for Emacs 20.1 and 20.2
92 ;; for MULE 1.* and 2.*
96 ;; for NEmacs and NEpoch
101 (require 'emu-latin1)
105 ;;; @ Mule emulating aliases
107 ;;; You should not use it.
109 (or (boundp '*noconv*)
110 (defconst *noconv* 'binary
111 "Coding-system for binary.
112 This constant is defined to emulate old MULE anything older than MULE 2.3.
113 It is obsolete, so don't use it."))
116 ;;; @ without code-conversion
119 (defalias 'insert-binary-file-contents 'insert-file-contents-as-binary)
120 (make-obsolete 'insert-binary-file-contents 'insert-file-contents-as-binary)
122 (defun-maybe insert-binary-file-contents-literally (filename
125 "Like `insert-file-contents-literally', q.v., but don't code conversion.
126 A buffer may be modified in several ways after reading into the buffer due
127 to advanced Emacs features, such as file-name-handlers, format decoding,
128 find-file-hooks, etc.
129 This function ensures that none of these modifications will take place.
131 (as-binary-input-file
132 ;; Returns list absolute file name and length of data inserted.
133 (insert-file-contents-literally filename visit beg end replace)))
139 (defun charsets-to-mime-charset (charsets)
140 "Return MIME charset from list of charset CHARSETS.
141 This function refers variable `charsets-mime-charset-alist'
142 and `default-mime-charset'."
145 (let ((rest charsets-mime-charset-alist)
147 (while (setq cell (car rest))
148 (if (catch 'not-subset
149 (let ((set1 charsets)
153 (setq obj (car set1))
155 (throw 'not-subset nil))
156 (setq set1 (cdr set1)))
158 (throw 'tag (cdr cell)))
159 (setq rest (cdr rest)))))
160 default-mime-charset)))
163 ;;; @ Emacs 20.3 emulation
166 (defmacro-maybe string-as-unibyte (string)
167 "Return a unibyte string with the same individual bytes as STRING.
168 If STRING is unibyte, the result is STRING itself.
169 \[Emacs 20.3 emulating macro]"
172 (defmacro-maybe string-as-multibyte (string)
173 "Return a multibyte string with the same individual bytes as STRING.
174 If STRING is multibyte, the result is STRING itself.
175 \[Emacs 20.3 emulating macro]"
182 (or (fboundp 'char-int)
183 (fset 'char-int (symbol-function 'identity))
185 (or (fboundp 'int-char)
186 (fset 'int-char (symbol-function 'identity))
188 (or (fboundp 'char-or-char-int-p)
189 (fset 'char-or-char-int-p (symbol-function 'integerp))
193 ;;; @ for text/richtext and text/enriched
196 (cond ((fboundp 'richtext-decode)
199 ((or running-emacs-19_29-or-later running-xemacs-19_14-or-later)
201 (autoload 'richtext-decode "richtext")
202 (or (assq 'text/richtext format-alist)
206 '("Extended MIME text/richtext format."
207 "Content-[Tt]ype:[ \t]*text/richtext"
208 richtext-decode richtext-encode t enriched-mode))
212 ;; don't have enriched.el
213 (autoload 'richtext-decode "tinyrich")
214 (autoload 'enriched-decode "tinyrich")