All fsets changed to defaliases.
[bpt/emacs.git] / lisp / emacs-lisp / lucid.el
1 ;;; lucid.el --- Emulate some Lucid Emacs functions.
2 ;; Copyright (C) 1993 Free Software Foundation, Inc.
3
4 ;; This file is part of GNU Emacs.
5
6 ;; GNU Emacs is free software; you can redistribute it and/or modify
7 ;; it under the terms of the GNU General Public License as published by
8 ;; the Free Software Foundation; either version 2, or (at your option)
9 ;; any later version.
10
11 ;; GNU Emacs is distributed in the hope that it will be useful,
12 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;; GNU General Public License for more details.
15
16 ;; You should have received a copy of the GNU General Public License
17 ;; along with GNU Emacs; see the file COPYING. If not, write to
18 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
19
20
21 (defun add-timeout (secs function object &optional resignal)
22 (run-at-time secs resignal function object))
23
24 (defun disable-timeout (timeout)
25 (cancel-timer timeout))
26
27 (defun copy-tree (tree)
28 (if (consp tree)
29 (cons (copy-tree (car tree))
30 (copy-tree (cdr tree)))
31 (if (vectorp tree)
32 (let ((new (copy-sequence tree))
33 (i (1- (length new))))
34 (while (>= i 0)
35 (aset new i (copy-tree (aref new i)))
36 (setq i (1- i)))
37 new)
38 tree)))
39
40 (defalias 'current-time-seconds 'current-time)
41
42 (defun keymap-parent (keymap)
43 (let ((tail (cdr keymap)))
44 (while (and tail (not (eq (car tail) 'keymap)))
45 (setq tail (cdr tail)))
46 tail))
47
48 (defun set-keymap-parent (keymap new-parent)
49 (let ((tail (cdr keymap)))
50 (while (and tail (cdr tail) (not (eq (car (cdr tail)) 'keymap)))
51 (setq tail (cdr tail)))
52 (if tail
53 (setcdr tail new-parent))))
54
55 (defun remove-hook (hook-var function)
56 (if (boundp 'hook-var)
57 (set hook-var (delq function (symbol-value hook-var)))))
58
59 (defun remprop (symbol prop)
60 (let ((plist (symbol-plist symbol)))
61 (while (eq (car plist) prop)
62 (setplist symbol (setq plist (cdr (cdr plist)))))
63 (while plist
64 (if (eq (nth 2 plist) prop)
65 (setcdr (cdr plist) (nthcdr 4 plist)))
66 (setq plist (cdr (cdr plist))))))
67
68 (defun map-keymap (function keymap &optional sort-first)
69 "Call FUNCTION for every binding in KEYMAP.
70 This includes bindings inherited from a parent keymap.
71 FUNCTION receives two arguments each time it is called:
72 the character (more generally, the event type) that is bound,
73 and the binding it has."
74 (if sort-first
75 (let (list)
76 (map-keymap (function (lambda (a b)
77 (setq list (cons (cons a b) list))))
78 keymap)
79 (setq list (sort list
80 (function (lambda (a b)
81 (setq a (car a) b (car b))
82 (if (integerp a)
83 (if (integerp b) (< a b)
84 t)
85 (if (integerp b) t
86 (string< a b)))))))
87 (while list
88 (funcall function (car (car list)) (cdr (car list)))
89 (setq list (cdr list))))
90 (while (consp keymap)
91 (if (consp (car keymap))
92 (funcall function (car (car keymap)) (cdr (car keymap)))
93 (if (vectorp (car keymap))
94 (let ((i (1- (length (car keymap))))
95 (vector (car keymap)))
96 (while (>= i 0)
97 (funcall function i (aref vector i))
98 (setq i (1- i))))))
99 (setq keymap (cdr keymap)))))
100
101 (defun real-path-name (name &optional default)
102 (file-truename (expand-file-name name default)))
103
104 ;; It's not clear what to return if the mouse is not in FRAME.
105 (defun read-mouse-position (frame)
106 (let ((pos (mouse-position)))
107 (if (eq (car pos) frame)
108 (cdr pos))))
109
110 (defun switch-to-other-buffer (arg)
111 "Switch to the previous buffer.
112 With a numeric arg N, switch to the Nth most recent buffer.
113 With an arg of 0, buries the current buffer at the
114 bottom of the buffer stack."
115 (interactive "p")
116 (if (eq arg 0)
117 (bury-buffer (current-buffer)))
118 (switch-to-buffer
119 (if (<= arg 1) (other-buffer (current-buffer))
120 (nth (1+ arg) (buffer-list)))))
121
122 (defalias 'find-face 'internal-find-face)
123 (defalias 'get-face 'internal-get-face)
124 (defalias 'try-face-font 'internal-try-face-font)
125 \f
126 ;; Support the Lucid names with `screen' instead of `frame'.
127
128 (defalias 'current-screen-configuration 'current-frame-configuration)
129 (defalias 'delete-screen 'delete-frame)
130 (defalias 'find-file-new-screen 'find-file-other-frame)
131 (defalias 'find-file-read-only-new-screen 'find-file-read-only-other-frame)
132 (defalias 'find-tag-new-screen 'find-tag-other-frame)
133 ;;(defalias 'focus-screen 'focus-frame)
134 (defalias 'iconify-screen 'iconify-frame)
135 (defalias 'mail-new-screen 'mail-other-frame)
136 (defalias 'make-screen-invisible 'make-frame-invisible)
137 (defalias 'make-screen-visible 'make-frame-visible)
138 ;; (defalias 'minibuffer-screen-list 'minibuffer-frame-list)
139 (defalias 'modify-screen-parameters 'modify-frame-parameters)
140 (defalias 'next-screen 'next-frame)
141 ;; (defalias 'next-multiscreen-window 'next-multiframe-window)
142 ;; (defalias 'previous-multiscreen-window 'previous-multiframe-window)
143 ;; (defalias 'redirect-screen-focus 'redirect-frame-focus)
144 (defalias 'redraw-screen 'redraw-frame)
145 ;; (defalias 'screen-char-height 'frame-char-height)
146 ;; (defalias 'screen-char-width 'frame-char-width)
147 ;; (defalias 'screen-configuration-to-register 'frame-configuration-to-register)
148 ;; (defalias 'screen-focus 'frame-focus)
149 (defalias 'screen-height 'frame-height)
150 (defalias 'screen-list 'frame-list)
151 ;; (defalias 'screen-live-p 'frame-live-p)
152 (defalias 'screen-parameters 'frame-parameters)
153 (defalias 'screen-pixel-height 'frame-pixel-height)
154 (defalias 'screen-pixel-width 'frame-pixel-width)
155 (defalias 'screen-root-window 'frame-root-window)
156 (defalias 'screen-selected-window 'frame-selected-window)
157 (defalias 'lower-screen 'lower-frame)
158 (defalias 'raise-screen 'raise-frame)
159 (defalias 'screen-visible-p 'frame-visible-p)
160 (defalias 'screen-width 'frame-width)
161 (defalias 'screenp 'framep)
162 (defalias 'select-screen 'select-frame)
163 (defalias 'selected-screen 'selected-frame)
164 ;; (defalias 'set-screen-configuration 'set-frame-configuration)
165 ;; (defalias 'set-screen-height 'set-frame-height)
166 (defalias 'set-screen-position 'set-frame-position)
167 (defalias 'set-screen-size 'set-frame-size)
168 ll (defalias 'set-screen-width 'set-frame-width)
169 (defalias 'switch-to-buffer-new-screen 'switch-to-buffer-other-frame)
170 ;; (defalias 'unfocus-screen 'unfocus-frame)
171 (defalias 'visible-screen-list 'visible-frame-list)
172 (defalias 'window-screen 'window-frame)
173 (defalias 'x-create-screen 'x-create-frame)
174 (defalias 'x-new-screen 'new-frame)
175
176 ;;; end of lucid.el