* filelock.c: Fix unlikely file descriptor leaks.
[emacs.git] / lisp / obsolete / lucid.el
blob713c4e6676b236d08b46733f1397213c09fe7b0e
1 ;;; lucid.el --- emulate some Lucid Emacs functions
3 ;; Copyright (C) 1993, 1995, 2001-2013 Free Software Foundation, Inc.
5 ;; Maintainer: FSF
6 ;; Keywords: emulations
7 ;; Obsolete-since: 23.2
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
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.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24 ;;; Commentary:
26 ;;; Code:
28 ;; XEmacs autoloads CL so we might as well make use of it.
29 (require 'cl)
31 (defalias 'current-time-seconds 'current-time)
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))
54 (defun real-path-name (name &optional default)
55 (file-truename (expand-file-name name default)))
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))))
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))
73 (nth arg
74 (apply 'nconc
75 (mapcar
76 (lambda (buf)
77 (if (= ?\ (string-to-char (buffer-name buf)))
78 nil
79 (list buf)))
80 (buffer-list)))))))
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)))
91 (defalias 'find-face 'facep)
92 (defalias 'get-face 'facep)
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)
96 (defalias 'exec-to-string 'shell-command-to-string)
99 ;; Buffer context
101 (defun buffer-syntactic-context (&optional buffer)
102 "Syntactic context at point in BUFFER.
103 Either of `string', `comment' or nil.
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)))))
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)))))
119 ;; Extents
120 (defun make-extent (beg end &optional buffer)
121 (make-overlay beg end buffer))
123 (defun extent-properties (extent) (overlay-properties extent))
124 (unless (fboundp 'extent-property) (defalias 'extent-property 'overlay-get))
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)))))
148 (defun set-extent-property (extent prop value)
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)))
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))
176 (defun set-extent-face (extent face)
177 (set-extent-property extent 'face face))
179 (defun set-extent-end-glyph (extent glyph)
180 (set-extent-property extent 'after-string glyph))
182 (defun delete-extent (extent)
183 (set-extent-property extent 'duplicable nil)
184 (delete-overlay extent))
186 ;; Support the Lucid names with `screen' instead of `frame'.
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)
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)
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)
226 ;; (defalias 'set-screen-width 'set-frame-width)
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)
232 (defalias 'x-new-screen 'make-frame)
234 (provide 'lucid)
236 ;; Local Variables:
237 ;; byte-compile-warnings: (not cl-functions)
238 ;; End:
240 ;;; lucid.el ends here