Commit | Line | Data |
---|---|---|
60370d40 | 1 | ;;; lucid.el --- emulate some Lucid Emacs functions |
b578f267 | 2 | |
ba318903 | 3 | ;; Copyright (C) 1993, 1995, 2001-2014 Free Software Foundation, Inc. |
6de6752c | 4 | |
34dc21db | 5 | ;; Maintainer: emacs-devel@gnu.org |
284b3043 | 6 | ;; Keywords: emulations |
8f72f03c | 7 | ;; Obsolete-since: 23.2 |
070c251e | 8 | |
6de6752c RS |
9 | ;; This file is part of GNU Emacs. |
10 | ||
d6cba7ae | 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify |
6de6752c | 12 | ;; it under the terms of the GNU General Public License as published by |
d6cba7ae GM |
13 | ;; the Free Software Foundation, either version 3 of the License, or |
14 | ;; (at your option) any later version. | |
6de6752c RS |
15 | |
16 | ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | ;; GNU General Public License for more details. | |
20 | ||
21 | ;; You should have received a copy of the GNU General Public License | |
d6cba7ae | 22 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
6de6752c | 23 | |
60370d40 PJ |
24 | ;;; Commentary: |
25 | ||
b578f267 | 26 | ;;; Code: |
6de6752c | 27 | |
5e2dfaa4 SM |
28 | ;; XEmacs autoloads CL so we might as well make use of it. |
29 | (require 'cl) | |
330fba95 | 30 | |
31e1d920 | 31 | (defalias 'current-time-seconds 'current-time) |
330fba95 | 32 | |
3b787dc3 RS |
33 | (defun read-number (prompt &optional integers-only) |
34 | "Read a number from the minibuffer. | |
35 | Keep reentering the minibuffer until we get suitable input. | |
36 | If optional argument INTEGERS-ONLY is non-nil, insist on an integer." | |
37 | (interactive) | |
38 | (let (success | |
39 | (number nil) | |
40 | (predicate (if integers-only 'integerp 'numberp))) | |
41 | (while (not success) | |
42 | (let ((input-string (read-string prompt))) | |
43 | (condition-case () | |
44 | (setq number (read input-string)) | |
45 | (error)) | |
46 | (if (funcall predicate number) | |
47 | (setq success t) | |
48 | (let ((cursor-in-echo-area t)) | |
49 | (message "Please type %s" | |
50 | (if integers-only "an integer" "a number")) | |
51 | (sit-for 1))))) | |
52 | number)) | |
53 | ||
7d18d35c JB |
54 | (defun real-path-name (name &optional default) |
55 | (file-truename (expand-file-name name default))) | |
56 | ||
57 | ;; It's not clear what to return if the mouse is not in FRAME. | |
58 | (defun read-mouse-position (frame) | |
59 | (let ((pos (mouse-position))) | |
60 | (if (eq (car pos) frame) | |
61 | (cdr pos)))) | |
62 | ||
63 | (defun switch-to-other-buffer (arg) | |
64 | "Switch to the previous buffer. | |
65 | With a numeric arg N, switch to the Nth most recent buffer. | |
66 | With an arg of 0, buries the current buffer at the | |
67 | bottom of the buffer stack." | |
68 | (interactive "p") | |
69 | (if (eq arg 0) | |
70 | (bury-buffer (current-buffer))) | |
71 | (switch-to-buffer | |
72 | (if (<= arg 1) (other-buffer (current-buffer)) | |
7c7daa22 | 73 | (nth arg |
e084483d JB |
74 | (apply 'nconc |
75 | (mapcar | |
76 | (lambda (buf) | |
0b9be2e7 | 77 | (if (= ?\ (string-to-char (buffer-name buf))) |
e084483d | 78 | nil |
0b9be2e7 JB |
79 | (list buf))) |
80 | (buffer-list))))))) | |
e15765f5 | 81 | |
efcc2791 SM |
82 | (defun device-class (&optional device) |
83 | "Return the class (color behavior) of DEVICE. | |
84 | This will be one of 'color, 'grayscale, or 'mono. | |
85 | This function exists for compatibility with XEmacs." | |
86 | (cond | |
87 | ((display-color-p device) 'color) | |
88 | ((display-grayscale-p device) 'grayscale) | |
89 | (t 'mono))) | |
90 | ||
3226d6ca GM |
91 | (defalias 'find-face 'facep) |
92 | (defalias 'get-face 'facep) | |
9a73a6c9 GM |
93 | ;; internal-try-face-font was removed from faces.el in rev 1.139, 1999/07/21. |
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)) | |
20fa59a0 | 128 | (let ((overlays (overlays-at pos 'sorted))) |
c9411d2f RS |
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))) | |
c9411d2f RS |
136 | (if before |
137 | (nth 1 (memq before overlays)) | |
138 | (car overlays))))) | |
139 | ||
51566783 | 140 | (defun set-extent-property (extent prop value) |
c27d895b RS |
141 | ;; Make sure that separate adjacent extents |
142 | ;; with the same mouse-face value | |
143 | ;; do not run together as one extent. | |
144 | (and (eq prop 'mouse-face) | |
145 | (symbolp value) | |
146 | (setq value (list value))) | |
51566783 RS |
147 | (if (eq prop 'duplicable) |
148 | (cond ((and value (not (overlay-get extent prop))) | |
149 | ;; If becoming duplicable, copy all overlayprops to text props. | |
150 | (add-text-properties (overlay-start extent) | |
151 | (overlay-end extent) | |
152 | (overlay-properties extent) | |
153 | (overlay-buffer extent))) | |
154 | ;; If becoming no longer duplicable, remove these text props. | |
155 | ((and (not value) (overlay-get extent prop)) | |
156 | (remove-text-properties (overlay-start extent) | |
157 | (overlay-end extent) | |
158 | (overlay-properties extent) | |
159 | (overlay-buffer extent)))) | |
160 | ;; If extent is already duplicable, put this property | |
161 | ;; on the text as well as on the overlay. | |
162 | (if (overlay-get extent 'duplicable) | |
163 | (put-text-property (overlay-start extent) | |
164 | (overlay-end extent) | |
165 | prop value (overlay-buffer extent)))) | |
166 | (overlay-put extent prop value)) | |
167 | ||
168 | (defun set-extent-face (extent face) | |
169 | (set-extent-property extent 'face face)) | |
170 | ||
5e2dfaa4 SM |
171 | (defun set-extent-end-glyph (extent glyph) |
172 | (set-extent-property extent 'after-string glyph)) | |
173 | ||
51566783 RS |
174 | (defun delete-extent (extent) |
175 | (set-extent-property extent 'duplicable nil) | |
176 | (delete-overlay extent)) | |
177 | \f | |
7d18d35c JB |
178 | ;; Support the Lucid names with `screen' instead of `frame'. |
179 | ||
31e1d920 ER |
180 | (defalias 'current-screen-configuration 'current-frame-configuration) |
181 | (defalias 'delete-screen 'delete-frame) | |
182 | (defalias 'find-file-new-screen 'find-file-other-frame) | |
183 | (defalias 'find-file-read-only-new-screen 'find-file-read-only-other-frame) | |
184 | (defalias 'find-tag-new-screen 'find-tag-other-frame) | |
185 | ;;(defalias 'focus-screen 'focus-frame) | |
186 | (defalias 'iconify-screen 'iconify-frame) | |
187 | (defalias 'mail-new-screen 'mail-other-frame) | |
188 | (defalias 'make-screen-invisible 'make-frame-invisible) | |
189 | (defalias 'make-screen-visible 'make-frame-visible) | |
190 | ;; (defalias 'minibuffer-screen-list 'minibuffer-frame-list) | |
191 | (defalias 'modify-screen-parameters 'modify-frame-parameters) | |
192 | (defalias 'next-screen 'next-frame) | |
193 | ;; (defalias 'next-multiscreen-window 'next-multiframe-window) | |
194 | ;; (defalias 'previous-multiscreen-window 'previous-multiframe-window) | |
195 | ;; (defalias 'redirect-screen-focus 'redirect-frame-focus) | |
196 | (defalias 'redraw-screen 'redraw-frame) | |
197 | ;; (defalias 'screen-char-height 'frame-char-height) | |
198 | ;; (defalias 'screen-char-width 'frame-char-width) | |
199 | ;; (defalias 'screen-configuration-to-register 'frame-configuration-to-register) | |
200 | ;; (defalias 'screen-focus 'frame-focus) | |
31e1d920 ER |
201 | (defalias 'screen-list 'frame-list) |
202 | ;; (defalias 'screen-live-p 'frame-live-p) | |
203 | (defalias 'screen-parameters 'frame-parameters) | |
204 | (defalias 'screen-pixel-height 'frame-pixel-height) | |
205 | (defalias 'screen-pixel-width 'frame-pixel-width) | |
206 | (defalias 'screen-root-window 'frame-root-window) | |
207 | (defalias 'screen-selected-window 'frame-selected-window) | |
208 | (defalias 'lower-screen 'lower-frame) | |
209 | (defalias 'raise-screen 'raise-frame) | |
210 | (defalias 'screen-visible-p 'frame-visible-p) | |
31e1d920 ER |
211 | (defalias 'screenp 'framep) |
212 | (defalias 'select-screen 'select-frame) | |
213 | (defalias 'selected-screen 'selected-frame) | |
214 | ;; (defalias 'set-screen-configuration 'set-frame-configuration) | |
215 | ;; (defalias 'set-screen-height 'set-frame-height) | |
216 | (defalias 'set-screen-position 'set-frame-position) | |
217 | (defalias 'set-screen-size 'set-frame-size) | |
e084483d | 218 | ;; (defalias 'set-screen-width 'set-frame-width) |
31e1d920 ER |
219 | (defalias 'switch-to-buffer-new-screen 'switch-to-buffer-other-frame) |
220 | ;; (defalias 'unfocus-screen 'unfocus-frame) | |
221 | (defalias 'visible-screen-list 'visible-frame-list) | |
222 | (defalias 'window-screen 'window-frame) | |
223 | (defalias 'x-create-screen 'x-create-frame) | |
c731cd93 | 224 | (defalias 'x-new-screen 'make-frame) |
6de6752c | 225 | |
e084483d JB |
226 | (provide 'lucid) |
227 | ||
b3e4c911 GM |
228 | ;; Local Variables: |
229 | ;; byte-compile-warnings: (not cl-functions) | |
230 | ;; End: | |
231 | ||
60370d40 | 232 | ;;; lucid.el ends here |