Move alias `insert-binary-file-contents-literally' from emu.el to
[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 (running-xemacs
81        (if (featurep 'mule)
82            ;; for XEmacs with MULE
83            (require 'emu-x20)
84          ;; for XEmacs without MULE
85          (require 'emu-latin1)
86          ))
87       (running-mule-merged-emacs
88        ;; for Emacs 20.1 and 20.2
89        (require 'emu-e20)
90        (defalias 'insert-binary-file-contents-literally
91          'insert-file-contents-literally)
92        )
93       ((boundp 'MULE)
94        ;; for MULE 1.* and 2.*
95        (require 'emu-mule)
96        )
97       ((boundp 'NEMACS)
98        ;; for NEmacs and NEpoch
99        (require 'emu-nemacs)
100        )
101       (t
102        ;; for Emacs 19
103        (require 'emu-latin1)
104        ))
105
106
107 ;;; @ Mule emulating aliases
108 ;;;
109 ;;; You should not use it.
110
111 (or (boundp '*noconv*)
112     (defconst *noconv* 'binary
113       "Coding-system for binary.
114 This constant is defined to emulate old MULE anything older than MULE 2.3.
115 It is obsolete, so don't use it."))
116
117
118 ;;; @ without code-conversion
119 ;;;
120
121 (defalias 'insert-binary-file-contents 'insert-file-contents-as-binary)
122 (make-obsolete 'insert-binary-file-contents 'insert-file-contents-as-binary)
123
124 (defun-maybe insert-binary-file-contents-literally (filename
125                                                     &optional visit
126                                                     beg end replace)
127   "Like `insert-file-contents-literally', q.v., but don't code conversion.
128 A buffer may be modified in several ways after reading into the buffer due
129 to advanced Emacs features, such as file-name-handlers, format decoding,
130 find-file-hooks, etc.
131   This function ensures that none of these modifications will take place.
132 \[emu-nemacs.el]"
133   (as-binary-input-file
134    ;; Returns list absolute file name and length of data inserted.
135    (insert-file-contents-literally filename visit beg end replace)))
136
137
138 ;;; @ for text/richtext and text/enriched
139 ;;;
140
141 (cond ((fboundp 'richtext-decode)
142        ;; have richtext.el
143        )
144       ((or running-emacs-19_29-or-later running-xemacs-19_14-or-later)
145        ;; have enriched.el
146        (autoload 'richtext-decode "richtext")
147        (or (assq 'text/richtext format-alist)
148            (setq format-alist
149                  (cons
150                   (cons 'text/richtext
151                         '("Extended MIME text/richtext format."
152                           "Content-[Tt]ype:[ \t]*text/richtext"
153                           richtext-decode richtext-encode t enriched-mode))
154                   format-alist)))
155        )
156       (t
157        ;; don't have enriched.el
158        (autoload 'richtext-decode "tinyrich")
159        (autoload 'enriched-decode "tinyrich")
160        ))
161
162
163 ;;; @ end
164 ;;;
165
166 (provide 'emu)
167
168 ;;; emu.el ends here