Modify conditions to load sub-modules.
[elisp/apel.git] / emu.el
1 ;;; emu.el --- Emulation module for each Emacs variants
2
3 ;; Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc.
4
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Keywords: emulation, compatibility, NEmacs, MULE, Emacs/mule, XEmacs
7
8 ;; This file is part of emu.
9
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.
14
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.
19
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.
24
25 ;;; Code:
26
27 (require 'poe)
28
29 (defvar running-emacs-18 (<= emacs-major-version 18))
30 (defvar running-xemacs (featurep 'xemacs))
31
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)))
35
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))))
40
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))
48
49 (cond (running-xemacs
50        ;; for XEmacs
51        (defvar mouse-button-1 'button1)
52        (defvar mouse-button-2 'button2)
53        (defvar mouse-button-3 'button3)
54        )
55       ((>= emacs-major-version 19)
56        ;; for tm-7.106
57        (defalias 'tl:make-overlay 'make-overlay)
58        (defalias 'tl:overlay-put 'overlay-put)
59        (defalias 'tl:overlay-buffer 'overlay-buffer)
60        
61        (make-obsolete 'tl:make-overlay 'make-overlay)
62        (make-obsolete 'tl:overlay-put 'overlay-put)
63        (make-obsolete 'tl:overlay-buffer 'overlay-buffer)
64        
65        ;; mouse
66        (defvar mouse-button-1 [mouse-1])
67        (defvar mouse-button-2 [mouse-2])
68        (defvar mouse-button-3 [down-mouse-3])
69        )
70       (t
71        ;; mouse
72        (defvar mouse-button-1 nil)
73        (defvar mouse-button-2 nil)
74        (defvar mouse-button-3 nil)
75        ))
76
77 (require 'poem)
78 (require 'mcharset)
79
80 (cond ((featurep 'mule)
81        (cond ((featurep 'xemacs)
82               ;; for XEmacs with MULE
83               (require 'emu-x20)
84               )
85              ((>= emacs-major-version 20)
86               ;; for Emacs 20
87               (require 'emu-e20)
88               (defalias 'insert-binary-file-contents-literally
89                 'insert-file-contents-literally)
90               )
91              (t
92               ;; for MULE 1.* and 2.*
93               (require 'emu-mule)
94               ))
95        )
96       ((boundp 'NEMACS)
97        ;; for NEmacs and NEpoch
98        (require 'emu-nemacs)
99        )
100       (t
101        ;; for Emacs 19 and XEmacs without MULE
102        (require 'emu-latin1)
103        ))
104
105
106 ;;; @ Mule emulating aliases
107 ;;;
108 ;;; You should not use it.
109
110 (or (boundp '*noconv*)
111     (defconst *noconv* 'binary
112       "Coding-system for binary.
113 This constant is defined to emulate old MULE anything older than MULE 2.3.
114 It is obsolete, so don't use it."))
115
116
117 ;;; @ without code-conversion
118 ;;;
119
120 (defalias 'insert-binary-file-contents 'insert-file-contents-as-binary)
121 (make-obsolete 'insert-binary-file-contents 'insert-file-contents-as-binary)
122
123 (defun-maybe insert-binary-file-contents-literally (filename
124                                                     &optional visit
125                                                     beg end replace)
126   "Like `insert-file-contents-literally', q.v., but don't code conversion.
127 A buffer may be modified in several ways after reading into the buffer due
128 to advanced Emacs features, such as file-name-handlers, format decoding,
129 find-file-hooks, etc.
130   This function ensures that none of these modifications will take place.
131 \[emu-nemacs.el]"
132   (as-binary-input-file
133    ;; Returns list absolute file name and length of data inserted.
134    (insert-file-contents-literally filename visit beg end replace)))
135
136
137 ;;; @ for text/richtext and text/enriched
138 ;;;
139
140 (cond ((fboundp 'richtext-decode)
141        ;; have richtext.el
142        )
143       ((or running-emacs-19_29-or-later running-xemacs-19_14-or-later)
144        ;; have enriched.el
145        (autoload 'richtext-decode "richtext")
146        (or (assq 'text/richtext format-alist)
147            (setq format-alist
148                  (cons
149                   (cons 'text/richtext
150                         '("Extended MIME text/richtext format."
151                           "Content-[Tt]ype:[ \t]*text/richtext"
152                           richtext-decode richtext-encode t enriched-mode))
153                   format-alist)))
154        )
155       (t
156        ;; don't have enriched.el
157        (autoload 'richtext-decode "tinyrich")
158        (autoload 'enriched-decode "tinyrich")
159        ))
160
161
162 ;;; @ end
163 ;;;
164
165 (provide 'emu)
166
167 ;;; emu.el ends here