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 ;; In case cl-map-keymap is an alias for map-keymap, avoid circular calls.
35 (fset 'cl-map-keymap (indirect-function 'cl-map-keymap))
37 (defun map-keymap (function keymap &optional sort-first)
38 "Call FUNCTION for every binding in KEYMAP.
39 This does not include bindings inherited from a parent keymap.
40 FUNCTION receives two arguments each time it is called:
41 the character (more generally, the event type) that is bound,
42 and the binding it has.
44 Note that passing the event type directly to `define-key' does not work
45 in Emacs 19. We do not emulate that particular feature of Lucid Emacs.
46 If your code does that, modify it to make a vector containing the event
47 type that you get. That will work in both versions of Emacs."
50 (cl-map-keymap (lambda (a b) (push (cons a b) list))
54 (setq a (car a) b (car b))
56 (if (integerp b) (< a b)
61 (funcall function (car p) (cdr p))))
62 (cl-map-keymap function keymap)))
64 (defun read-number (prompt &optional integers-only)
65 "Read a number from the minibuffer.
66 Keep reentering the minibuffer until we get suitable input.
67 If optional argument INTEGERS-ONLY is non-nil, insist on an integer."
71 (predicate (if integers-only 'integerp 'numberp)))
73 (let ((input-string (read-string prompt)))
75 (setq number (read input-string))
77 (if (funcall predicate number)
79 (let ((cursor-in-echo-area t))
80 (message "Please type %s"
81 (if integers-only "an integer" "a number"))
85 (defun real-path-name (name &optional default)
86 (file-truename (expand-file-name name default)))
88 ;; It's not clear what to return if the mouse is not in FRAME.
89 (defun read-mouse-position (frame)
90 (let ((pos (mouse-position)))
91 (if (eq (car pos) frame)
94 (defun switch-to-other-buffer (arg)
95 "Switch to the previous buffer.
96 With a numeric arg N, switch to the Nth most recent buffer.
97 With an arg of 0, buries the current buffer at the
98 bottom of the buffer stack."
101 (bury-buffer (current-buffer)))
103 (if (<= arg 1) (other-buffer (current-buffer))
108 (if (= ?\ (string-to-char (buffer-name buf)))
113 (defun device-class (&optional device)
114 "Return the class (color behavior) of DEVICE.
115 This will be one of 'color, 'grayscale, or 'mono.
116 This function exists for compatibility with XEmacs."
118 ((display-color-p device) 'color)
119 ((display-grayscale-p device) 'grayscale)
122 (defalias 'find-face 'internal-find-face)
123 (defalias 'get-face 'internal-get-face)
124 (defalias 'try-face-font 'internal-try-face-font)
126 (defalias 'exec-to-string 'shell-command-to-string)
131 (defun buffer-syntactic-context (&optional buffer)
132 "Syntactic context at point in BUFFER.
133 Either of `string', `comment' or nil.
134 This is an XEmacs compatibility function."
135 (with-current-buffer (or buffer (current-buffer))
136 (let ((state (syntax-ppss (point))))
138 ((nth 3 state) 'string)
139 ((nth 4 state) 'comment)))))
142 (defun buffer-syntactic-context-depth (&optional buffer)
143 "Syntactic parenthesis depth at point in BUFFER.
144 This is an XEmacs compatibility function."
145 (with-current-buffer (or buffer (current-buffer))
146 (nth 0 (syntax-ppss (point)))))
150 (defun make-extent (beg end &optional buffer)
151 (make-overlay beg end buffer))
153 (defun extent-properties (extent) (overlay-properties extent))
154 (unless (fboundp 'extent-property) (defalias 'extent-property 'overlay-get))
156 (defun extent-at (pos &optional object property before)
157 (with-current-buffer (or object (current-buffer))
158 (let ((overlays (overlays-at pos)))
162 (if (overlay-get (car overlays) property)
163 (setq filtered (cons (car overlays) filtered)))
164 (setq overlays (cdr overlays)))
165 (setq overlays filtered)))
168 (function (lambda (o1 o2)
169 (let ((p1 (or (overlay-get o1 'priority) 0))
170 (p2 (or (overlay-get o2 'priority) 0)))
173 (> (overlay-start o1) (overlay-start o2)))))))))
175 (nth 1 (memq before overlays))
178 (defun set-extent-property (extent prop value)
179 ;; Make sure that separate adjacent extents
180 ;; with the same mouse-face value
181 ;; do not run together as one extent.
182 (and (eq prop 'mouse-face)
184 (setq value (list value)))
185 (if (eq prop 'duplicable)
186 (cond ((and value (not (overlay-get extent prop)))
187 ;; If becoming duplicable, copy all overlayprops to text props.
188 (add-text-properties (overlay-start extent)
190 (overlay-properties extent)
191 (overlay-buffer extent)))
192 ;; If becoming no longer duplicable, remove these text props.
193 ((and (not value) (overlay-get extent prop))
194 (remove-text-properties (overlay-start extent)
196 (overlay-properties extent)
197 (overlay-buffer extent))))
198 ;; If extent is already duplicable, put this property
199 ;; on the text as well as on the overlay.
200 (if (overlay-get extent 'duplicable)
201 (put-text-property (overlay-start extent)
203 prop value (overlay-buffer extent))))
204 (overlay-put extent prop value))
206 (defun set-extent-face (extent face)
207 (set-extent-property extent 'face face))
209 (defun set-extent-end-glyph (extent glyph)
210 (set-extent-property extent 'after-string glyph))
212 (defun delete-extent (extent)
213 (set-extent-property extent 'duplicable nil)
214 (delete-overlay extent))
216 ;; Support the Lucid names with `screen' instead of `frame'.
218 (defalias 'current-screen-configuration 'current-frame-configuration)
219 (defalias 'delete-screen 'delete-frame)
220 (defalias 'find-file-new-screen 'find-file-other-frame)
221 (defalias 'find-file-read-only-new-screen 'find-file-read-only-other-frame)
222 (defalias 'find-tag-new-screen 'find-tag-other-frame)
223 ;;(defalias 'focus-screen 'focus-frame)
224 (defalias 'iconify-screen 'iconify-frame)
225 (defalias 'mail-new-screen 'mail-other-frame)
226 (defalias 'make-screen-invisible 'make-frame-invisible)
227 (defalias 'make-screen-visible 'make-frame-visible)
228 ;; (defalias 'minibuffer-screen-list 'minibuffer-frame-list)
229 (defalias 'modify-screen-parameters 'modify-frame-parameters)
230 (defalias 'next-screen 'next-frame)
231 ;; (defalias 'next-multiscreen-window 'next-multiframe-window)
232 ;; (defalias 'previous-multiscreen-window 'previous-multiframe-window)
233 ;; (defalias 'redirect-screen-focus 'redirect-frame-focus)
234 (defalias 'redraw-screen 'redraw-frame)
235 ;; (defalias 'screen-char-height 'frame-char-height)
236 ;; (defalias 'screen-char-width 'frame-char-width)
237 ;; (defalias 'screen-configuration-to-register 'frame-configuration-to-register)
238 ;; (defalias 'screen-focus 'frame-focus)
239 (defalias 'screen-list 'frame-list)
240 ;; (defalias 'screen-live-p 'frame-live-p)
241 (defalias 'screen-parameters 'frame-parameters)
242 (defalias 'screen-pixel-height 'frame-pixel-height)
243 (defalias 'screen-pixel-width 'frame-pixel-width)
244 (defalias 'screen-root-window 'frame-root-window)
245 (defalias 'screen-selected-window 'frame-selected-window)
246 (defalias 'lower-screen 'lower-frame)
247 (defalias 'raise-screen 'raise-frame)
248 (defalias 'screen-visible-p 'frame-visible-p)
249 (defalias 'screenp 'framep)
250 (defalias 'select-screen 'select-frame)
251 (defalias 'selected-screen 'selected-frame)
252 ;; (defalias 'set-screen-configuration 'set-frame-configuration)
253 ;; (defalias 'set-screen-height 'set-frame-height)
254 (defalias 'set-screen-position 'set-frame-position)
255 (defalias 'set-screen-size 'set-frame-size)
256 ;; (defalias 'set-screen-width 'set-frame-width)
257 (defalias 'switch-to-buffer-new-screen 'switch-to-buffer-other-frame)
258 ;; (defalias 'unfocus-screen 'unfocus-frame)
259 (defalias 'visible-screen-list 'visible-frame-list)
260 (defalias 'window-screen 'window-frame)
261 (defalias 'x-create-screen 'x-create-frame)
262 (defalias 'x-new-screen 'make-frame)
266 ;;; arch-tag: 80f9ab46-0b36-4151-86ed-3edb6d449c9e
267 ;;; lucid.el ends here