comparison lisp/tl/emu.el @ 8:4b173ad71786 r19-15b5

Import from CVS: tag r19-15b5
author cvs
date Mon, 13 Aug 2007 08:47:35 +0200
parents b82b59fe008d
children 8fc7fe29b841
comparison
equal deleted inserted replaced
7:c153ca296910 8:4b173ad71786
1 ;;; emu.el --- Emulation module for each Emacs variants 1 ;;; emu.el --- Emulation module for each Emacs variants
2 2
3 ;; Copyright (C) 1995,1996 Free Software Foundation, Inc. 3 ;; Copyright (C) 1995,1996 Free Software Foundation, Inc.
4 4
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp> 5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Version: $Id: emu.el,v 1.1.1.1 1996/12/18 03:55:31 steve Exp $ 6 ;; Version: $Id: emu.el,v 1.2 1996/12/22 00:29:31 steve Exp $
7 ;; Keywords: emulation, compatibility, NEmacs, MULE, XEmacs 7 ;; Keywords: emulation, compatibility, NEmacs, MULE, Emacs/mule, XEmacs
8 8
9 ;; This file is part of tl (Tiny Library). 9 ;; This file is part of emu.
10 10
11 ;; This program is free software; you can redistribute it and/or 11 ;; This program is free software; you can redistribute it and/or
12 ;; modify it under the terms of the GNU General Public License as 12 ;; modify it under the terms of the GNU General Public License as
13 ;; published by the Free Software Foundation; either version 2, or (at 13 ;; published by the Free Software Foundation; either version 2, or (at
14 ;; your option) any later version. 14 ;; your option) any later version.
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the 22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, 23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA. 24 ;; Boston, MA 02111-1307, USA.
25 25
26 ;;; Code: 26 ;;; Code:
27
28 (defmacro defun-maybe (name &rest everything-else)
29 (or (and (fboundp name)
30 (not (get name 'defun-maybe))
31 )
32 (` (or (fboundp (quote (, name)))
33 (progn
34 (defun (, name) (,@ everything-else))
35 (put (quote (, name)) 'defun-maybe t)
36 ))
37 )))
38
39 (put 'defun-maybe 'lisp-indent-function 'defun)
40
27 41
28 (or (boundp 'emacs-major-version) 42 (or (boundp 'emacs-major-version)
29 (defconst emacs-major-version (string-to-int emacs-version))) 43 (defconst emacs-major-version (string-to-int emacs-version)))
30 (or (boundp 'emacs-minor-version) 44 (or (boundp 'emacs-minor-version)
31 (defconst emacs-minor-version 45 (defconst emacs-minor-version
128 ;;; 142 ;;;
129 143
130 (defvar path-separator ":" 144 (defvar path-separator ":"
131 "Character used to separate concatenated paths.") 145 "Character used to separate concatenated paths.")
132 146
133 (or (fboundp 'buffer-substring-no-properties) 147 (defun-maybe buffer-substring-no-properties (beg end)
134 (defun buffer-substring-no-properties (beg end) 148 "Return the text from BEG to END, without text properties, as a string.
135 "Return the text from BEG to END, without text properties, as a string.
136 \[emu.el; EMACS 19.29 emulating function]" 149 \[emu.el; EMACS 19.29 emulating function]"
137 (let ((string (buffer-substring beg end))) 150 (let ((string (buffer-substring beg end)))
138 (tl:set-text-properties 0 (length string) nil string) 151 (tl:set-text-properties 0 (length string) nil string)
139 string)) 152 string))
140 ) 153
154 (defun-maybe match-string (num &optional string)
155 "Return string of text matched by last search.
156 NUM specifies which parenthesized expression in the last regexp.
157 Value is nil if NUMth pair didn't match, or there were less than NUM pairs.
158 Zero means the entire text matched by the whole regexp or whole string.
159 STRING should be given if the last search was by `string-match' on STRING.
160 \[emu.el; EMACS 19.29 emulating function]"
161 (if (match-beginning num)
162 (if string
163 (substring string (match-beginning num) (match-end num))
164 (buffer-substring (match-beginning num) (match-end num)))))
141 165
142 (or running-emacs-19_29-or-later 166 (or running-emacs-19_29-or-later
143 running-xemacs 167 running-xemacs
144 ;; for Emacs 19.28 or earlier 168 ;; for Emacs 19.28 or earlier
145 (fboundp 'si:read-string) 169 (fboundp 'si:read-string)
153 See `read-from-minibuffer' for details of HISTORY argument." 177 See `read-from-minibuffer' for details of HISTORY argument."
154 (si:read-string prompt initial-input) 178 (si:read-string prompt initial-input)
155 ) 179 )
156 )) 180 ))
157 181
158 (or (fboundp 'add-to-list) 182 ;; This function was imported Emacs 19.30.
159 ;; This function was imported Emacs 19.30. 183 (defun-maybe add-to-list (list-var element)
160 (defun add-to-list (list-var element) 184 "Add to the value of LIST-VAR the element ELEMENT if it isn't there yet.
161 "Add to the value of LIST-VAR the element ELEMENT if it isn't there yet.
162 If you want to use `add-to-list' on a variable that is not defined 185 If you want to use `add-to-list' on a variable that is not defined
163 until a certain package is loaded, you should put the call to `add-to-list' 186 until a certain package is loaded, you should put the call to `add-to-list'
164 into a hook function that will be run only after loading the package. 187 into a hook function that will be run only after loading the package.
165 \[emu.el; EMACS 19.30 emulating function]" 188 \[emu.el; EMACS 19.30 emulating function]"
166 (or (member element (symbol-value list-var)) 189 (or (member element (symbol-value list-var))
167 (set list-var (cons element (symbol-value list-var))))) 190 (set list-var (cons element (symbol-value list-var)))
168 ) 191 ))
169 192
170 193
171 ;;; @ EMACS 19.30 emulation 194 ;;; @ EMACS 19.30 emulation
172 ;;; 195 ;;;
173 196
192 215
193 216
194 ;;; @ EMACS 19.31 emulation 217 ;;; @ EMACS 19.31 emulation
195 ;;; 218 ;;;
196 219
197 (or (fboundp 'buffer-live-p) 220 (defun-maybe buffer-live-p (object)
198 (defun buffer-live-p (object) 221 "Return non-nil if OBJECT is a buffer which has not been killed.
199 "Return non-nil if OBJECT is a buffer which has not been killed.
200 Value is nil if OBJECT is not a buffer or if it has been killed. 222 Value is nil if OBJECT is not a buffer or if it has been killed.
201 \[emu.el; EMACS 19.31 emulating function]" 223 \[emu.el; EMACS 19.31 emulating function]"
202 (and object 224 (and object
203 (get-buffer object) 225 (get-buffer object)
204 (buffer-name (get-buffer object)) 226 (buffer-name (get-buffer object))
205 )) 227 ))
206 )
207 228
208 (or (fboundp 'save-selected-window) 229 (or (fboundp 'save-selected-window)
209 ;; This function was imported Emacs 19.33. 230 ;; This function was imported Emacs 19.33.
210 (defmacro save-selected-window (&rest body) 231 (defmacro save-selected-window (&rest body)
211 "Execute BODY, then select the window that was selected before BODY. 232 "Execute BODY, then select the window that was selected before BODY.
219 240
220 241
221 ;;; @ XEmacs emulation 242 ;;; @ XEmacs emulation
222 ;;; 243 ;;;
223 244
224 (or (fboundp 'functionp) 245 (defun-maybe functionp (obj)
225 (defun functionp (obj) 246 "Returns t if OBJ is a function, nil otherwise.
226 "Returns t if OBJ is a function, nil otherwise.
227 \[emu.el; XEmacs emulating function]" 247 \[emu.el; XEmacs emulating function]"
228 (or (subrp obj) 248 (or (subrp obj)
229 (byte-code-function-p obj) 249 (byte-code-function-p obj)
230 (and (symbolp obj)(fboundp obj)) 250 (and (symbolp obj)(fboundp obj))
231 (and (consp obj)(eq (car obj) 'lambda)) 251 (and (consp obj)(eq (car obj) 'lambda))
232 )) 252 ))
233 ) 253
234
235 254
236 ;;; @ for XEmacs 20 255 ;;; @ for XEmacs 20
237 ;;; 256 ;;;
238 257
239 (or (fboundp 'char-int) 258 (or (fboundp 'char-int)