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 ;; XEmacs autoloads CL so we might as well make use of it.
27 (defalias 'current-time-seconds
'current-time
)
29 (defun map-keymap (function keymap
&optional sort-first
)
30 "Call FUNCTION for every binding in KEYMAP.
31 This does not include bindings inherited from a parent keymap.
32 FUNCTION receives two arguments each time it is called:
33 the character (more generally, the event type) that is bound,
34 and the binding it has.
36 Note that passing the event type directly to `define-key' does not work
37 in Emacs 19. We do not emulate that particular feature of Lucid Emacs.
38 If your code does that, modify it to make a vector containing the event
39 type that you get. That will work in both versions of Emacs."
42 (cl-map-keymap (lambda (a b
) (push (cons a b
) list
))
46 (setq a
(car a
) b
(car b
))
48 (if (integerp b
) (< a b
)
53 (funcall function
(car p
) (cdr p
))))
54 (cl-map-keymap function keymap
)))
56 (defun read-number (prompt &optional integers-only
)
57 "Read a number from the minibuffer.
58 Keep reentering the minibuffer until we get suitable input.
59 If optional argument INTEGERS-ONLY is non-nil, insist on an integer."
63 (predicate (if integers-only
'integerp
'numberp
)))
65 (let ((input-string (read-string prompt
)))
67 (setq number
(read input-string
))
69 (if (funcall predicate number
)
71 (let ((cursor-in-echo-area t
))
72 (message "Please type %s"
73 (if integers-only
"an integer" "a number"))
77 (defun real-path-name (name &optional default
)
78 (file-truename (expand-file-name name default
)))
80 ;; It's not clear what to return if the mouse is not in FRAME.
81 (defun read-mouse-position (frame)
82 (let ((pos (mouse-position)))
83 (if (eq (car pos
) frame
)
86 (defun switch-to-other-buffer (arg)
87 "Switch to the previous buffer.
88 With a numeric arg N, switch to the Nth most recent buffer.
89 With an arg of 0, buries the current buffer at the
90 bottom of the buffer stack."
93 (bury-buffer (current-buffer)))
95 (if (<= arg
1) (other-buffer (current-buffer))
100 (if (= ?\
(string-to-char (buffer-name buf
)))
105 (defalias 'find-face
'internal-find-face
)
106 (defalias 'get-face
'internal-get-face
)
107 (defalias 'try-face-font
'internal-try-face-font
)
109 (defalias 'exec-to-string
'shell-command-to-string
)
111 (defun make-extent (beg end
&optional buffer
)
112 (make-overlay beg end buffer
))
114 (defun extent-properties (extent) (overlay-properties extent
))
115 (unless (fboundp 'extent-property
) (defalias 'extent-property
'overlay-get
))
117 (defun extent-at (pos &optional object property before
)
118 (with-current-buffer (or object
(current-buffer))
119 (let ((overlays (overlays-at pos
)))
123 (if (overlay-get (car overlays
) property
)
124 (setq filtered
(cons (car overlays
) filtered
)))
125 (setq overlays
(cdr overlays
)))
126 (setq overlays filtered
)))
129 (function (lambda (o1 o2
)
130 (let ((p1 (or (overlay-get o1
'priority
) 0))
131 (p2 (or (overlay-get o2
'priority
) 0)))
134 (> (overlay-start o1
) (overlay-start o2
)))))))))
136 (nth 1 (memq before overlays
))
139 (defun set-extent-property (extent prop value
)
140 ;; Make sure that separate adjacent extents
141 ;; with the same mouse-face value
142 ;; do not run together as one extent.
143 (and (eq prop
'mouse-face
)
145 (setq value
(list value
)))
146 (if (eq prop
'duplicable
)
147 (cond ((and value
(not (overlay-get extent prop
)))
148 ;; If becoming duplicable, copy all overlayprops to text props.
149 (add-text-properties (overlay-start extent
)
151 (overlay-properties extent
)
152 (overlay-buffer extent
)))
153 ;; If becoming no longer duplicable, remove these text props.
154 ((and (not value
) (overlay-get extent prop
))
155 (remove-text-properties (overlay-start extent
)
157 (overlay-properties extent
)
158 (overlay-buffer extent
))))
159 ;; If extent is already duplicable, put this property
160 ;; on the text as well as on the overlay.
161 (if (overlay-get extent
'duplicable
)
162 (put-text-property (overlay-start extent
)
164 prop value
(overlay-buffer extent
))))
165 (overlay-put extent prop value
))
167 (defun set-extent-face (extent face
)
168 (set-extent-property extent
'face face
))
170 (defun set-extent-end-glyph (extent glyph
)
171 (set-extent-property extent
'after-string glyph
))
173 (defun delete-extent (extent)
174 (set-extent-property extent
'duplicable nil
)
175 (delete-overlay extent
))
177 ;; Support the Lucid names with `screen' instead of `frame'.
179 (defalias 'current-screen-configuration
'current-frame-configuration
)
180 (defalias 'delete-screen
'delete-frame
)
181 (defalias 'find-file-new-screen
'find-file-other-frame
)
182 (defalias 'find-file-read-only-new-screen
'find-file-read-only-other-frame
)
183 (defalias 'find-tag-new-screen
'find-tag-other-frame
)
184 ;;(defalias 'focus-screen 'focus-frame)
185 (defalias 'iconify-screen
'iconify-frame
)
186 (defalias 'mail-new-screen
'mail-other-frame
)
187 (defalias 'make-screen-invisible
'make-frame-invisible
)
188 (defalias 'make-screen-visible
'make-frame-visible
)
189 ;; (defalias 'minibuffer-screen-list 'minibuffer-frame-list)
190 (defalias 'modify-screen-parameters
'modify-frame-parameters
)
191 (defalias 'next-screen
'next-frame
)
192 ;; (defalias 'next-multiscreen-window 'next-multiframe-window)
193 ;; (defalias 'previous-multiscreen-window 'previous-multiframe-window)
194 ;; (defalias 'redirect-screen-focus 'redirect-frame-focus)
195 (defalias 'redraw-screen
'redraw-frame
)
196 ;; (defalias 'screen-char-height 'frame-char-height)
197 ;; (defalias 'screen-char-width 'frame-char-width)
198 ;; (defalias 'screen-configuration-to-register 'frame-configuration-to-register)
199 ;; (defalias 'screen-focus 'frame-focus)
200 (defalias 'screen-list
'frame-list
)
201 ;; (defalias 'screen-live-p 'frame-live-p)
202 (defalias 'screen-parameters
'frame-parameters
)
203 (defalias 'screen-pixel-height
'frame-pixel-height
)
204 (defalias 'screen-pixel-width
'frame-pixel-width
)
205 (defalias 'screen-root-window
'frame-root-window
)
206 (defalias 'screen-selected-window
'frame-selected-window
)
207 (defalias 'lower-screen
'lower-frame
)
208 (defalias 'raise-screen
'raise-frame
)
209 (defalias 'screen-visible-p
'frame-visible-p
)
210 (defalias 'screenp
'framep
)
211 (defalias 'select-screen
'select-frame
)
212 (defalias 'selected-screen
'selected-frame
)
213 ;; (defalias 'set-screen-configuration 'set-frame-configuration)
214 ;; (defalias 'set-screen-height 'set-frame-height)
215 (defalias 'set-screen-position
'set-frame-position
)
216 (defalias 'set-screen-size
'set-frame-size
)
217 ;; (defalias 'set-screen-width 'set-frame-width)
218 (defalias 'switch-to-buffer-new-screen
'switch-to-buffer-other-frame
)
219 ;; (defalias 'unfocus-screen 'unfocus-frame)
220 (defalias 'visible-screen-list
'visible-frame-list
)
221 (defalias 'window-screen
'window-frame
)
222 (defalias 'x-create-screen
'x-create-frame
)
223 (defalias 'x-new-screen
'make-frame
)