1 ;;; lucid.el --- Emulate some Lucid Emacs functions.
3 ;; Copyright (C) 1993, 1995 Free Software Foundation, Inc.
5 ;; This file is part of GNU Emacs.
7 ;; GNU Emacs is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; GNU Emacs is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU Emacs; see the file COPYING. If not, write to the
19 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 ;; Boston, MA 02111-1307, USA.
24 (defun add-timeout (secs function object
&optional resignal
)
25 (run-at-time secs resignal function object
))
27 (defun disable-timeout (timeout)
28 (cancel-timer timeout
))
30 (defun copy-tree (tree)
32 (cons (copy-tree (car tree
))
33 (copy-tree (cdr tree
)))
35 (let* ((new (copy-sequence tree
))
36 (i (1- (length new
))))
38 (aset new i
(copy-tree (aref new i
)))
43 (defalias 'current-time-seconds
'current-time
)
45 (defun keymap-parent (keymap)
46 (let ((tail (cdr keymap
)))
47 (while (and tail
(not (eq (car tail
) 'keymap
)))
48 (setq tail
(cdr tail
)))
51 (defun set-keymap-parent (keymap new-parent
)
53 (while (and tail
(cdr tail
) (not (eq (car (cdr tail
)) 'keymap
)))
54 (setq tail
(cdr tail
)))
56 (setcdr tail new-parent
))))
58 (defun remprop (symbol prop
)
59 (let ((plist (symbol-plist symbol
)))
60 (while (eq (car plist
) prop
)
61 (setplist symbol
(setq plist
(cdr (cdr plist
)))))
63 (if (eq (nth 2 plist
) prop
)
64 (setcdr (cdr plist
) (nthcdr 4 plist
)))
65 (setq plist
(cdr (cdr plist
))))))
67 (defun map-keymap (function keymap
&optional sort-first
)
68 "Call FUNCTION for every binding in KEYMAP.
69 This includes bindings inherited from a parent keymap.
70 FUNCTION receives two arguments each time it is called:
71 the character (more generally, the event type) that is bound,
72 and the binding it has.
74 Note that passing the event type directly to `define-key' does not work
75 in Emacs 19. We do not emulate that particular feature of Lucid Emacs.
76 If your code does that, modify it to make a vector containing the event
77 type that you get. That will work in both versions of Emacs."
80 (map-keymap (function (lambda (a b
)
81 (setq list
(cons (cons a b
) list
))))
84 (function (lambda (a b
)
85 (setq a
(car a
) b
(car b
))
87 (if (integerp b
) (< a b
)
92 (funcall function
(car (car list
)) (cdr (car list
)))
93 (setq list
(cdr list
))))
95 (if (consp (car keymap
))
96 (funcall function
(car (car keymap
)) (cdr (car keymap
)))
97 (if (vectorp (car keymap
))
98 (let ((i (1- (length (car keymap
))))
99 (vector (car keymap
)))
101 (funcall function i
(aref vector i
))
103 (setq keymap
(cdr keymap
)))))
105 (defun read-number (prompt &optional integers-only
)
106 "Read a number from the minibuffer.
107 Keep reentering the minibuffer until we get suitable input.
108 If optional argument INTEGERS-ONLY is non-nil, insist on an integer."
112 (predicate (if integers-only
'integerp
'numberp
)))
114 (let ((input-string (read-string prompt
)))
116 (setq number
(read input-string
))
118 (if (funcall predicate number
)
120 (let ((cursor-in-echo-area t
))
121 (message "Please type %s"
122 (if integers-only
"an integer" "a number"))
126 (defun real-path-name (name &optional default
)
127 (file-truename (expand-file-name name default
)))
129 ;; It's not clear what to return if the mouse is not in FRAME.
130 (defun read-mouse-position (frame)
131 (let ((pos (mouse-position)))
132 (if (eq (car pos
) frame
)
135 (defun switch-to-other-buffer (arg)
136 "Switch to the previous buffer.
137 With a numeric arg N, switch to the Nth most recent buffer.
138 With an arg of 0, buries the current buffer at the
139 bottom of the buffer stack."
142 (bury-buffer (current-buffer)))
144 (if (<= arg
1) (other-buffer (current-buffer))
149 (if (= ?\
(string-to-char (buffer-name buf
)))
154 (defalias 'find-face
'internal-find-face
)
155 (defalias 'get-face
'internal-get-face
)
156 (defalias 'try-face-font
'internal-try-face-font
)
158 (defun make-extent (beg end
&optional buffer
)
159 (make-overlay beg end buffer
))
161 (defun set-extent-property (extent prop value
)
162 (if (eq prop
'duplicable
)
163 (cond ((and value
(not (overlay-get extent prop
)))
164 ;; If becoming duplicable, copy all overlayprops to text props.
165 (add-text-properties (overlay-start extent
)
167 (overlay-properties extent
)
168 (overlay-buffer extent
)))
169 ;; If becoming no longer duplicable, remove these text props.
170 ((and (not value
) (overlay-get extent prop
))
171 (remove-text-properties (overlay-start extent
)
173 (overlay-properties extent
)
174 (overlay-buffer extent
))))
175 ;; If extent is already duplicable, put this property
176 ;; on the text as well as on the overlay.
177 (if (overlay-get extent
'duplicable
)
178 (put-text-property (overlay-start extent
)
180 prop value
(overlay-buffer extent
))))
181 (overlay-put extent prop value
))
183 (defun set-extent-face (extent face
)
184 (set-extent-property extent
'face face
))
186 (defun delete-extent (extent)
187 (set-extent-property extent
'duplicable nil
)
188 (delete-overlay extent
))
190 ;; Support the Lucid names with `screen' instead of `frame'.
192 (defalias 'current-screen-configuration
'current-frame-configuration
)
193 (defalias 'delete-screen
'delete-frame
)
194 (defalias 'find-file-new-screen
'find-file-other-frame
)
195 (defalias 'find-file-read-only-new-screen
'find-file-read-only-other-frame
)
196 (defalias 'find-tag-new-screen
'find-tag-other-frame
)
197 ;;(defalias 'focus-screen 'focus-frame)
198 (defalias 'iconify-screen
'iconify-frame
)
199 (defalias 'mail-new-screen
'mail-other-frame
)
200 (defalias 'make-screen-invisible
'make-frame-invisible
)
201 (defalias 'make-screen-visible
'make-frame-visible
)
202 ;; (defalias 'minibuffer-screen-list 'minibuffer-frame-list)
203 (defalias 'modify-screen-parameters
'modify-frame-parameters
)
204 (defalias 'next-screen
'next-frame
)
205 ;; (defalias 'next-multiscreen-window 'next-multiframe-window)
206 ;; (defalias 'previous-multiscreen-window 'previous-multiframe-window)
207 ;; (defalias 'redirect-screen-focus 'redirect-frame-focus)
208 (defalias 'redraw-screen
'redraw-frame
)
209 ;; (defalias 'screen-char-height 'frame-char-height)
210 ;; (defalias 'screen-char-width 'frame-char-width)
211 ;; (defalias 'screen-configuration-to-register 'frame-configuration-to-register)
212 ;; (defalias 'screen-focus 'frame-focus)
213 (defalias 'screen-height
'frame-height
)
214 (defalias 'screen-list
'frame-list
)
215 ;; (defalias 'screen-live-p 'frame-live-p)
216 (defalias 'screen-parameters
'frame-parameters
)
217 (defalias 'screen-pixel-height
'frame-pixel-height
)
218 (defalias 'screen-pixel-width
'frame-pixel-width
)
219 (defalias 'screen-root-window
'frame-root-window
)
220 (defalias 'screen-selected-window
'frame-selected-window
)
221 (defalias 'lower-screen
'lower-frame
)
222 (defalias 'raise-screen
'raise-frame
)
223 (defalias 'screen-visible-p
'frame-visible-p
)
224 (defalias 'screen-width
'frame-width
)
225 (defalias 'screenp
'framep
)
226 (defalias 'select-screen
'select-frame
)
227 (defalias 'selected-screen
'selected-frame
)
228 ;; (defalias 'set-screen-configuration 'set-frame-configuration)
229 ;; (defalias 'set-screen-height 'set-frame-height)
230 (defalias 'set-screen-position
'set-frame-position
)
231 (defalias 'set-screen-size
'set-frame-size
)
232 ;; (defalias 'set-screen-width 'set-frame-width)
233 (defalias 'switch-to-buffer-new-screen
'switch-to-buffer-other-frame
)
234 ;; (defalias 'unfocus-screen 'unfocus-frame)
235 (defalias 'visible-screen-list
'visible-frame-list
)
236 (defalias 'window-screen
'window-frame
)
237 (defalias 'x-create-screen
'x-create-frame
)
238 (defalias 'x-new-screen
'make-frame
)