2 ;;; emu.el --- Emulation module for each Emacs variants
4 ;;; Copyright (C) 1995 Free Software Foundation, Inc.
5 ;;; Copyright (C) 1995,1996 MORIOKA Tomohiko
7 ;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;;; modified by KOBAYASHI Shuhei <shuhei-k@jaist.ac.jp>
10 ;;; $Id: emu.el,v 7.17 1996/07/03 06:27:10 morioka Exp $
11 ;;; Keywords: emulation, compatibility, NEmacs, Mule, XEmacs
13 ;;; This file is part of tl (Tiny Library).
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.
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.
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.
31 (or (boundp 'emacs-major-version)
32 (defconst emacs-major-version (string-to-int emacs-version)))
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-20-or-later (and running-xemacs
41 (>= emacs-major-version 20)))
42 (defvar running-xemacs-19_14-or-later
43 (or (and running-xemacs-19 (>= emacs-minor-version 14))
44 running-xemacs-20-or-later))
45 (defvar running-emacs-19 (and (not running-xemacs)
46 (= emacs-major-version 19)))
47 (defvar running-emacs-19_29-or-later
48 (or (and running-emacs-19 (>= emacs-minor-version 29))
49 (and (not running-xemacs)(>= emacs-major-version 20))))
54 ((and running-xemacs-20 (featurep 'mule))
65 ;;; @ Emacs 19.29 emulation
68 (or (fboundp 'buffer-substring-no-properties)
69 (defun buffer-substring-no-properties (beg end)
70 "Return the text from BEG to END, without text properties, as a string."
71 (let ((string (buffer-substring beg end)))
72 (tl:set-text-properties 0 (length string) nil string)
76 (cond ((or running-emacs-19_29-or-later running-xemacs)
77 ;; for Emacs 19.29 or later and XEmacs
78 (defalias 'tl:read-string 'read-string)
81 ;; for Emacs 19.28 or earlier
82 (defun tl:read-string (prompt &optional initial-input history)
83 (read-string prompt initial-input)
87 (or (fboundp 'add-to-list)
88 ;; This function was imported Emacs 19.30.
89 (defun add-to-list (list-var element)
90 "Add to the value of LIST-VAR the element ELEMENT if it isn't there yet.
91 If you want to use `add-to-list' on a variable that is not defined
92 until a certain package is loaded, you should put the call to `add-to-list'
93 into a hook function that will be run only after loading the package.
94 \[emu.el; Emacs 19.30 emulating function]"
95 (or (member element (symbol-value list-var))
96 (set list-var (cons element (symbol-value list-var)))))
100 ;;; @ XEmacs emulation
103 (or (fboundp 'functionp)
104 (defun functionp (obj)
105 "Returns t if OBJ is a function, nil otherwise.
106 \[emu.el; XEmacs emulating function]"
108 (byte-code-function-p obj)
109 (and (symbolp obj)(fboundp obj))
110 (and (consp obj)(eq (car obj) 'lambda))
118 (or (fboundp 'char-int)
119 (fset 'char-int (symbol-function 'identity))
121 (or (fboundp 'int-char)
122 (fset 'int-char (symbol-function 'identity))
126 ;;; @ for text/richtext and text/enriched
129 (cond ((or running-emacs-19_29-or-later running-xemacs-19_14-or-later)
131 (autoload 'richtext-decode "richtext")
132 (or (assq 'text/richtext format-alist)
136 '("Extended MIME text/richtext format."
137 "Content-[Tt]ype:[ \t]*text/richtext"
138 richtext-decode richtext-encode t enriched-mode))
142 ;; don't have enriched.el
143 (autoload 'richtext-decode "tinyrich")
144 (autoload 'enriched-decode "tinyrich")