Commit | Line | Data |
---|---|---|
60370d40 | 1 | ;;; lucid.el --- emulate some Lucid Emacs functions |
b578f267 | 2 | |
284b3043 | 3 | ;; Copyright (C) 1993, 1995, 2001 Free Software Foundation, Inc. |
6de6752c | 4 | |
070c251e | 5 | ;; Maintainer: FSF |
284b3043 | 6 | ;; Keywords: emulations |
070c251e | 7 | |
6de6752c RS |
8 | ;; This file is part of GNU Emacs. |
9 | ||
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) | |
13 | ;; any later version. | |
14 | ||
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. | |
19 | ||
20 | ;; You should have received a copy of the GNU General Public License | |
b578f267 | 21 | ;; along with GNU Emacs; see the file COPYING. If not, write to the |
3a35cf56 LK |
22 | ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
23 | ;; Boston, MA 02110-1301, USA. | |
6de6752c | 24 | |
60370d40 PJ |
25 | ;;; Commentary: |
26 | ||
b578f267 | 27 | ;;; Code: |
6de6752c | 28 | |
5e2dfaa4 SM |
29 | ;; XEmacs autoloads CL so we might as well make use of it. |
30 | (require 'cl) | |
330fba95 | 31 | |
31e1d920 | 32 | (defalias 'current-time-seconds 'current-time) |
330fba95 | 33 | |
3b787dc3 RS |
34 | (defun read-number (prompt &optional integers-only) |
35 | "Read a number from the minibuffer. | |
36 | Keep reentering the minibuffer until we get suitable input. | |
37 | If optional argument INTEGERS-ONLY is non-nil, insist on an integer." | |
38 | (interactive) | |
39 | (let (success | |
40 | (number nil) | |
41 | (predicate (if integers-only 'integerp 'numberp))) | |
42 | (while (not success) | |
43 | (let ((input-string (read-string prompt))) | |
44 | (condition-case () | |
45 | (setq number (read input-string)) | |
46 | (error)) | |
47 | (if (funcall predicate number) | |
48 | (setq success t) | |
49 | (let ((cursor-in-echo-area t)) | |
50 | (message "Please type %s" | |
51 | (if integers-only "an integer" "a number")) | |
52 | (sit-for 1))))) | |
53 | number)) | |
54 | ||
7d18d35c JB |
55 | (defun real-path-name (name &optional default) |
56 | (file-truename (expand-file-name name default))) | |
57 | ||
58 | ;; It's not clear what to return if the mouse is not in FRAME. | |
59 | (defun read-mouse-position (frame) | |
60 | (let ((pos (mouse-position))) | |
61 | (if (eq (car pos) frame) | |
62 | (cdr pos)))) | |
63 | ||
64 | (defun switch-to-other-buffer (arg) | |
65 | "Switch to the previous buffer. | |
66 | With a numeric arg N, switch to the Nth most recent buffer. | |
67 | With an arg of 0, buries the current buffer at the | |
68 | bottom of the buffer stack." | |
69 | (interactive "p") | |
70 | (if (eq arg 0) | |
71 | (bury-buffer (current-buffer))) | |
72 | (switch-to-buffer | |
73 | (if (<= arg 1) (other-buffer (current-buffer)) | |
7c7daa22 | 74 | (nth arg |
e084483d JB |
75 | (apply 'nconc |
76 | (mapcar | |
77 | (lambda (buf) | |
0b9be2e7 | 78 | (if (= ?\ (string-to-char (buffer-name buf))) |
e084483d | 79 | nil |
0b9be2e7 JB |
80 | (list buf))) |
81 | (buffer-list))))))) | |
e15765f5 | 82 | |
efcc2791 SM |
83 | (defun device-class (&optional device) |
84 | "Return the class (color behavior) of DEVICE. | |
85 | This will be one of 'color, 'grayscale, or 'mono. | |
86 | This function exists for compatibility with XEmacs." | |
87 | (cond | |
88 | ((display-color-p device) 'color) | |
89 | ((display-grayscale-p device) 'grayscale) | |
90 | (t 'mono))) | |
91 | ||
31e1d920 ER |
92 | (defalias 'find-face 'internal-find-face) |
93 | (defalias 'get-face 'internal-get-face) | |
94 | (defalias 'try-face-font 'internal-try-face-font) | |
6b4268b0 RS |
95 | |
96 | (defalias 'exec-to-string 'shell-command-to-string) | |
7d18d35c | 97 | \f |
efcc2791 SM |
98 | |
99 | ;; Buffer context | |
100 | ||
101 | (defun buffer-syntactic-context (&optional buffer) | |
102 | "Syntactic context at point in BUFFER. | |
89a5038d | 103 | Either of `string', `comment' or nil. |
efcc2791 SM |
104 | This is an XEmacs compatibility function." |
105 | (with-current-buffer (or buffer (current-buffer)) | |
106 | (let ((state (syntax-ppss (point)))) | |
107 | (cond | |
108 | ((nth 3 state) 'string) | |
109 | ((nth 4 state) 'comment))))) | |
110 | ||
111 | ||
112 | (defun buffer-syntactic-context-depth (&optional buffer) | |
113 | "Syntactic parenthesis depth at point in BUFFER. | |
114 | This is an XEmacs compatibility function." | |
115 | (with-current-buffer (or buffer (current-buffer)) | |
116 | (nth 0 (syntax-ppss (point))))) | |
117 | ||
118 | ||
119 | ;; Extents | |
51566783 RS |
120 | (defun make-extent (beg end &optional buffer) |
121 | (make-overlay beg end buffer)) | |
122 | ||
5e2dfaa4 SM |
123 | (defun extent-properties (extent) (overlay-properties extent)) |
124 | (unless (fboundp 'extent-property) (defalias 'extent-property 'overlay-get)) | |
c9411d2f RS |
125 | |
126 | (defun extent-at (pos &optional object property before) | |
127 | (with-current-buffer (or object (current-buffer)) | |
128 | (let ((overlays (overlays-at pos))) | |
129 | (when property | |
130 | (let (filtered) | |
131 | (while overlays | |
132 | (if (overlay-get (car overlays) property) | |
133 | (setq filtered (cons (car overlays) filtered))) | |
134 | (setq overlays (cdr overlays))) | |
135 | (setq overlays filtered))) | |
136 | (setq overlays | |
137 | (sort overlays | |
138 | (function (lambda (o1 o2) | |
139 | (let ((p1 (or (overlay-get o1 'priority) 0)) | |
140 | (p2 (or (overlay-get o2 'priority) 0))) | |
141 | (or (> p1 p2) | |
142 | (and (= p1 p2) | |
143 | (> (overlay-start o1) (overlay-start o2))))))))) | |
144 | (if before | |
145 | (nth 1 (memq before overlays)) | |
146 | (car overlays))))) | |
147 | ||
51566783 | 148 | (defun set-extent-property (extent prop value) |
c27d895b RS |
149 | ;; Make sure that separate adjacent extents |
150 | ;; with the same mouse-face value | |
151 | ;; do not run together as one extent. | |
152 | (and (eq prop 'mouse-face) | |
153 | (symbolp value) | |
154 | (setq value (list value))) | |
51566783 RS |
155 | (if (eq prop 'duplicable) |
156 | (cond ((and value (not (overlay-get extent prop))) | |
157 | ;; If becoming duplicable, copy all overlayprops to text props. | |
158 | (add-text-properties (overlay-start extent) | |
159 | (overlay-end extent) | |
160 | (overlay-properties extent) | |
161 | (overlay-buffer extent))) | |
162 | ;; If becoming no longer duplicable, remove these text props. | |
163 | ((and (not value) (overlay-get extent prop)) | |
164 | (remove-text-properties (overlay-start extent) | |
165 | (overlay-end extent) | |
166 | (overlay-properties extent) | |
167 | (overlay-buffer extent)))) | |
168 | ;; If extent is already duplicable, put this property | |
169 | ;; on the text as well as on the overlay. | |
170 | (if (overlay-get extent 'duplicable) | |
171 | (put-text-property (overlay-start extent) | |
172 | (overlay-end extent) | |
173 | prop value (overlay-buffer extent)))) | |
174 | (overlay-put extent prop value)) | |
175 | ||
176 | (defun set-extent-face (extent face) | |
177 | (set-extent-property extent 'face face)) | |
178 | ||
5e2dfaa4 SM |
179 | (defun set-extent-end-glyph (extent glyph) |
180 | (set-extent-property extent 'after-string glyph)) | |
181 | ||
51566783 RS |
182 | (defun delete-extent (extent) |
183 | (set-extent-property extent 'duplicable nil) | |
184 | (delete-overlay extent)) | |
185 | \f | |
7d18d35c JB |
186 | ;; Support the Lucid names with `screen' instead of `frame'. |
187 | ||
31e1d920 ER |
188 | (defalias 'current-screen-configuration 'current-frame-configuration) |
189 | (defalias 'delete-screen 'delete-frame) | |
190 | (defalias 'find-file-new-screen 'find-file-other-frame) | |
191 | (defalias 'find-file-read-only-new-screen 'find-file-read-only-other-frame) | |
192 | (defalias 'find-tag-new-screen 'find-tag-other-frame) | |
193 | ;;(defalias 'focus-screen 'focus-frame) | |
194 | (defalias 'iconify-screen 'iconify-frame) | |
195 | (defalias 'mail-new-screen 'mail-other-frame) | |
196 | (defalias 'make-screen-invisible 'make-frame-invisible) | |
197 | (defalias 'make-screen-visible 'make-frame-visible) | |
198 | ;; (defalias 'minibuffer-screen-list 'minibuffer-frame-list) | |
199 | (defalias 'modify-screen-parameters 'modify-frame-parameters) | |
200 | (defalias 'next-screen 'next-frame) | |
201 | ;; (defalias 'next-multiscreen-window 'next-multiframe-window) | |
202 | ;; (defalias 'previous-multiscreen-window 'previous-multiframe-window) | |
203 | ;; (defalias 'redirect-screen-focus 'redirect-frame-focus) | |
204 | (defalias 'redraw-screen 'redraw-frame) | |
205 | ;; (defalias 'screen-char-height 'frame-char-height) | |
206 | ;; (defalias 'screen-char-width 'frame-char-width) | |
207 | ;; (defalias 'screen-configuration-to-register 'frame-configuration-to-register) | |
208 | ;; (defalias 'screen-focus 'frame-focus) | |
31e1d920 ER |
209 | (defalias 'screen-list 'frame-list) |
210 | ;; (defalias 'screen-live-p 'frame-live-p) | |
211 | (defalias 'screen-parameters 'frame-parameters) | |
212 | (defalias 'screen-pixel-height 'frame-pixel-height) | |
213 | (defalias 'screen-pixel-width 'frame-pixel-width) | |
214 | (defalias 'screen-root-window 'frame-root-window) | |
215 | (defalias 'screen-selected-window 'frame-selected-window) | |
216 | (defalias 'lower-screen 'lower-frame) | |
217 | (defalias 'raise-screen 'raise-frame) | |
218 | (defalias 'screen-visible-p 'frame-visible-p) | |
31e1d920 ER |
219 | (defalias 'screenp 'framep) |
220 | (defalias 'select-screen 'select-frame) | |
221 | (defalias 'selected-screen 'selected-frame) | |
222 | ;; (defalias 'set-screen-configuration 'set-frame-configuration) | |
223 | ;; (defalias 'set-screen-height 'set-frame-height) | |
224 | (defalias 'set-screen-position 'set-frame-position) | |
225 | (defalias 'set-screen-size 'set-frame-size) | |
e084483d | 226 | ;; (defalias 'set-screen-width 'set-frame-width) |
31e1d920 ER |
227 | (defalias 'switch-to-buffer-new-screen 'switch-to-buffer-other-frame) |
228 | ;; (defalias 'unfocus-screen 'unfocus-frame) | |
229 | (defalias 'visible-screen-list 'visible-frame-list) | |
230 | (defalias 'window-screen 'window-frame) | |
231 | (defalias 'x-create-screen 'x-create-frame) | |
c731cd93 | 232 | (defalias 'x-new-screen 'make-frame) |
6de6752c | 233 | |
e084483d JB |
234 | (provide 'lucid) |
235 | ||
ab5796a9 | 236 | ;;; arch-tag: 80f9ab46-0b36-4151-86ed-3edb6d449c9e |
60370d40 | 237 | ;;; lucid.el ends here |