1 ;;; obsolete.el --- obsoleteness support
3 ;; Copyright (C) 1985-1994, 1997 Free Software Foundation, Inc.
4 ;; Copyright (C) 1994, 1995 Amdahl Corporation.
5 ;; Copyright (C) 1995 Sun Microsystems.
7 ;; Maintainer: XEmacs Development Team
8 ;; Keywords: internal, dumped
10 ;; This file is part of XEmacs.
12 ;; XEmacs is free software; you can redistribute it and/or modify it
13 ;; under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; XEmacs is distributed in the hope that it will be useful, but
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 ;; General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with XEmacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
27 ;;; Synched up with: Not in FSF.
31 ;; This file is dumped with XEmacs.
33 ;; The obsoleteness support used to be scattered throughout various
34 ;; source files. We put the stuff in one place to remove the junkiness
35 ;; from other source files and to facilitate creating/updating things
40 (defsubst define-obsolete-function-alias (oldfun newfun)
41 "Define OLDFUN as an obsolete alias for function NEWFUN.
42 This makes calling OLDFUN equivalent to calling NEWFUN and marks OLDFUN
44 (define-function oldfun newfun)
45 (make-obsolete oldfun newfun))
47 (defsubst define-compatible-function-alias (oldfun newfun)
48 "Define OLDFUN as a compatible alias for function NEWFUN.
49 This makes calling OLDFUN equivalent to calling NEWFUN and marks OLDFUN
50 as provided for compatibility only."
51 (define-function oldfun newfun)
52 (make-compatible oldfun newfun))
54 (defsubst define-obsolete-variable-alias (oldvar newvar)
55 "Define OLDVAR as an obsolete alias for variable NEWVAR.
56 This makes referencing or setting OLDVAR equivalent to referencing or
57 setting NEWVAR and marks OLDVAR as obsolete.
58 If OLDVAR was bound and NEWVAR was not, Set NEWVAR to OLDVAR.
60 Note: Use this before any other references (defvar/defcustom) to NEWVAR."
61 (let ((needs-setting (and (boundp oldvar) (not (boundp newvar))))
62 (value (and (boundp oldvar) (symbol-value oldvar))))
63 (defvaralias oldvar newvar)
64 (make-obsolete-variable oldvar newvar)
65 (and needs-setting (set newvar value))))
67 (defsubst define-compatible-variable-alias (oldvar newvar)
68 "Define OLDVAR as a compatible alias for variable NEWVAR.
69 This makes referencing or setting OLDVAR equivalent to referencing or
70 setting NEWVAR and marks OLDVAR as provided for compatibility only."
71 (defvaralias oldvar newvar)
72 (make-compatible-variable oldvar newvar))
74 ;;;;;;;;;;;;;;;;;;;;;;;;;;;; device stuff
76 (make-compatible-variable 'window-system "use (console-type)")
78 (defun x-display-color-p (&optional device)
79 "Return t if DEVICE is a color device."
80 (eq 'color (device-class device)))
81 (make-compatible 'x-display-color-p 'device-class)
83 (define-function 'x-color-display-p 'x-display-color-p)
84 (make-compatible 'x-display-color-p 'device-class)
86 (defun x-display-grayscale-p (&optional device)
87 "Return t if DEVICE is a grayscale device."
88 (eq 'grayscale (device-class device)))
89 (make-compatible 'x-display-grayscale-p 'device-class)
91 (define-function 'x-grayscale-display-p 'x-display-grayscale-p)
92 (make-compatible 'x-display-grayscale-p 'device-class)
94 (define-compatible-function-alias 'x-display-pixel-width 'device-pixel-width)
95 (define-compatible-function-alias 'x-display-pixel-height 'device-pixel-height)
96 (define-compatible-function-alias 'x-display-planes 'device-bitplanes)
97 (define-compatible-function-alias 'x-display-color-cells 'device-color-cells)
99 ;;;;;;;;;;;;;;;;;;;;;;;;;;;; events
101 (define-obsolete-function-alias 'menu-event-p 'misc-user-event-p)
102 (make-obsolete-variable 'unread-command-char 'unread-command-events)
104 ;;;;;;;;;;;;;;;;;;;;;;;;;;;; extents
106 (make-obsolete 'set-window-dot 'set-window-point)
108 (define-obsolete-function-alias 'extent-buffer 'extent-object)
109 (define-compatible-variable-alias 'parse-sexp-lookup-properties
110 'lookup-syntax-properties)
112 ;;;;;;;;;;;;;;;;;;;;;;;;;;;; frames
113 (defun frame-first-window (frame)
114 "Return the topmost, leftmost window of FRAME.
115 If omitted, FRAME defaults to the currently selected frame."
116 (frame-highest-window frame 0))
117 (make-compatible 'frame-first-window 'frame-highest-window)
119 (define-obsolete-variable-alias 'initial-frame-alist 'initial-frame-plist)
120 (define-obsolete-variable-alias 'minibuffer-frame-alist
121 'minibuffer-frame-plist)
122 (define-obsolete-variable-alias 'pop-up-frame-alist 'pop-up-frame-plist)
123 (define-obsolete-variable-alias 'special-display-frame-alist
124 'special-display-frame-plist)
128 (define-obsolete-variable-alias 'default-frame-alist 'default-frame-plist)
129 (define-obsolete-variable-alias 'default-x-frame-alist 'default-x-frame-plist)
130 (define-obsolete-variable-alias 'default-tty-frame-alist
131 'default-tty-frame-plist)
133 (make-compatible 'frame-parameters 'frame-property)
134 (defun frame-parameters (&optional frame)
135 "Return the parameters-alist of frame FRAME.
136 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
137 The meaningful PARMs depend on the kind of frame.
138 If FRAME is omitted, return information on the currently selected frame.
140 See the variables `default-frame-plist', `default-x-frame-plist', and
141 `default-tty-frame-plist' for a description of the parameters meaningful
142 for particular types of frames."
143 (or frame (setq frame (selected-frame)))
144 ;; #### This relies on a `copy-sequence' of the user properties in
145 ;; `frame-properties'. Removing that would make `frame-properties' more
146 ;; efficient but this function less efficient, as we couldn't be
147 ;; destructive. Since most callers now use `frame-parameters', we'll
148 ;; do it this way. Should probably change this at some point in the
150 (destructive-plist-to-alist (frame-properties frame)))
152 (make-compatible 'modify-frame-parameters 'set-frame-properties)
153 (defun modify-frame-parameters (frame alist)
154 "Modify the properties of frame FRAME according to ALIST.
155 ALIST is an alist of properties to change and their new values.
156 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
157 The meaningful PARMs depend on the kind of frame.
159 See `set-frame-properties' for built-in property names."
160 ;; it would be nice to be destructive here but that's not safe.
161 (set-frame-properties frame (alist-to-plist alist)))
163 ;;;;;;;;;;;;;;;;;;;;;;;;;;;; faces
165 (define-obsolete-function-alias 'list-faces-display 'edit-faces)
166 (define-obsolete-function-alias 'list-faces 'face-list)
168 ;;;;;;;;;;;;;;;;;;;;;;;;;;;; paths
170 (defvar Info-default-directory-list nil
171 "This used to be the initial value of Info-directory-list.
172 If you want to change the locations where XEmacs looks for info files,
173 set Info-directory-list.")
174 (make-obsolete-variable 'Info-default-directory-list 'Info-directory-list)
176 (defvar init-file-user nil
177 "This used to be the name of the user whose init file was read at startup.")
178 (make-obsolete-variable 'init-file-user 'load-user-init-file-p)
180 (define-obsolete-function-alias 'pui-add-install-directory
181 'pui-set-local-package-get-directory) ; misleading name
182 ;;;;;;;;;;;;;;;;;;;;;;;;;;;; hooks
184 (make-compatible-variable 'lisp-indent-hook 'lisp-indent-function)
185 (make-compatible-variable 'comment-indent-hook 'comment-indent-function)
186 (make-obsolete-variable 'temp-buffer-show-hook
187 'temp-buffer-show-function)
188 (make-obsolete-variable 'inhibit-local-variables
189 "use `enable-local-variables' (with the reversed sense).")
190 (make-obsolete-variable 'suspend-hooks 'suspend-hook)
191 (make-obsolete-variable 'first-change-function 'first-change-hook)
192 (make-obsolete-variable 'before-change-function
193 "use before-change-functions; which is a list of functions rather than a single function.")
194 (make-obsolete-variable 'after-change-function
195 "use after-change-functions; which is a list of functions rather than a single function.")
197 ;;;;;;;;;;;;;;;;;;;;;;;;;;;; insertion and deletion
199 (define-compatible-function-alias 'insert-and-inherit 'insert)
200 (define-compatible-function-alias 'insert-before-markers-and-inherit
201 'insert-before-markers)
203 ;;;;;;;;;;;;;;;;;;;;;;;;;;;; keymaps
205 (defun keymap-parent (keymap)
206 "Return the first parent of the given keymap."
207 (car (keymap-parents keymap)))
208 (make-compatible 'keymap-parent 'keymap-parents)
210 (defun set-keymap-parent (keymap parent)
211 "Make the given keymap have (only) the given parent."
212 (set-keymap-parents keymap (if parent (list parent) '()))
214 (make-compatible 'set-keymap-parent 'set-keymap-parents)
216 ;;;;;;;;;;;;;;;;;;;;;;;;;;;; menu stuff
218 (defun add-menu-item (menu-path item-name function enabled-p &optional before)
219 "Obsolete. See the function `add-menu-button'."
220 (or item-name (error "must specify an item name"))
221 (add-menu-button menu-path (vector item-name function enabled-p) before))
222 (make-obsolete 'add-menu-item 'add-menu-button)
224 (defun add-menu (menu-path menu-name menu-items &optional before)
225 "See the function `add-submenu'."
226 (or menu-name (error "must specify a menu name"))
227 (or menu-items (error "must specify some menu items"))
228 (add-submenu menu-path (cons menu-name menu-items) before))
229 ;; Can't make this obsolete. easymenu depends on it.
230 (make-compatible 'add-menu 'add-submenu)
232 (define-obsolete-function-alias 'package-get-download-menu
233 'package-ui-download-menu)
235 ;;;;;;;;;;;;;;;;;;;;;;;;;;;; minibuffer
237 (define-compatible-function-alias 'read-minibuffer
238 'read-expression) ; misleading name
239 (define-compatible-function-alias 'read-input 'read-string)
241 ;;;;;;;;;;;;;;;;;;;;;;;;;;;; misc
243 ;; (defun user-original-login-name ()
244 ;; "Return user's login name from original login.
245 ;; This tries to remain unaffected by `su', by looking in environment variables."
246 ;; (or (getenv "LOGNAME") (getenv "USER") (user-login-name)))
247 (define-obsolete-function-alias 'user-original-login-name 'user-login-name)
250 (define-obsolete-function-alias 'show-buffer 'set-window-buffer)
251 (define-obsolete-function-alias 'buffer-flush-undo 'buffer-disable-undo)
252 (make-compatible 'eval-current-buffer 'eval-buffer)
253 (define-compatible-function-alias 'byte-code-function-p
254 'compiled-function-p) ;FSFmacs
256 (define-obsolete-function-alias 'isearch-yank-x-selection
257 'isearch-yank-selection)
258 (define-obsolete-function-alias 'isearch-yank-x-clipboard
259 'isearch-yank-clipboard)
261 ;; too bad there's not a way to check for aref, assq, and nconc
262 ;; being called on the values of functions known to return keymaps,
263 ;; or known to return vectors of events instead of strings...
265 (make-obsolete-variable 'executing-macro 'executing-kbd-macro)
267 (define-compatible-function-alias 'interactive-form
268 'function-interactive) ;GNU 21.1
269 (define-compatible-function-alias 'assq-delete-all
272 (define-compatible-function-alias 'line-beginning-position 'point-at-bol)
273 (define-compatible-function-alias 'line-end-position 'point-at-eol)
275 ;;;;;;;;;;;;;;;;;;;;;;;;;;;; modeline
277 (define-compatible-function-alias 'redraw-mode-line 'redraw-modeline)
278 (define-compatible-function-alias 'force-mode-line-update
279 'redraw-modeline) ;; FSF compatibility
280 (define-compatible-variable-alias 'mode-line-map 'modeline-map)
281 (define-compatible-variable-alias 'mode-line-buffer-identification
282 'modeline-buffer-identification)
283 (define-compatible-variable-alias 'mode-line-process 'modeline-process)
284 (define-compatible-variable-alias 'mode-line-modified 'modeline-modified)
285 (make-compatible-variable 'mode-line-inverse-video
286 "use set-face-highlight-p and set-face-reverse-p")
287 (define-compatible-variable-alias 'default-mode-line-format
288 'default-modeline-format)
289 (define-compatible-variable-alias 'mode-line-format 'modeline-format)
290 (define-compatible-variable-alias 'mode-line-menu 'modeline-menu)
292 ;;;;;;;;;;;;;;;;;;;;;;;;;;;; mouse
294 ;;; (defun mouse-eval-last-sexpr (event)
295 ;;; (interactive "@e")
297 ;;; (mouse-set-point event)
298 ;;; (eval-last-sexp nil)))
300 (define-obsolete-function-alias 'mouse-eval-last-sexpr 'mouse-eval-sexp)
302 (defun read-mouse-position (frame)
303 (cdr (mouse-position (frame-device frame))))
304 (make-obsolete 'read-mouse-position 'mouse-position)
306 ;;;;;;;;;;;;;;;;;;;;;;;;;;;; redisplay
308 (defun redraw-display (&optional device)
310 (mapcar 'redisplay-device (device-list))
311 (redisplay-device device)))
313 ;;;;;;;;;;;;;;;;;;;;;;;;;;;; window-system objects
315 ;; the functionality of column.el has been moved into C
316 ;; Function obsoleted for XEmacs 20.0/February 1997.
317 (defalias 'display-column-mode 'column-number-mode)
319 (defun x-color-values (color &optional frame)
320 "Return a description of the color named COLOR on frame FRAME.
321 The value is a list of integer RGB values--(RED GREEN BLUE).
322 These values appear to range from 0 to 65280 or 65535, depending
323 on the system; white is (65280 65280 65280) or (65535 65535 65535).
324 If FRAME is omitted or nil, use the selected frame."
325 (color-instance-rgb-components (make-color-instance color)))
326 (make-compatible 'x-color-values 'color-instance-rgb-components)
328 ;; Two loser functions which shouldn't be used.
329 (make-obsolete 'following-char 'char-after)
330 (make-obsolete 'preceding-char 'char-before)
333 ;; The following several functions are useful in GNU Emacs 20 because
334 ;; of the multibyte "characters" the internal representation of which
335 ;; leaks into Lisp. In XEmacs/Mule they are trivial and unnecessary.
336 ;; We provide them for compatibility reasons solely.
338 (defun string-to-sequence (string type)
339 "Convert STRING to a sequence of TYPE which contains characters in STRING.
340 TYPE should be `list' or `vector'.
341 Multibyte characters are concerned."
344 (mapcar #'identity string))
346 (mapvector #'identity string))))
348 (defun string-to-list (string)
349 "Return a list of characters in STRING."
350 (mapcar #'identity string))
352 (defun string-to-vector (string)
353 "Return a vector of characters in STRING."
354 (mapvector #'identity string))
356 (defun store-substring (string idx object)
357 "Embed OBJECT (string or character) at index IDX of STRING."
358 (let* ((str (cond ((stringp object) object)
359 ((characterp object) (char-to-string object))
361 "Invalid argument (should be string or character): %s"
363 (string-len (length string))
366 (while (and (< i len) (< idx string-len))
367 (aset string idx (aref str i))
368 (setq idx (1+ idx) i (1+ i)))
371 ;; #### This function is not compatible with FSF in some cases. Hard
372 ;; to fix, because it is hard to trace the logic of the FSF function.
373 ;; In case we need the exact behavior, we can always copy the FSF
374 ;; version, which is very long and does lots of unnecessary stuff.
375 (defun truncate-string-to-width (str end-column &optional start-column padding)
376 "Truncate string STR to end at column END-COLUMN.
377 The optional 2nd arg START-COLUMN, if non-nil, specifies
378 the starting column; that means to return the characters occupying
379 columns START-COLUMN ... END-COLUMN of STR.
381 The optional 3rd arg PADDING, if non-nil, specifies a padding character
382 to add at the end of the result if STR doesn't reach column END-COLUMN,
383 or if END-COLUMN comes in the middle of a character in STR.
384 PADDING is also added at the beginning of the result
385 if column START-COLUMN appears in the middle of a character in STR.
387 If PADDING is nil, no padding is added in these cases, so
388 the resulting string may be narrower than END-COLUMN."
390 (setq start-column 0))
391 (let ((len (length str)))
392 (concat (substring str (min start-column len) (min end-column len))
393 (and padding (> end-column len)
394 (make-string (- end-column len) padding)))))
396 (defalias 'truncate-string 'truncate-string-to-width)
397 (make-obsolete 'truncate-string 'truncate-string-to-width)
399 ;; Keywords already do The Right Thing in XEmacs
400 (make-compatible 'define-widget-keywords "Just use them")
402 (make-obsolete 'function-called-at-point 'function-at-point)
404 (when (featurep 'utf-2000)
405 (make-obsolete-variable 'utf-2000-version 'xemacs-chise-version))
408 ;;; obsolete.el ends here