Add 2012 to FSF copyright years for Emacs files (do not merge to trunk)
[emacs.git] / lisp / obsolete / lucid.el
blobdd0a47f30ee9c046e674340454e4590f65e75163
1 ;;; lucid.el --- emulate some Lucid Emacs functions
3 ;; Copyright (C) 1993, 1995, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
6 ;; Maintainer: FSF
7 ;; Keywords: emulations
8 ;; Obsolete-since: 23.2
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
25 ;;; Commentary:
27 ;;; Code:
29 ;; XEmacs autoloads CL so we might as well make use of it.
30 (require 'cl)
32 (defalias 'current-time-seconds 'current-time)
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))
55 (defun real-path-name (name &optional default)
56 (file-truename (expand-file-name name default)))
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))))
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))
74 (nth arg
75 (apply 'nconc
76 (mapcar
77 (lambda (buf)
78 (if (= ?\ (string-to-char (buffer-name buf)))
79 nil
80 (list buf)))
81 (buffer-list)))))))
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)))
92 (defalias 'find-face 'internal-find-face)
93 (defalias 'get-face 'internal-get-face)
94 ;; internal-try-face-font was removed from faces.el in rev 1.139, 1999/07/21.
95 ;;;(defalias 'try-face-font 'internal-try-face-font)
97 (defalias 'exec-to-string 'shell-command-to-string)
100 ;; Buffer context
102 (defun buffer-syntactic-context (&optional buffer)
103 "Syntactic context at point in BUFFER.
104 Either of `string', `comment' or nil.
105 This is an XEmacs compatibility function."
106 (with-current-buffer (or buffer (current-buffer))
107 (let ((state (syntax-ppss (point))))
108 (cond
109 ((nth 3 state) 'string)
110 ((nth 4 state) 'comment)))))
113 (defun buffer-syntactic-context-depth (&optional buffer)
114 "Syntactic parenthesis depth at point in BUFFER.
115 This is an XEmacs compatibility function."
116 (with-current-buffer (or buffer (current-buffer))
117 (nth 0 (syntax-ppss (point)))))
120 ;; Extents
121 (defun make-extent (beg end &optional buffer)
122 (make-overlay beg end buffer))
124 (defun extent-properties (extent) (overlay-properties extent))
125 (unless (fboundp 'extent-property) (defalias 'extent-property 'overlay-get))
127 (defun extent-at (pos &optional object property before)
128 (with-current-buffer (or object (current-buffer))
129 (let ((overlays (overlays-at pos)))
130 (when property
131 (let (filtered)
132 (while overlays
133 (if (overlay-get (car overlays) property)
134 (setq filtered (cons (car overlays) filtered)))
135 (setq overlays (cdr overlays)))
136 (setq overlays filtered)))
137 (setq overlays
138 (sort overlays
139 (function (lambda (o1 o2)
140 (let ((p1 (or (overlay-get o1 'priority) 0))
141 (p2 (or (overlay-get o2 'priority) 0)))
142 (or (> p1 p2)
143 (and (= p1 p2)
144 (> (overlay-start o1) (overlay-start o2)))))))))
145 (if before
146 (nth 1 (memq before overlays))
147 (car overlays)))))
149 (defun set-extent-property (extent prop value)
150 ;; Make sure that separate adjacent extents
151 ;; with the same mouse-face value
152 ;; do not run together as one extent.
153 (and (eq prop 'mouse-face)
154 (symbolp value)
155 (setq value (list value)))
156 (if (eq prop 'duplicable)
157 (cond ((and value (not (overlay-get extent prop)))
158 ;; If becoming duplicable, copy all overlayprops to text props.
159 (add-text-properties (overlay-start extent)
160 (overlay-end extent)
161 (overlay-properties extent)
162 (overlay-buffer extent)))
163 ;; If becoming no longer duplicable, remove these text props.
164 ((and (not value) (overlay-get extent prop))
165 (remove-text-properties (overlay-start extent)
166 (overlay-end extent)
167 (overlay-properties extent)
168 (overlay-buffer extent))))
169 ;; If extent is already duplicable, put this property
170 ;; on the text as well as on the overlay.
171 (if (overlay-get extent 'duplicable)
172 (put-text-property (overlay-start extent)
173 (overlay-end extent)
174 prop value (overlay-buffer extent))))
175 (overlay-put extent prop value))
177 (defun set-extent-face (extent face)
178 (set-extent-property extent 'face face))
180 (defun set-extent-end-glyph (extent glyph)
181 (set-extent-property extent 'after-string glyph))
183 (defun delete-extent (extent)
184 (set-extent-property extent 'duplicable nil)
185 (delete-overlay extent))
187 ;; Support the Lucid names with `screen' instead of `frame'.
189 (defalias 'current-screen-configuration 'current-frame-configuration)
190 (defalias 'delete-screen 'delete-frame)
191 (defalias 'find-file-new-screen 'find-file-other-frame)
192 (defalias 'find-file-read-only-new-screen 'find-file-read-only-other-frame)
193 (defalias 'find-tag-new-screen 'find-tag-other-frame)
194 ;;(defalias 'focus-screen 'focus-frame)
195 (defalias 'iconify-screen 'iconify-frame)
196 (defalias 'mail-new-screen 'mail-other-frame)
197 (defalias 'make-screen-invisible 'make-frame-invisible)
198 (defalias 'make-screen-visible 'make-frame-visible)
199 ;; (defalias 'minibuffer-screen-list 'minibuffer-frame-list)
200 (defalias 'modify-screen-parameters 'modify-frame-parameters)
201 (defalias 'next-screen 'next-frame)
202 ;; (defalias 'next-multiscreen-window 'next-multiframe-window)
203 ;; (defalias 'previous-multiscreen-window 'previous-multiframe-window)
204 ;; (defalias 'redirect-screen-focus 'redirect-frame-focus)
205 (defalias 'redraw-screen 'redraw-frame)
206 ;; (defalias 'screen-char-height 'frame-char-height)
207 ;; (defalias 'screen-char-width 'frame-char-width)
208 ;; (defalias 'screen-configuration-to-register 'frame-configuration-to-register)
209 ;; (defalias 'screen-focus 'frame-focus)
210 (defalias 'screen-list 'frame-list)
211 ;; (defalias 'screen-live-p 'frame-live-p)
212 (defalias 'screen-parameters 'frame-parameters)
213 (defalias 'screen-pixel-height 'frame-pixel-height)
214 (defalias 'screen-pixel-width 'frame-pixel-width)
215 (defalias 'screen-root-window 'frame-root-window)
216 (defalias 'screen-selected-window 'frame-selected-window)
217 (defalias 'lower-screen 'lower-frame)
218 (defalias 'raise-screen 'raise-frame)
219 (defalias 'screen-visible-p 'frame-visible-p)
220 (defalias 'screenp 'framep)
221 (defalias 'select-screen 'select-frame)
222 (defalias 'selected-screen 'selected-frame)
223 ;; (defalias 'set-screen-configuration 'set-frame-configuration)
224 ;; (defalias 'set-screen-height 'set-frame-height)
225 (defalias 'set-screen-position 'set-frame-position)
226 (defalias 'set-screen-size 'set-frame-size)
227 ;; (defalias 'set-screen-width 'set-frame-width)
228 (defalias 'switch-to-buffer-new-screen 'switch-to-buffer-other-frame)
229 ;; (defalias 'unfocus-screen 'unfocus-frame)
230 (defalias 'visible-screen-list 'visible-frame-list)
231 (defalias 'window-screen 'window-frame)
232 (defalias 'x-create-screen 'x-create-frame)
233 (defalias 'x-new-screen 'make-frame)
235 (provide 'lucid)
237 ;; arch-tag: 80f9ab46-0b36-4151-86ed-3edb6d449c9e
238 ;;; lucid.el ends here