1 ;;; lucid.el --- emulate some Lucid Emacs functions
3 ;; Copyright (C) 1993, 1995, 2001 Free Software Foundation, Inc.
6 ;; Keywords: emulations
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 ;; XEmacs autoloads CL so we might as well make use of it.
32 (defalias 'current-time-seconds 'current-time)
34 (defun map-keymap (function keymap &optional sort-first)
35 "Call FUNCTION for every binding in KEYMAP.
36 This does not include bindings inherited from a parent keymap.
37 FUNCTION receives two arguments each time it is called:
38 the character (more generally, the event type) that is bound,
39 and the binding it has.
41 Note that passing the event type directly to `define-key' does not work
42 in Emacs 19. We do not emulate that particular feature of Lucid Emacs.
43 If your code does that, modify it to make a vector containing the event
44 type that you get. That will work in both versions of Emacs."
47 (cl-map-keymap (lambda (a b) (push (cons a b) list))
51 (setq a (car a) b (car b))
53 (if (integerp b) (< a b)
58 (funcall function (car p) (cdr p))))
59 (cl-map-keymap function keymap)))
61 (defun read-number (prompt &optional integers-only)
62 "Read a number from the minibuffer.
63 Keep reentering the minibuffer until we get suitable input.
64 If optional argument INTEGERS-ONLY is non-nil, insist on an integer."
68 (predicate (if integers-only 'integerp 'numberp)))
70 (let ((input-string (read-string prompt)))
72 (setq number (read input-string))
74 (if (funcall predicate number)
76 (let ((cursor-in-echo-area t))
77 (message "Please type %s"
78 (if integers-only "an integer" "a number"))
82 (defun real-path-name (name &optional default)
83 (file-truename (expand-file-name name default)))
85 ;; It's not clear what to return if the mouse is not in FRAME.
86 (defun read-mouse-position (frame)
87 (let ((pos (mouse-position)))
88 (if (eq (car pos) frame)
91 (defun switch-to-other-buffer (arg)
92 "Switch to the previous buffer.
93 With a numeric arg N, switch to the Nth most recent buffer.
94 With an arg of 0, buries the current buffer at the
95 bottom of the buffer stack."
98 (bury-buffer (current-buffer)))
100 (if (<= arg 1) (other-buffer (current-buffer))
105 (if (= ?\ (string-to-char (buffer-name buf)))
110 (defun device-class (&optional device)
111 "Return the class (color behavior) of DEVICE.
112 This will be one of 'color, 'grayscale, or 'mono.
113 This function exists for compatibility with XEmacs."
115 ((display-color-p device) 'color)
116 ((display-grayscale-p device) 'grayscale)
119 (defalias 'find-face 'internal-find-face)
120 (defalias 'get-face 'internal-get-face)
121 (defalias 'try-face-font 'internal-try-face-font)
123 (defalias 'exec-to-string 'shell-command-to-string)
128 (defun buffer-syntactic-context (&optional buffer)
129 "Syntactic context at point in BUFFER.
130 Either of `string', `comment' or `nil'.
131 This is an XEmacs compatibility function."
132 (with-current-buffer (or buffer (current-buffer))
133 (let ((state (syntax-ppss (point))))
135 ((nth 3 state) 'string)
136 ((nth 4 state) 'comment)))))
139 (defun buffer-syntactic-context-depth (&optional buffer)
140 "Syntactic parenthesis depth at point in BUFFER.
141 This is an XEmacs compatibility function."
142 (with-current-buffer (or buffer (current-buffer))
143 (nth 0 (syntax-ppss (point)))))
147 (defun make-extent (beg end &optional buffer)
148 (make-overlay beg end buffer))
150 (defun extent-properties (extent) (overlay-properties extent))
151 (unless (fboundp 'extent-property) (defalias 'extent-property 'overlay-get))
153 (defun extent-at (pos &optional object property before)
154 (with-current-buffer (or object (current-buffer))
155 (let ((overlays (overlays-at pos)))
159 (if (overlay-get (car overlays) property)
160 (setq filtered (cons (car overlays) filtered)))
161 (setq overlays (cdr overlays)))
162 (setq overlays filtered)))
165 (function (lambda (o1 o2)
166 (let ((p1 (or (overlay-get o1 'priority) 0))
167 (p2 (or (overlay-get o2 'priority) 0)))
170 (> (overlay-start o1) (overlay-start o2)))))))))
172 (nth 1 (memq before overlays))
175 (defun set-extent-property (extent prop value)
176 ;; Make sure that separate adjacent extents
177 ;; with the same mouse-face value
178 ;; do not run together as one extent.
179 (and (eq prop 'mouse-face)
181 (setq value (list value)))
182 (if (eq prop 'duplicable)
183 (cond ((and value (not (overlay-get extent prop)))
184 ;; If becoming duplicable, copy all overlayprops to text props.
185 (add-text-properties (overlay-start extent)
187 (overlay-properties extent)
188 (overlay-buffer extent)))
189 ;; If becoming no longer duplicable, remove these text props.
190 ((and (not value) (overlay-get extent prop))
191 (remove-text-properties (overlay-start extent)
193 (overlay-properties extent)
194 (overlay-buffer extent))))
195 ;; If extent is already duplicable, put this property
196 ;; on the text as well as on the overlay.
197 (if (overlay-get extent 'duplicable)
198 (put-text-property (overlay-start extent)
200 prop value (overlay-buffer extent))))
201 (overlay-put extent prop value))
203 (defun set-extent-face (extent face)
204 (set-extent-property extent 'face face))
206 (defun set-extent-end-glyph (extent glyph)
207 (set-extent-property extent 'after-string glyph))
209 (defun delete-extent (extent)
210 (set-extent-property extent 'duplicable nil)
211 (delete-overlay extent))
213 ;; Support the Lucid names with `screen' instead of `frame'.
215 (defalias 'current-screen-configuration 'current-frame-configuration)
216 (defalias 'delete-screen 'delete-frame)
217 (defalias 'find-file-new-screen 'find-file-other-frame)
218 (defalias 'find-file-read-only-new-screen 'find-file-read-only-other-frame)
219 (defalias 'find-tag-new-screen 'find-tag-other-frame)
220 ;;(defalias 'focus-screen 'focus-frame)
221 (defalias 'iconify-screen 'iconify-frame)
222 (defalias 'mail-new-screen 'mail-other-frame)
223 (defalias 'make-screen-invisible 'make-frame-invisible)
224 (defalias 'make-screen-visible 'make-frame-visible)
225 ;; (defalias 'minibuffer-screen-list 'minibuffer-frame-list)
226 (defalias 'modify-screen-parameters 'modify-frame-parameters)
227 (defalias 'next-screen 'next-frame)
228 ;; (defalias 'next-multiscreen-window 'next-multiframe-window)
229 ;; (defalias 'previous-multiscreen-window 'previous-multiframe-window)
230 ;; (defalias 'redirect-screen-focus 'redirect-frame-focus)
231 (defalias 'redraw-screen 'redraw-frame)
232 ;; (defalias 'screen-char-height 'frame-char-height)
233 ;; (defalias 'screen-char-width 'frame-char-width)
234 ;; (defalias 'screen-configuration-to-register 'frame-configuration-to-register)
235 ;; (defalias 'screen-focus 'frame-focus)
236 (defalias 'screen-list 'frame-list)
237 ;; (defalias 'screen-live-p 'frame-live-p)
238 (defalias 'screen-parameters 'frame-parameters)
239 (defalias 'screen-pixel-height 'frame-pixel-height)
240 (defalias 'screen-pixel-width 'frame-pixel-width)
241 (defalias 'screen-root-window 'frame-root-window)
242 (defalias 'screen-selected-window 'frame-selected-window)
243 (defalias 'lower-screen 'lower-frame)
244 (defalias 'raise-screen 'raise-frame)
245 (defalias 'screen-visible-p 'frame-visible-p)
246 (defalias 'screenp 'framep)
247 (defalias 'select-screen 'select-frame)
248 (defalias 'selected-screen 'selected-frame)
249 ;; (defalias 'set-screen-configuration 'set-frame-configuration)
250 ;; (defalias 'set-screen-height 'set-frame-height)
251 (defalias 'set-screen-position 'set-frame-position)
252 (defalias 'set-screen-size 'set-frame-size)
253 ;; (defalias 'set-screen-width 'set-frame-width)
254 (defalias 'switch-to-buffer-new-screen 'switch-to-buffer-other-frame)
255 ;; (defalias 'unfocus-screen 'unfocus-frame)
256 (defalias 'visible-screen-list 'visible-frame-list)
257 (defalias 'window-screen 'window-frame)
258 (defalias 'x-create-screen 'x-create-frame)
259 (defalias 'x-new-screen 'make-frame)
263 ;;; lucid.el ends here