tm 7.57.
[elisp/apel.git] / emu.el
1 ;;;
2 ;;; emu.el --- Emulation module for each Emacs variants
3 ;;;
4 ;;; Copyright (C) 1995 Free Software Foundation, Inc.
5 ;;; Copyright (C) 1995,1996 MORIOKA Tomohiko
6 ;;;
7 ;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;;; modified by KOBAYASHI Shuhei <shuhei-k@jaist.ac.jp>
9 ;;; Version:
10 ;;;     $Id: emu.el,v 7.13 1996/05/07 17:50:26 morioka Exp $
11 ;;; Keywords: emulation, compatibility, NEmacs, Mule, XEmacs
12 ;;;
13 ;;; This file is part of tl (Tiny Library).
14 ;;;
15 ;;; This program is free software; you can redistribute it and/or
16 ;;; modify it under the terms of the GNU General Public License as
17 ;;; published by the Free Software Foundation; either version 2, or
18 ;;; (at your option) any later version.
19 ;;;
20 ;;; This program is distributed in the hope that it will be useful,
21 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23 ;;; General Public License for more details.
24 ;;;
25 ;;; You should have received a copy of the GNU General Public License
26 ;;; along with This program.  If not, write to the Free Software
27 ;;; Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
28 ;;;
29 ;;; Code:
30
31 (or (boundp 'emacs-major-version)
32     (defconst emacs-major-version (string-to-int emacs-version)))
33
34 (defvar running-emacs-18 (<= emacs-major-version 18))
35 (defvar running-xemacs (string-match "XEmacs" emacs-version))
36 (defvar running-xemacs-19 (and running-xemacs
37                                (= emacs-major-version 19)))
38 (defvar running-xemacs-20 (and running-xemacs
39                                (= emacs-major-version 20)))
40 (defvar running-xemacs-19_14-or-later
41   (or (and running-xemacs-19 (>= emacs-minor-version 14))
42       (>= emacs-major-version 20)))
43 (defvar running-emacs-19 (and (not running-xemacs)
44                               (= emacs-major-version 19)))
45 (defvar running-emacs-19_29-or-later
46   (or (and running-emacs-19 (>= emacs-minor-version 29))
47       (>= emacs-major-version 20)))
48
49 (cond ((boundp 'MULE)
50        (require 'emu-mule)
51        )
52       ((and running-xemacs-20 (featurep 'mule))
53        (require 'emu-x20)
54        )
55       ((boundp 'NEMACS)
56        (require 'emu-nemacs)
57        )
58       (t
59        (require 'emu-e19)
60        ))
61
62
63 ;;; @ Emacs 19.29 emulation
64 ;;;
65
66 (or (fboundp 'buffer-substring-no-properties)
67     (defun buffer-substring-no-properties (beg end)
68       "Return the text from BEG to END, without text properties, as a string."
69       (let ((string (buffer-substring beg end)))
70         (tl:set-text-properties 0 (length string) nil string)
71         string))
72     )
73
74 (cond ((or running-emacs-19_29-or-later running-xemacs)
75        ;; for Emacs 19.29 or later and XEmacs
76        (defalias 'tl:read-string 'read-string)
77        )
78       (t
79        ;; for Emacs 19.28 or earlier
80        (defun tl:read-string (prompt &optional initial-input history)
81          (read-string prompt initial-input)
82          )
83        ))
84
85
86 ;;; @ XEmacs emulation
87 ;;;
88
89 (or (fboundp 'functionp)
90     (defun functionp (obj)
91       "Returns t if OBJ is a function, nil otherwise.
92 \[emu.el; XEmacs emulating function]"
93       (or (subrp obj)
94           (byte-code-function-p obj)
95           (and (symbolp obj)(fboundp obj))
96           (and (consp obj)(eq (car obj) 'lambda))
97           ))
98     )
99         
100
101 ;;; @ for XEmacs 20
102 ;;;
103
104 (or (fboundp 'char-int)
105     (fset 'char-int (symbol-function 'identity))
106     )
107 (or (fboundp 'int-char)
108     (fset 'int-char (symbol-function 'identity))
109     )
110
111
112 ;;; @ for text/richtext and text/enriched
113 ;;;
114
115 (cond ((or running-emacs-19_29-or-later running-xemacs-19_14-or-later)
116        ;; have enriched.el
117        (autoload 'richtext-decode "richtext")
118        (or (assq 'text/richtext format-alist)
119            (setq format-alist
120                  (cons
121                   (cons 'text/richtext
122                         '("Extended MIME text/richtext format."
123                           "Content-[Tt]ype:[ \t]*text/richtext"
124                           richtext-decode richtext-encode t enriched-mode))
125                   format-alist)))
126        )
127       (t
128        ;; don't have enriched.el
129        (autoload 'richtext-decode "tinyrich")
130        (autoload 'enriched-decode "tinyrich")
131        ))
132
133
134 ;;; @ end
135 ;;;
136
137 (provide 'emu)
138
139 ;;; emu.el ends here