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 (defalias 'find-face 'internal-find-face)
111 (defalias 'get-face 'internal-get-face)
112 (defalias 'try-face-font 'internal-try-face-font)
114 (defalias 'exec-to-string 'shell-command-to-string)
116 (defun make-extent (beg end &optional buffer)
117 (make-overlay beg end buffer))
119 (defun extent-properties (extent) (overlay-properties extent))
120 (unless (fboundp 'extent-property) (defalias 'extent-property 'overlay-get))
122 (defun extent-at (pos &optional object property before)
123 (with-current-buffer (or object (current-buffer))
124 (let ((overlays (overlays-at pos)))
128 (if (overlay-get (car overlays) property)
129 (setq filtered (cons (car overlays) filtered)))
130 (setq overlays (cdr overlays)))
131 (setq overlays filtered)))
134 (function (lambda (o1 o2)
135 (let ((p1 (or (overlay-get o1 'priority) 0))
136 (p2 (or (overlay-get o2 'priority) 0)))
139 (> (overlay-start o1) (overlay-start o2)))))))))
141 (nth 1 (memq before overlays))
144 (defun set-extent-property (extent prop value)
145 ;; Make sure that separate adjacent extents
146 ;; with the same mouse-face value
147 ;; do not run together as one extent.
148 (and (eq prop 'mouse-face)
150 (setq value (list value)))
151 (if (eq prop 'duplicable)
152 (cond ((and value (not (overlay-get extent prop)))
153 ;; If becoming duplicable, copy all overlayprops to text props.
154 (add-text-properties (overlay-start extent)
156 (overlay-properties extent)
157 (overlay-buffer extent)))
158 ;; If becoming no longer duplicable, remove these text props.
159 ((and (not value) (overlay-get extent prop))
160 (remove-text-properties (overlay-start extent)
162 (overlay-properties extent)
163 (overlay-buffer extent))))
164 ;; If extent is already duplicable, put this property
165 ;; on the text as well as on the overlay.
166 (if (overlay-get extent 'duplicable)
167 (put-text-property (overlay-start extent)
169 prop value (overlay-buffer extent))))
170 (overlay-put extent prop value))
172 (defun set-extent-face (extent face)
173 (set-extent-property extent 'face face))
175 (defun set-extent-end-glyph (extent glyph)
176 (set-extent-property extent 'after-string glyph))
178 (defun delete-extent (extent)
179 (set-extent-property extent 'duplicable nil)
180 (delete-overlay extent))
182 ;; Support the Lucid names with `screen' instead of `frame'.
184 (defalias 'current-screen-configuration 'current-frame-configuration)
185 (defalias 'delete-screen 'delete-frame)
186 (defalias 'find-file-new-screen 'find-file-other-frame)
187 (defalias 'find-file-read-only-new-screen 'find-file-read-only-other-frame)
188 (defalias 'find-tag-new-screen 'find-tag-other-frame)
189 ;;(defalias 'focus-screen 'focus-frame)
190 (defalias 'iconify-screen 'iconify-frame)
191 (defalias 'mail-new-screen 'mail-other-frame)
192 (defalias 'make-screen-invisible 'make-frame-invisible)
193 (defalias 'make-screen-visible 'make-frame-visible)
194 ;; (defalias 'minibuffer-screen-list 'minibuffer-frame-list)
195 (defalias 'modify-screen-parameters 'modify-frame-parameters)
196 (defalias 'next-screen 'next-frame)
197 ;; (defalias 'next-multiscreen-window 'next-multiframe-window)
198 ;; (defalias 'previous-multiscreen-window 'previous-multiframe-window)
199 ;; (defalias 'redirect-screen-focus 'redirect-frame-focus)
200 (defalias 'redraw-screen 'redraw-frame)
201 ;; (defalias 'screen-char-height 'frame-char-height)
202 ;; (defalias 'screen-char-width 'frame-char-width)
203 ;; (defalias 'screen-configuration-to-register 'frame-configuration-to-register)
204 ;; (defalias 'screen-focus 'frame-focus)
205 (defalias 'screen-list 'frame-list)
206 ;; (defalias 'screen-live-p 'frame-live-p)
207 (defalias 'screen-parameters 'frame-parameters)
208 (defalias 'screen-pixel-height 'frame-pixel-height)
209 (defalias 'screen-pixel-width 'frame-pixel-width)
210 (defalias 'screen-root-window 'frame-root-window)
211 (defalias 'screen-selected-window 'frame-selected-window)
212 (defalias 'lower-screen 'lower-frame)
213 (defalias 'raise-screen 'raise-frame)
214 (defalias 'screen-visible-p 'frame-visible-p)
215 (defalias 'screenp 'framep)
216 (defalias 'select-screen 'select-frame)
217 (defalias 'selected-screen 'selected-frame)
218 ;; (defalias 'set-screen-configuration 'set-frame-configuration)
219 ;; (defalias 'set-screen-height 'set-frame-height)
220 (defalias 'set-screen-position 'set-frame-position)
221 (defalias 'set-screen-size 'set-frame-size)
222 ;; (defalias 'set-screen-width 'set-frame-width)
223 (defalias 'switch-to-buffer-new-screen 'switch-to-buffer-other-frame)
224 ;; (defalias 'unfocus-screen 'unfocus-frame)
225 (defalias 'visible-screen-list 'visible-frame-list)
226 (defalias 'window-screen 'window-frame)
227 (defalias 'x-create-screen 'x-create-frame)
228 (defalias 'x-new-screen 'make-frame)
232 ;;; lucid.el ends here