Mercurial > hg > xemacs-beta
annotate lisp/frame.el @ 5461:568ec109e73d
Check types (unless `byte-compile-delete-errors' is t), #'char<, #'char=, etc.
src/ChangeLog addition:
2011-04-23 Aidan Kehoe <kehoea@parhasard.net>
* editfns.c:
* editfns.c (syms_of_editfns):
Implement #'char= in cl-extra.el, not here, accepting more than
two arguments as Common Lisp specifies.
lisp/ChangeLog addition:
2011-04-23 Aidan Kehoe <kehoea@parhasard.net>
* cl-extra.el (define-char-comparisons):
Add type-checking when the various character-specific comparison
predicates are used; don't check types if
byte-compile-delete-errors is non-nil at compile-time, instead use
the corresponding built-in numeric byte codes.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sat, 23 Apr 2011 22:42:10 +0100 |
parents | 8b70d37ab80e |
children | ac37a5f7e5be |
rev | line source |
---|---|
428 | 1 ;;; frame.el --- multi-frame management independent of window systems. |
2 | |
1942 | 3 ;; Copyright (C) 1993, 1994, 1996, 1997, 2000, 2001, 2003 |
4 ;; Free Software Foundation, Inc. | |
428 | 5 ;; Copyright (C) 1995, 1996 Ben Wing. |
5080
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
6 ;; Copyright (C) 2010 Didier Verna |
428 | 7 |
8 ;; Maintainer: XEmacs Development Team | |
9 ;; Keywords: internal, dumped | |
10 | |
11 ;; This file is part of XEmacs. | |
12 | |
13 ;; XEmacs is free software; you can redistribute it and/or modify it | |
14 ;; under the terms of the GNU General Public License as published by | |
15 ;; the Free Software Foundation; either version 2, or (at your option) | |
16 ;; any later version. | |
17 | |
18 ;; XEmacs is distributed in the hope that it will be useful, but | |
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
21 ;; General Public License for more details. | |
22 | |
23 ;; You should have received a copy of the GNU General Public License | |
24 ;; along with XEmacs; see the file COPYING. If not, write to the | |
1942 | 25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
428 | 26 ;; Boston, MA 02111-1307, USA. |
27 | |
1942 | 28 ;;; Synched up with: FSF 21.3. |
428 | 29 |
30 ;;; Commentary: | |
31 | |
32 ;; This file is dumped with XEmacs. | |
33 | |
34 ;;; Code: | |
35 | |
1942 | 36 ;; XEmacs addition |
428 | 37 (defgroup frames nil |
38 "Support for Emacs frames and window systems." | |
39 :group 'environment) | |
40 | |
1942 | 41 ;; XEmacs change: No need for `frame-creation-function'. |
428 | 42 |
1942 | 43 ;; XEmacs change: Emacs no longer specifies the minibuffer property here. |
428 | 44 ;;; The initial value given here for this must ask for a minibuffer. |
45 ;;; There must always exist a frame with a minibuffer, and after we | |
46 ;;; delete the terminal frame, this will be the only frame. | |
47 (defcustom initial-frame-plist '(minibuffer t) | |
48 "Plist of frame properties for creating the initial X window frame. | |
49 You can set this in your `.emacs' file; for example, | |
50 (setq initial-frame-plist '(top 1 left 1 width 80 height 55)) | |
51 Properties specified here supersede the values given in `default-frame-plist'. | |
52 The format of this can also be an alist for backward compatibility. | |
53 | |
54 If the value calls for a frame without a minibuffer, and you have not created | |
55 a minibuffer frame on your own, one is created according to | |
56 `minibuffer-frame-plist'. | |
57 | |
58 You can specify geometry-related options for just the initial frame | |
59 by setting this variable in your `.emacs' file; however, they won't | |
60 take effect until Emacs reads `.emacs', which happens after first creating | |
61 the frame. If you want the frame to have the proper geometry as soon | |
62 as it appears, you need to use this three-step process: | |
63 * Specify X resources to give the geometry you want. | |
64 * Set `default-frame-plist' to override these options so that they | |
65 don't affect subsequent frames. | |
66 * Set `initial-frame-plist' in a way that matches the X resources, | |
67 to override what you put in `default-frame-plist'." | |
68 :type 'plist | |
69 :group 'frames) | |
70 | |
71 (defcustom minibuffer-frame-plist '(width 80 height 2 menubar-visible-p nil | |
1942 | 72 default-toolbar-visible-p nil) |
428 | 73 "Plist of frame properties for initially creating a minibuffer frame. |
74 You can set this in your `.emacs' file; for example, | |
75 (setq minibuffer-frame-plist '(top 1 left 1 width 80 height 2)) | |
76 Properties specified here supersede the values given in | |
77 `default-frame-plist'. | |
78 The format of this can also be an alist for backward compatibility." | |
79 :type 'plist | |
80 :group 'frames) | |
81 | |
82 (defcustom pop-up-frame-plist nil | |
83 "Plist of frame properties used when creating pop-up frames. | |
84 Pop-up frames are used for completions, help, and the like. | |
85 This variable can be set in your init file, like this: | |
86 (setq pop-up-frame-plist '(width 80 height 20)) | |
1942 | 87 These supersede the values given in `default-frame-plist', for pop-up frames. |
428 | 88 The format of this can also be an alist for backward compatibility." |
89 :type 'plist | |
90 :group 'frames) | |
91 | |
92 (setq pop-up-frame-function | |
1942 | 93 #'(lambda () |
94 (make-frame pop-up-frame-plist))) | |
428 | 95 |
96 (defcustom special-display-frame-plist '(height 14 width 80 unsplittable t) | |
97 "*Plist of frame properties used when creating special frames. | |
98 Special frames are used for buffers whose names are in | |
99 `special-display-buffer-names' and for buffers whose names match | |
100 one of the regular expressions in `special-display-regexps'. | |
101 This variable can be set in your init file, like this: | |
102 (setq special-display-frame-plist '(width 80 height 20)) | |
103 These supersede the values given in `default-frame-plist'. | |
104 The format of this can also be an alist for backward compatibility." | |
105 :type 'plist | |
106 :group 'frames) | |
107 | |
1942 | 108 ;; XEmacs addition |
428 | 109 (defun safe-alist-to-plist (cruftiness) |
110 (if (consp (car cruftiness)) | |
111 (alist-to-plist cruftiness) | |
112 cruftiness)) | |
113 | |
1942 | 114 ;; XEmacs change: require args to be a plist instead of an alist. |
428 | 115 (defun special-display-popup-frame (buffer &optional args) |
1942 | 116 "Display BUFFER in its own frame, reusing an existing window if any. |
117 Return the window chosen. | |
118 Currently we do not insist on selecting the window within its frame. | |
119 If ARGS is a plist, use it as a list of frame property specs. | |
120 If ARGS is a list whose car is t, | |
121 use (cadr ARGS) as a function to do the work. | |
122 Pass it BUFFER as first arg, and (cddr ARGS) gives the rest of the args." | |
428 | 123 ;; if we can't display simultaneous multiple frames, just return |
124 ;; nil and let the normal behavior take over. | |
125 (and (device-on-window-system-p) | |
126 (if (and args (eq t (car args))) | |
127 (apply (cadr args) buffer (cddr args)) | |
128 (let ((window (get-buffer-window buffer t))) | |
1942 | 129 (setq args (safe-alist-to-plist args)) |
130 (or | |
131 ;; If we have a window already, make it visible. | |
132 (when window | |
133 (let ((frame (window-frame window))) | |
134 (make-frame-visible frame) | |
135 (raise-frame frame) | |
136 window)) | |
137 ;; Reuse the current window if the user requested it. | |
138 (when (lax-plist-get args 'same-window) | |
139 (condition-case nil | |
140 (progn (switch-to-buffer buffer) (selected-window)) | |
141 (error nil))) | |
142 ;; Stay on the same frame if requested. | |
143 (when (or (lax-plist-get args 'same-frame) | |
144 (lax-plist-get args 'same-window)) | |
145 (let* ((pop-up-frames nil) (pop-up-windows t) | |
146 special-display-regexps special-display-buffer-names | |
147 (window (display-buffer buffer))) | |
148 ;; (set-window-dedicated-p window t) | |
149 window)) | |
150 ;; If no window yet, make one in a new frame. | |
151 (let ((frame (make-frame (append args | |
152 (safe-alist-to-plist | |
153 special-display-frame-plist))))) | |
154 (set-window-buffer (frame-selected-window frame) buffer) | |
155 (set-window-dedicated-p (frame-selected-window frame) t) | |
156 (frame-selected-window frame))))))) | |
428 | 157 |
1942 | 158 ;; XEmacs change: comment out |
428 | 159 ;(defun handle-delete-frame (event) |
1942 | 160 ; "Handle delete-frame events from the X server." |
428 | 161 ; (interactive "e") |
162 ; (let ((frame (posn-window (event-start event))) | |
163 ; (i 0) | |
164 ; (tail (frame-list))) | |
165 ; (while tail | |
166 ; (and (frame-visible-p (car tail)) | |
167 ; (not (eq (car tail) frame)) | |
168 ; (setq i (1+ i))) | |
169 ; (setq tail (cdr tail))) | |
170 ; (if (> i 0) | |
171 ; (delete-frame frame t) | |
1942 | 172 ; ;; Gildea@x.org says it is ok to ask questions before terminating. |
173 ; (save-buffers-kill-emacs)))) | |
428 | 174 |
175 ;;;; Arrangement of frames at startup | |
176 | |
1942 | 177 ;; 1) Load the window system startup file from the lisp library and read the |
178 ;; high-priority arguments (-q and the like). The window system startup | |
179 ;; file should create any frames specified in the window system defaults. | |
180 ;; | |
181 ;; 2) If no frames have been opened, we open an initial text frame. | |
182 ;; | |
183 ;; 3) Once the init file is done, we apply any newly set properties | |
184 ;; in initial-frame-plist to the frame. | |
428 | 185 |
1942 | 186 ;; These are now called explicitly at the proper times, |
187 ;; since that is easier to understand. | |
188 ;; Actually using hooks within Emacs is bad for future maintenance. --rms. | |
189 ;; (add-hook 'before-init-hook 'frame-initialize) | |
190 ;; (add-hook 'window-setup-hook 'frame-notice-user-settings) | |
191 | |
192 ;; If we create the initial frame, this is it. | |
428 | 193 (defvar frame-initial-frame nil) |
194 | |
195 ;; Record the properties used in frame-initialize to make the initial frame. | |
196 (defvar frame-initial-frame-plist) | |
197 | |
198 (defvar frame-initial-geometry-arguments nil) | |
199 | |
1942 | 200 ;; XEmacs addition |
428 | 201 (defun canonicalize-frame-plists () |
202 (setq initial-frame-plist (safe-alist-to-plist initial-frame-plist)) | |
203 (setq default-frame-plist (safe-alist-to-plist default-frame-plist))) | |
204 | |
1942 | 205 ;; startup.el calls this function before loading the user's init |
206 ;; file - if there is no frame with a minibuffer open now, create | |
207 ;; one to display messages while loading the init file. | |
428 | 208 (defun frame-initialize () |
1942 | 209 "Create an initial frame if necessary." |
428 | 210 ;; In batch mode, we actually use the initial terminal device for output. |
1942 | 211 ;; XEmacs addition |
428 | 212 (canonicalize-frame-plists) |
1942 | 213 |
428 | 214 (if (not (noninteractive)) |
215 (progn | |
1942 | 216 ;; Turn on special-display processing only if there's a window system. |
217 (setq special-display-function 'special-display-popup-frame) | |
428 | 218 |
219 ;; If there is no frame with a minibuffer besides the terminal | |
220 ;; frame, then we need to create the opening frame. Make sure | |
221 ;; it has a minibuffer, but let initial-frame-plist omit the | |
222 ;; minibuffer spec. | |
223 (or (delq terminal-frame (minibuffer-frame-list)) | |
224 (progn | |
225 (setq frame-initial-frame-plist | |
226 (append initial-frame-plist default-frame-plist)) | |
1942 | 227 ;; XEmacs change: omit the scrollbar settings |
228 ; (or (assq 'horizontal-scroll-bars frame-initial-frame-alist) | |
229 ; (setq frame-initial-frame-alist | |
230 ; (cons '(horizontal-scroll-bars . t) | |
231 ; frame-initial-frame-alist))) | |
428 | 232 (setq default-minibuffer-frame |
233 (setq frame-initial-frame | |
234 (make-frame initial-frame-plist | |
235 (car (delq terminal-device | |
236 (device-list)))))) | |
237 ;; Delete any specifications for window geometry properties | |
238 ;; so that we won't reapply them in frame-notice-user-settings. | |
239 ;; It would be wrong to reapply them then, | |
240 ;; because that would override explicit user resizing. | |
241 (setq initial-frame-plist | |
242 (frame-remove-geometry-props initial-frame-plist)))) | |
243 ;; At this point, we know that we have a frame open, so we | |
1942 | 244 ;; can delete the terminal frame. |
245 ;; XEmacs change: Do it the same way Fkill_emacs does it. -slb | |
428 | 246 (delete-console terminal-console) |
1942 | 247 (setq terminal-frame nil)) |
428 | 248 |
1942 | 249 ;; XEmacs change: omit the pc window-system stuff. |
250 ; ;; No, we're not running a window system. Use make-terminal-frame if | |
251 ; ;; we support that feature, otherwise arrange to cause errors. | |
252 ; (or (eq window-system 'pc) | |
253 ; (setq frame-creation-function | |
254 ; (if (fboundp 'tty-create-frame-with-faces) | |
255 ; 'tty-create-frame-with-faces | |
256 ; (function | |
257 ; (lambda (parameters) | |
258 ; (error | |
259 ; "Can't create multiple frames without a window system")))))) | |
260 )) | |
261 | |
262 (defvar frame-notice-user-settings t | |
263 "Non-nil means function `frame-notice-user-settings' wasn't run yet.") | |
428 | 264 |
1942 | 265 ;; startup.el calls this function after loading the user's init |
266 ;; file. Now default-frame-plist and initial-frame-plist contain | |
267 ;; information to which we must react; do what needs to be done. | |
428 | 268 (defun frame-notice-user-settings () |
1942 | 269 "Act on user's init file settings of frame parameters. |
270 React to settings of `default-frame-plist', `initial-frame-plist' there." | |
271 ;; XEmacs addition | |
272 (canonicalize-frame-plists) | |
428 | 273 |
1942 | 274 ;; XEmacs change: omit menu-bar manipulations. |
275 ; ;; Make menu-bar-mode and default-frame-alist consistent. | |
276 ; (when (boundp 'menu-bar-mode) | |
277 ; (let ((default (assq 'menu-bar-lines default-frame-alist))) | |
278 ; (if default | |
279 ; (setq menu-bar-mode (not (eq (cdr default) 0))) | |
280 ; (setq default-frame-alist | |
281 ; (cons (cons 'menu-bar-lines (if menu-bar-mode 1 0)) | |
282 ; default-frame-alist))))) | |
428 | 283 |
1942 | 284 ;; XEmacs change: omit tool-bar manipulations. |
285 ; ;; Make tool-bar-mode and default-frame-alist consistent. Don't do | |
286 ; ;; it in batch mode since that would leave a tool-bar-lines | |
287 ; ;; parameter in default-frame-alist in a dumped Emacs, which is not | |
288 ; ;; what we want. | |
289 ; (when (and (boundp 'tool-bar-mode) | |
290 ; (not noninteractive)) | |
291 ; (let ((default (assq 'tool-bar-lines default-frame-alist))) | |
292 ; (if default | |
293 ; (setq tool-bar-mode (not (eq (cdr default) 0))) | |
294 ; (setq default-frame-alist | |
295 ; (cons (cons 'tool-bar-lines (if tool-bar-mode 1 0)) | |
296 ; default-frame-alist))))) | |
428 | 297 |
298 ;; Creating and deleting frames may shift the selected frame around, | |
299 ;; and thus the current buffer. Protect against that. We don't | |
300 ;; want to use save-excursion here, because that may also try to set | |
301 ;; the buffer of the selected window, which fails when the selected | |
302 ;; window is the minibuffer. | |
303 (let ((old-buffer (current-buffer))) | |
304 | |
1942 | 305 ;; XEmacs change: omit special handling for MS-DOS |
306 ; (when (and frame-notice-user-settings | |
307 ; (null frame-initial-frame)) | |
308 ; ;; This case happens when we don't have a window system, and | |
309 ; ;; also for MS-DOS frames. | |
310 ; (let ((parms (frame-parameters frame-initial-frame))) | |
311 ; ;; Don't change the frame names. | |
312 ; (setq parms (delq (assq 'name parms) parms)) | |
313 ; ;; Can't modify the minibuffer parameter, so don't try. | |
314 ; (setq parms (delq (assq 'minibuffer parms) parms)) | |
315 ; (modify-frame-parameters nil | |
316 ; (if (null window-system) | |
317 ; (append initial-frame-alist | |
318 ; default-frame-alist | |
319 ; parms | |
320 ; nil) | |
321 ; ;; initial-frame-alist and | |
322 ; ;; default-frame-alist were already | |
323 ; ;; applied in pc-win.el. | |
324 ; parms)) | |
325 ; (if (null window-system) ;; MS-DOS does this differently in pc-win.el | |
326 ; (let ((newparms (frame-parameters)) | |
327 ; (frame (selected-frame))) | |
328 ; (tty-handle-reverse-video frame newparms) | |
329 ; ;; If we changed the background color, we need to update | |
330 ; ;; the background-mode parameter, and maybe some faces, | |
331 ; ;; too. | |
332 ; (when (assq 'background-color newparms) | |
333 ; (unless (or (assq 'background-mode initial-frame-alist) | |
334 ; (assq 'background-mode default-frame-alist)) | |
335 ; (frame-set-background-mode frame)) | |
336 ; (face-set-after-frame-default frame)))))) | |
337 | |
428 | 338 ;; If the initial frame is still around, apply initial-frame-plist |
339 ;; and default-frame-plist to it. | |
1942 | 340 (when (frame-live-p frame-initial-frame) |
341 | |
342 ;; XEmacs change: omit the tool-bar manipulations | |
343 ; ;; When tool-bar has been switched off, correct the frame size | |
344 ; ;; by the lines added in x-create-frame for the tool-bar and | |
345 ; ;; switch `tool-bar-mode' off. | |
346 ; (when (display-graphic-p) | |
347 ; (let ((tool-bar-lines (or (assq 'tool-bar-lines initial-frame-alist) | |
348 ; (assq 'tool-bar-lines default-frame-alist)))) | |
349 ; (when (and tool-bar-originally-present | |
350 ; (or (null tool-bar-lines) | |
351 ; (null (cdr tool-bar-lines)) | |
352 ; (eq 0 (cdr tool-bar-lines)))) | |
353 ; (let* ((char-height (frame-char-height frame-initial-frame)) | |
354 ; (image-height tool-bar-images-pixel-height) | |
355 ; (margin (cond ((and (consp tool-bar-button-margin) | |
356 ; (integerp (cdr tool-bar-button-margin)) | |
357 ; (> tool-bar-button-margin 0)) | |
358 ; (cdr tool-bar-button-margin)) | |
359 ; ((and (integerp tool-bar-button-margin) | |
360 ; (> tool-bar-button-margin 0)) | |
361 ; tool-bar-button-margin) | |
362 ; (t 0))) | |
363 ; (relief (if (and (integerp tool-bar-button-relief) | |
364 ; (> tool-bar-button-relief 0)) | |
365 ; tool-bar-button-relief 3)) | |
366 ; (lines (/ (+ image-height | |
367 ; (* 2 margin) | |
368 ; (* 2 relief) | |
369 ; (1- char-height)) | |
370 ; char-height)) | |
371 ; (height (frame-parameter frame-initial-frame 'height)) | |
372 ; (newparms (list (cons 'height (- height lines)))) | |
373 ; (initial-top (cdr (assq 'top | |
374 ; frame-initial-geometry-arguments))) | |
375 ; (top (frame-parameter frame-initial-frame 'top))) | |
376 ; (when (and (consp initial-top) (eq '- (car initial-top))) | |
377 ; (let ((adjusted-top | |
378 ; (cond ((and (consp top) | |
379 ; (eq '+ (car top))) | |
380 ; (list '+ | |
381 ; (+ (cadr top) | |
382 ; (* lines char-height)))) | |
383 ; ((and (consp top) | |
384 ; (eq '- (car top))) | |
385 ; (list '- | |
386 ; (- (cadr top) | |
387 ; (* lines char-height)))) | |
388 ; (t (+ top (* lines char-height)))))) | |
389 ; (setq newparms | |
390 ; (append newparms | |
391 ; `((top . ,adjusted-top)) | |
392 ; nil)))) | |
393 ; (modify-frame-parameters frame-initial-frame newparms) | |
394 ; (tool-bar-mode -1))))) | |
428 | 395 |
396 ;; The initial frame we create above always has a minibuffer. | |
397 ;; If the user wants to remove it, or make it a minibuffer-only | |
398 ;; frame, then we'll have to delete the selected frame and make a | |
399 ;; new one; you can't remove or add a root window to/from an | |
400 ;; existing frame. | |
401 ;; | |
402 ;; NOTE: default-frame-plist was nil when we created the | |
403 ;; existing frame. We need to explicitly include | |
404 ;; default-frame-plist in the properties of the screen we | |
405 ;; create here, so that its new value, gleaned from the user's | |
406 ;; .emacs file, will be applied to the existing screen. | |
407 (if (not (eq (car | |
408 (or (and (lax-plist-member | |
409 initial-frame-plist 'minibuffer) | |
410 (list (lax-plist-get initial-frame-plist | |
411 'minibuffer))) | |
412 (and (lax-plist-member default-frame-plist | |
413 'minibuffer) | |
414 (list (lax-plist-get default-frame-plist | |
415 'minibuffer))) | |
416 '(t))) | |
417 t)) | |
418 ;; Create the new frame. | |
2367 | 419 (let (props ;new |
420 ) | |
428 | 421 ;; If the frame isn't visible yet, wait till it is. |
422 ;; If the user has to position the window, | |
423 ;; Emacs doesn't know its real position until | |
424 ;; the frame is seen to be visible. | |
425 | |
1942 | 426 ;; XEmacs change: check the initially-unmapped property |
428 | 427 (if (frame-property frame-initial-frame 'initially-unmapped) |
428 nil | |
429 (while (not (frame-visible-p frame-initial-frame)) | |
430 (sleep-for 1))) | |
431 (setq props (frame-properties frame-initial-frame)) | |
1942 | 432 |
428 | 433 ;; Get rid of `name' unless it was specified explicitly before. |
434 (or (lax-plist-member frame-initial-frame-plist 'name) | |
435 (setq props (lax-plist-remprop props 'name))) | |
1942 | 436 |
437 (setq props (append initial-frame-plist | |
438 default-frame-plist | |
428 | 439 props |
440 nil)) | |
1942 | 441 |
428 | 442 ;; Get rid of `reverse', because that was handled |
443 ;; when we first made the frame. | |
444 (laxputf props 'reverse nil) | |
1942 | 445 |
446 ;; XEmacs addition: Get rid of `window-id', otherwise make-frame | |
447 ;; will think we're trying to setup an external widget. | |
428 | 448 (laxremf props 'window-id) |
1942 | 449 |
428 | 450 (if (lax-plist-member frame-initial-geometry-arguments 'height) |
451 (laxremf props 'height)) | |
452 (if (lax-plist-member frame-initial-geometry-arguments 'width) | |
453 (laxremf props 'width)) | |
454 (if (lax-plist-member frame-initial-geometry-arguments 'left) | |
455 (laxremf props 'left)) | |
456 (if (lax-plist-member frame-initial-geometry-arguments 'top) | |
457 (laxremf props 'top)) | |
458 ;; Now create the replacement initial frame. | |
2367 | 459 ;(setq new |
460 (make-frame | |
461 ;; Use the geometry args that created the existing | |
462 ;; frame, rather than the props we get for it. | |
463 (append '(user-size t user-position t) | |
464 frame-initial-geometry-arguments | |
465 props)) | |
466 ;) | |
428 | 467 ;; The initial frame, which we are about to delete, may be |
468 ;; the only frame with a minibuffer. If it is, create a | |
469 ;; new one. | |
470 (or (delq frame-initial-frame (minibuffer-frame-list)) | |
471 (make-initial-minibuffer-frame nil)) | |
472 | |
473 ;; If the initial frame is serving as a surrogate | |
474 ;; minibuffer frame for any frames, we need to wean them | |
475 ;; onto a new frame. The default-minibuffer-frame | |
476 ;; variable must be handled similarly. | |
477 (let ((users-of-initial | |
5367
8b70d37ab80e
Use Common Lisp-derived builtins in a few more places in core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5264
diff
changeset
|
478 (remove-if-not |
428 | 479 #'(lambda (frame) |
480 (and (not (eq frame frame-initial-frame)) | |
481 (eq (window-frame | |
482 (minibuffer-window frame)) | |
5367
8b70d37ab80e
Use Common Lisp-derived builtins in a few more places in core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5264
diff
changeset
|
483 frame-initial-frame))) |
8b70d37ab80e
Use Common Lisp-derived builtins in a few more places in core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5264
diff
changeset
|
484 (frame-list)))) |
428 | 485 (if (or users-of-initial |
486 (eq default-minibuffer-frame frame-initial-frame)) | |
487 | |
488 ;; Choose an appropriate frame. Prefer frames which | |
489 ;; are only minibuffers. | |
490 (let* ((new-surrogate | |
491 (car | |
5367
8b70d37ab80e
Use Common Lisp-derived builtins in a few more places in core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5264
diff
changeset
|
492 (or (remove-if-not |
428 | 493 #'(lambda (frame) |
494 (eq 'only | |
5367
8b70d37ab80e
Use Common Lisp-derived builtins in a few more places in core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5264
diff
changeset
|
495 (frame-property frame 'minibuffer))) |
8b70d37ab80e
Use Common Lisp-derived builtins in a few more places in core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5264
diff
changeset
|
496 (frame-list)) |
428 | 497 (minibuffer-frame-list)))) |
498 (new-minibuffer (minibuffer-window new-surrogate))) | |
499 | |
500 (if (eq default-minibuffer-frame frame-initial-frame) | |
501 (setq default-minibuffer-frame new-surrogate)) | |
502 | |
503 ;; Wean the frames using frame-initial-frame as | |
504 ;; their minibuffer frame. | |
4783
e29fcfd8df5f
Eliminate most core code byte-compile warnings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4759
diff
changeset
|
505 (mapc |
1942 | 506 #'(lambda (frame) |
507 (set-frame-property frame 'minibuffer | |
508 new-minibuffer)) | |
509 users-of-initial)))) | |
428 | 510 |
511 ;; Redirect events enqueued at this frame to the new frame. | |
512 ;; Is this a good idea? | |
513 ;; Probably not, since this whole redirect-frame-focus | |
514 ;; stuff is a load of trash, and so is this function we're in. | |
515 ;; --ben | |
516 ;(redirect-frame-focus frame-initial-frame new) | |
517 | |
518 ;; Finally, get rid of the old frame. | |
519 (delete-frame frame-initial-frame t)) | |
520 | |
521 ;; Otherwise, we don't need all that rigamarole; just apply | |
522 ;; the new properties. | |
523 (let (newprops allprops tail) | |
524 (setq allprops (append initial-frame-plist | |
525 default-frame-plist)) | |
526 (if (lax-plist-member frame-initial-geometry-arguments 'height) | |
527 (laxremf allprops 'height)) | |
528 (if (lax-plist-member frame-initial-geometry-arguments 'width) | |
529 (remf allprops 'width)) | |
530 (if (lax-plist-member frame-initial-geometry-arguments 'left) | |
531 (laxremf allprops 'left)) | |
532 (if (lax-plist-member frame-initial-geometry-arguments 'top) | |
533 (laxremf allprops 'top)) | |
534 (setq tail allprops) | |
535 ;; Find just the props that have changed since we first | |
536 ;; made this frame. Those are the ones actually set by | |
537 ;; the init file. For those props whose values we already knew | |
538 ;; (such as those spec'd by command line options) | |
539 ;; it is undesirable to specify the parm again | |
540 ;; once the user has seen the frame and been able to alter it | |
541 ;; manually. | |
542 (while tail | |
543 (let (newval oldval) | |
544 (setq oldval (lax-plist-get frame-initial-frame-plist | |
545 (car tail))) | |
546 (setq newval (lax-plist-get allprops (car tail))) | |
547 (or (eq oldval newval) | |
548 (laxputf newprops (car tail) newval))) | |
549 (setq tail (cddr tail))) | |
550 (set-frame-properties frame-initial-frame newprops) | |
1942 | 551 ;; XEmacs change: omit the background manipulation |
552 ; ;; If we changed the background color, | |
553 ; ;; we need to update the background-mode parameter | |
554 ; ;; and maybe some faces too. | |
555 ; (when (assq 'background-color newparms) | |
556 ; (unless (assq 'background-mode newparms) | |
557 ; (frame-set-background-mode frame-initial-frame)) | |
558 ; (face-set-after-frame-default frame-initial-frame))))) | |
428 | 559 ))) |
560 | |
561 ;; Restore the original buffer. | |
562 (set-buffer old-buffer) | |
563 | |
564 ;; Make sure the initial frame can be GC'd if it is ever deleted. | |
565 ;; Make sure frame-notice-user-settings does nothing if called twice. | |
1942 | 566 (setq frame-notice-user-settings nil) |
428 | 567 (setq frame-initial-frame nil))) |
568 | |
569 (defun make-initial-minibuffer-frame (device) | |
570 (let ((props (append '(minibuffer only) | |
571 (safe-alist-to-plist minibuffer-frame-plist)))) | |
572 (make-frame props device))) | |
573 | |
574 | |
575 ;;;; Creation of additional frames, and other frame miscellanea | |
576 | |
1942 | 577 (defun modify-all-frames-properties (plist) |
578 "Modify all current and future frames' parameters according to PLIST. | |
579 This changes `default-frame-plist' and possibly `initial-frame-plist'. | |
580 See `set-frame-properties' for more information." | |
581 (dolist (frame (frame-list)) | |
582 (set-frame-properties frame plist)) | |
583 | |
584 ;; XEmacs change: iterate over plists instead of alists | |
585 (map-plist | |
586 #'(lambda (prop val) | |
587 ;; initial-frame-plist needs setting only when | |
588 ;; frame-notice-user-settings is true | |
589 (and frame-notice-user-settings | |
590 (lax-plist-remprop initial-frame-plist prop)) | |
591 (lax-plist-remprop default-frame-plist prop)) | |
592 plist) | |
593 | |
594 (and frame-notice-user-settings | |
595 (setq initial-frame-plist (append initial-frame-plist plist))) | |
596 (setq default-frame-plist (append default-frame-plist plist))) | |
597 | |
428 | 598 (defun get-other-frame () |
1942 | 599 "Return some frame other than the current frame. |
600 Create one if necessary. Note that the minibuffer frame, if separate, | |
601 is not considered (see `next-frame')." | |
428 | 602 (let* ((this (selected-frame)) |
603 ;; search visible frames first | |
604 (next (next-frame this 'visible-nomini))) | |
605 ;; then search iconified frames | |
606 (if (eq this next) | |
607 (setq next (next-frame 'visible-iconic-nomini))) | |
608 (if (eq this next) | |
609 ;; otherwise, make a new frame | |
610 (make-frame) | |
611 next))) | |
612 | |
613 (defun next-multiframe-window () | |
614 "Select the next window, regardless of which frame it is on." | |
615 (interactive) | |
616 (select-window (next-window (selected-window) | |
617 (> (minibuffer-depth) 0) | |
1942 | 618 t)) |
619 ;; XEmacs change: select-window already selects the containing frame | |
620 ;(select-frame-set-input-focus (selected-frame)) | |
621 ) | |
428 | 622 |
623 (defun previous-multiframe-window () | |
624 "Select the previous window, regardless of which frame it is on." | |
625 (interactive) | |
626 (select-window (previous-window (selected-window) | |
627 (> (minibuffer-depth) 0) | |
1942 | 628 t)) |
629 ;; XEmacs change: select-window already selects the containing frame | |
630 ;(select-frame-set-input-focus (selected-frame)) | |
631 ) | |
428 | 632 |
1942 | 633 ;; XEmacs change: Emacs has make-frame-on-display |
428 | 634 (defun make-frame-on-device (type connection &optional props) |
635 "Create a frame of type TYPE on CONNECTION. | |
636 TYPE should be a symbol naming the device type, i.e. one of | |
637 | |
638 x An X display. CONNECTION should be a standard display string | |
639 such as \"unix:0\", or nil for the display specified on the | |
640 command line or in the DISPLAY environment variable. Only if | |
641 support for X was compiled into XEmacs. | |
642 tty A standard TTY connection or terminal. CONNECTION should be | |
643 a TTY device name such as \"/dev/ttyp2\" (as determined by | |
644 the Unix command `tty') or nil for XEmacs' standard input | |
645 and output (usually the TTY in which XEmacs started). Only | |
646 if support for TTY's was compiled into XEmacs. | |
462 | 647 gtk A GTK device. |
428 | 648 mswindows A connection to a machine running Microsoft Windows NT or |
649 Windows 95/97. | |
650 pc A direct-write MS-DOS frame. Not currently implemented. | |
651 | |
652 PROPS should be a plist of properties, as in the call to `make-frame'. | |
653 | |
654 If a connection to CONNECTION already exists, it is reused; otherwise, | |
655 a new connection is opened." | |
656 (make-frame props (make-device type connection props))) | |
657 | |
1942 | 658 ;; XEmacs omission: Emacs has make-frame-command here, but it reduces to |
659 ;; make-frame for us. | |
660 | |
661 ;; XEmacs omission: the following 2 variables are not yet implemented. | |
662 ;(defvar before-make-frame-hook nil | |
663 ; "Functions to run before a frame is created.") | |
664 ; | |
665 ;(defvar after-make-frame-functions nil | |
666 ; "Functions to run after a frame is created. | |
667 ;The functions are run with one arg, the newly created frame.") | |
668 ; | |
669 (defvar after-setting-font-hook nil | |
670 "Functions to run after a frame's font has been changed.") | |
671 | |
428 | 672 ;; Alias, kept temporarily. |
673 (defalias 'new-frame 'make-frame) | |
1942 | 674 (make-obsolete 'new-frame 'make-frame) |
428 | 675 |
1942 | 676 ;; XEmacs change: Emacs has make-frame here. We have it in C, so no need for |
677 ;; frame-creation-function. | |
428 | 678 |
5367
8b70d37ab80e
Use Common Lisp-derived builtins in a few more places in core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5264
diff
changeset
|
679 ;; XEmacs addition: support optional DEVICE argument, use delete-if-not. |
428 | 680 (defun filtered-frame-list (predicate &optional device) |
681 "Return a list of all live frames which satisfy PREDICATE. | |
682 If optional second arg DEVICE is non-nil, restrict the frames | |
683 returned to that device." | |
5367
8b70d37ab80e
Use Common Lisp-derived builtins in a few more places in core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5264
diff
changeset
|
684 (delete-if-not predicate |
8b70d37ab80e
Use Common Lisp-derived builtins in a few more places in core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5264
diff
changeset
|
685 (if device (device-frame-list device) (frame-list)))) |
428 | 686 |
1942 | 687 ;; XEmacs addition: support optional DEVICE argument. |
428 | 688 (defun minibuffer-frame-list (&optional device) |
689 "Return a list of all frames with their own minibuffers. | |
690 If optional second arg DEVICE is non-nil, restrict the frames | |
691 returned to that device." | |
5367
8b70d37ab80e
Use Common Lisp-derived builtins in a few more places in core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5264
diff
changeset
|
692 (delete-if-not |
8b70d37ab80e
Use Common Lisp-derived builtins in a few more places in core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5264
diff
changeset
|
693 #'(lambda (frame) (eq frame (window-frame (minibuffer-window frame)))) |
8b70d37ab80e
Use Common Lisp-derived builtins in a few more places in core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5264
diff
changeset
|
694 (if device (device-frame-list device) (frame-list)))) |
428 | 695 |
1942 | 696 ;; XEmacs omission: Emacs has frames-on-display-list here, but that is |
697 ;; essentially equivalent to supplying the optional DEVICE argument to | |
698 ;; filtered-frame-list. | |
699 | |
700 ;; XEmacs addition: the following two functions make life a lot simpler below. | |
701 (defsubst display-frame (display) | |
702 "Return the active frame for DISPLAY. | |
703 DISPLAY may be a frame, a device, or a console. If it is omitted or nil, | |
704 it defaults to the selected frame." | |
705 (cond | |
706 ((null display) (selected-frame)) | |
707 ((framep display) display) | |
708 ((devicep display) (selected-frame display)) | |
709 ((consolep display) (selected-frame (car (console-device-list display)))) | |
710 (t (error 'wrong-type-argument "Not a frame, device, or console" display)))) | |
711 | |
712 (defsubst display-device (display) | |
713 "Return the device for DISPLAY. | |
714 DISPLAY may be a frame, a device, or a console. If it is omitted or nil, | |
715 it defaults to the selected frame." | |
716 (cond | |
717 ((null display) (selected-device)) | |
718 ((framep display) (frame-device display)) | |
719 ((devicep display) display) | |
720 ((consolep display) (car (console-device-list display))) | |
721 (t (error 'wrong-type-argument "Not a frame, device, or console" display)))) | |
722 | |
723 ;; Emacs compatibility function. We do not allow display names of the type | |
724 ;; HOST:SERVER.SCREEN as Emacs does, but we do handle devices and consoles. | |
725 (defun framep-on-display (&optional display) | |
726 "Return the type of frames on DISPLAY. | |
727 DISPLAY may be a frame, a device, or a console. If it is a frame, its type | |
728 is returned. If DISPLAY is omitted or nil, it defaults to the selected | |
729 frame. All frames on a given device or console are of the same type." | |
730 (cond | |
731 ((null display) (frame-type (selected-frame))) | |
732 ((framep display) (frame-type display)) | |
733 ((devicep display) (device-type display)) | |
734 ((consolep display) (console-type display)) | |
735 (t (error 'wrong-type-argument "Not a frame, device, or console" display)))) | |
736 | |
737 ;; XEmacs addition: Emacs does not have this function. | |
428 | 738 (defun frame-minibuffer-only-p (frame) |
739 "Return non-nil if FRAME is a minibuffer-only frame." | |
740 (eq (frame-root-window frame) (minibuffer-window frame))) | |
741 | |
742 (defun frame-remove-geometry-props (plist) | |
743 "Return the property list PLIST, but with geometry specs removed. | |
744 This deletes all bindings in PLIST for `top', `left', `width', | |
745 `height', `user-size' and `user-position' properties. | |
746 Emacs uses this to avoid overriding explicit moves and resizings from | |
747 the user during startup." | |
748 (setq plist (canonicalize-lax-plist (copy-sequence plist))) | |
4783
e29fcfd8df5f
Eliminate most core code byte-compile warnings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4759
diff
changeset
|
749 (mapc #'(lambda (property) |
e29fcfd8df5f
Eliminate most core code byte-compile warnings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4759
diff
changeset
|
750 (if (lax-plist-member plist property) |
e29fcfd8df5f
Eliminate most core code byte-compile warnings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4759
diff
changeset
|
751 (progn |
e29fcfd8df5f
Eliminate most core code byte-compile warnings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4759
diff
changeset
|
752 (setq frame-initial-geometry-arguments |
e29fcfd8df5f
Eliminate most core code byte-compile warnings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4759
diff
changeset
|
753 (cons property |
e29fcfd8df5f
Eliminate most core code byte-compile warnings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4759
diff
changeset
|
754 (cons (lax-plist-get plist property) |
e29fcfd8df5f
Eliminate most core code byte-compile warnings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4759
diff
changeset
|
755 frame-initial-geometry-arguments))) |
e29fcfd8df5f
Eliminate most core code byte-compile warnings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4759
diff
changeset
|
756 (setq plist (lax-plist-remprop plist property))))) |
e29fcfd8df5f
Eliminate most core code byte-compile warnings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4759
diff
changeset
|
757 '(height width top left user-size user-position)) |
428 | 758 plist) |
759 | |
1942 | 760 ;; XEmacs change: Emacs has focus-follows-mouse here, which lets them |
761 ;; Customize it. XEmacs has it builtin. Should that change? | |
762 | |
763 ;; XEmacs change: we have focus-frame instead of multiple foo-focus-frame | |
764 ;; functions. | |
765 (defun select-frame-set-input-focus (frame) | |
766 "Select FRAME, raise it, and set input focus, if possible." | |
767 (raise-frame frame) | |
768 (focus-frame frame) ;; This also selects FRAME | |
769 ;; XEmacs change: This is a bad idea; you should in general never warp the | |
770 ;; pointer unless the user asks for it. | |
771 ;;(if focus-follows-mouse | |
772 ;; (set-mouse-position (selected-window) (1- (frame-width frame)) 0))) | |
773 ) | |
774 | |
428 | 775 (defun other-frame (arg) |
776 "Select the ARG'th different visible frame, and raise it. | |
777 All frames are arranged in a cyclic order. | |
778 This command selects the frame ARG steps away in that order. | |
779 A negative ARG moves in the opposite order. | |
780 | |
1942 | 781 To make this command work properly, you must tell Emacs |
782 how the system (or the window manager) generally handles | |
783 focus-switching between windows. If moving the mouse onto a window | |
784 selects it (gives it focus), set `focus-follows-mouse' to t. | |
785 Otherwise, that variable should be nil." | |
428 | 786 (interactive "p") |
787 (let ((frame (selected-frame))) | |
788 (while (> arg 0) | |
789 (setq frame (next-frame frame 'visible-nomini)) | |
790 (setq arg (1- arg))) | |
791 (while (< arg 0) | |
792 (setq frame (previous-frame frame 'visible-nomini)) | |
793 (setq arg (1+ arg))) | |
1942 | 794 (select-frame-set-input-focus frame))) |
795 | |
796 (defun iconify-or-deiconify-frame () | |
797 "Iconify the selected frame, or deiconify if it's currently an icon." | |
798 (interactive) | |
799 (if (lax-plist-get (frame-properties) 'visibility) | |
800 (iconify-frame) | |
801 (make-frame-visible))) | |
802 | |
803 (defun make-frame-names-alist () | |
804 (let* ((current-frame (selected-frame)) | |
805 (falist | |
806 (cons | |
807 (cons (frame-property current-frame 'name) current-frame) nil)) | |
808 (frame (next-frame current-frame t))) | |
809 (while (not (eq frame current-frame)) | |
810 (progn | |
811 (setq falist (cons (cons (frame-property frame 'name) frame) falist)) | |
812 (setq frame (next-frame frame t)))) | |
813 falist)) | |
814 | |
815 (defvar frame-name-history nil) | |
816 (defun select-frame-by-name (name) | |
817 "Select the frame on the current terminal whose name is NAME and raise it. | |
818 If there is no frame by that name, signal an error." | |
819 (interactive | |
820 (let* ((frame-names-alist (make-frame-names-alist)) | |
821 (default (car (car frame-names-alist))) | |
822 (input (completing-read | |
823 (format "Select Frame (default %s): " default) | |
824 frame-names-alist nil t nil 'frame-name-history default))) | |
825 ;; XEmacs change: use the last param of completing-read to simplify. | |
826 (list input))) | |
827 (let* ((frame-names-alist (make-frame-names-alist)) | |
828 (frame (cdr (assoc name frame-names-alist)))) | |
829 (or frame | |
830 (error "There is no frame named `%s'" name)) | |
831 (make-frame-visible frame) | |
832 ;; XEmacs change: make-frame-visible implies (raise-frame) | |
833 ;; (raise-frame frame) | |
834 ;; XEmacs change: we defined this function, might as well use it. | |
835 (select-frame-set-input-focus frame))) | |
428 | 836 |
837 ;; XEmacs-added utility functions | |
838 | |
839 (defmacro save-selected-frame (&rest body) | |
840 "Execute forms in BODY, then restore the selected frame. | |
841 The value returned is the value of the last form in BODY." | |
842 (let ((old-frame (gensym "ssf"))) | |
843 `(let ((,old-frame (selected-frame))) | |
844 (unwind-protect | |
845 (progn ,@body) | |
846 (select-frame ,old-frame))))) | |
847 | |
848 (defmacro with-selected-frame (frame &rest body) | |
849 "Execute forms in BODY with FRAME as the selected frame. | |
850 The value returned is the value of the last form in BODY." | |
851 `(save-selected-frame | |
852 (select-frame ,frame) | |
853 ,@body)) | |
854 | |
1942 | 855 ; This is in C in Emacs |
428 | 856 (defun frame-list () |
857 "Return a list of all frames on all devices/consoles." | |
858 ;; Lists are copies, so nconc is safe here. | |
5264
0d43872986b6
Change (apply 'nconc (mapcar ...)) to (mapcan ...); warn about first form.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5080
diff
changeset
|
859 (mapcan #'device-frame-list (device-list))) |
428 | 860 |
861 (defun frame-type (&optional frame) | |
862 "Return the type of the specified frame (e.g. `x' or `tty'). | |
863 This is equivalent to the type of the frame's device. | |
864 Value is `tty' for a tty frame (a character-only terminal), | |
865 `x' for a frame that is an X window, | |
440 | 866 `mswindows' for a frame that is a MS Windows desktop window, |
867 `msprinter' for a frame that is a MS Windows print job, | |
428 | 868 `stream' for a stream frame (which acts like a stdio stream), and |
869 `dead' for a deleted frame." | |
870 (or frame (setq frame (selected-frame))) | |
871 (if (not (frame-live-p frame)) 'dead | |
872 (device-type (frame-device frame)))) | |
873 | |
874 (defun device-or-frame-p (object) | |
875 "Return non-nil if OBJECT is a device or frame." | |
876 (or (devicep object) | |
877 (framep object))) | |
878 | |
879 (defun device-or-frame-type (device-or-frame) | |
880 "Return the type (e.g. `x' or `tty') of DEVICE-OR-FRAME. | |
881 DEVICE-OR-FRAME should be a device or a frame object. See `device-type' | |
882 for a description of the possible types." | |
883 (if (devicep device-or-frame) | |
884 (device-type device-or-frame) | |
885 (frame-type device-or-frame))) | |
886 | |
887 (defun fw-frame (obj) | |
888 "Given a frame or window, return the associated frame. | |
889 Return nil otherwise." | |
890 (cond ((windowp obj) (window-frame obj)) | |
891 ((framep obj) obj) | |
892 (t nil))) | |
893 | |
894 | |
895 ;;;; Frame configurations | |
896 | |
897 (defun current-frame-configuration () | |
898 "Return a list describing the positions and states of all frames. | |
899 Its car is `frame-configuration'. | |
900 Each element of the cdr is a list of the form (FRAME PLIST WINDOW-CONFIG), | |
901 where | |
902 FRAME is a frame object, | |
903 PLIST is a property list specifying some of FRAME's properties, and | |
904 WINDOW-CONFIG is a window configuration object for FRAME." | |
905 (cons 'frame-configuration | |
906 (mapcar (function | |
907 (lambda (frame) | |
908 (list frame | |
909 (frame-properties frame) | |
910 (current-window-configuration frame)))) | |
911 (frame-list)))) | |
912 | |
913 (defun set-frame-configuration (configuration &optional nodelete) | |
914 "Restore the frames to the state described by CONFIGURATION. | |
915 Each frame listed in CONFIGURATION has its position, size, window | |
916 configuration, and other properties set as specified in CONFIGURATION. | |
917 Ordinarily, this function deletes all existing frames not | |
918 listed in CONFIGURATION. But if optional second argument NODELETE | |
919 is given and non-nil, the unwanted frames are iconified instead." | |
920 (or (frame-configuration-p configuration) | |
921 (signal 'wrong-type-argument | |
922 (list 'frame-configuration-p configuration))) | |
1942 | 923 (let ((config-alist (cdr configuration)) |
428 | 924 frames-to-delete) |
1942 | 925 (mapc #'(lambda (frame) |
926 (let ((properties (assq frame config-alist))) | |
927 (if properties | |
928 (progn | |
929 (set-frame-properties | |
930 frame | |
931 ;; Since we can't set a frame's minibuffer status, | |
932 ;; we might as well omit the parameter altogether. | |
933 (lax-plist-remprop (nth 1 properties) 'minibuffer)) | |
934 (set-window-configuration (nth 2 properties))) | |
935 (setq frames-to-delete (cons frame frames-to-delete))))) | |
428 | 936 (frame-list)) |
937 (if nodelete | |
938 ;; Note: making frames invisible here was tried | |
939 ;; but led to some strange behavior--each time the frame | |
940 ;; was made visible again, the window manager asked afresh | |
941 ;; for where to put it. | |
1942 | 942 (mapc #'iconify-frame frames-to-delete) |
943 (mapc #'delete-frame frames-to-delete)))) | |
428 | 944 |
1942 | 945 ; XEmacs change: this function is in subr.el in Emacs. |
946 ; That's because they don't always include frame.el, while we do. | |
428 | 947 |
948 (defun frame-configuration-p (object) | |
949 "Return non-nil if OBJECT seems to be a frame configuration. | |
950 Any list whose car is `frame-configuration' is assumed to be a frame | |
951 configuration." | |
952 (and (consp object) | |
953 (eq (car object) 'frame-configuration))) | |
954 | |
955 | |
1942 | 956 ;;;; Convenience functions for accessing and interactively changing |
957 ;;;; frame parameters. | |
958 | |
959 (defun frame-height (&optional frame) | |
960 "Return number of lines available for display on FRAME. | |
961 If FRAME is omitted, describe the currently selected frame." | |
962 (frame-property frame 'height)) | |
963 | |
964 (defun frame-width (&optional frame) | |
965 "Return number of columns available for display on FRAME. | |
966 If FRAME is omitted, describe the currently selected frame." | |
967 (frame-property frame 'width)) | |
968 | |
969 (defalias 'set-default-font 'set-frame-font) | |
970 | |
971 ;; XEmacs change: this function differs significantly from Emacs. | |
972 (defun set-frame-font (font-name &optional keep-size) | |
973 "Set the font of the selected frame to FONT-NAME. | |
974 When called interactively, prompt for the name of the font to use. | |
975 To get the frame's current default font, use `(face-font-name 'default)'. | |
976 | |
977 The default behavior is to keep the numbers of lines and columns in | |
978 the frame, thus may change its pixel size. If optional KEEP-SIZE is | |
979 non-nil (interactively, prefix argument) the current frame size (in | |
980 pixels) is kept by adjusting the numbers of the lines and columns." | |
981 (interactive | |
982 (let* ((frame (selected-frame)) | |
983 (completion-ignore-case t) | |
984 (font (completing-read "Font name: " | |
985 (mapcar #'list | |
2527 | 986 (font-list "*" frame)) |
1942 | 987 nil nil nil nil |
988 (face-font-name 'default frame)))) | |
989 (list font current-prefix-arg))) | |
990 (let* ((frame (selected-frame)) | |
991 (fht (frame-pixel-height frame)) | |
992 (fwd (frame-pixel-width frame)) | |
993 (face-list-to-change (face-list))) | |
994 (when (eq (device-type) 'mswindows) | |
995 (setq face-list-to-change | |
996 (delq 'border-glyph face-list-to-change))) | |
997 ;; FIXME: Is it sufficient to just change the default face, due to | |
998 ;; face inheritance? | |
999 (dolist (face face-list-to-change) | |
1000 (when (face-font-instance face) | |
1001 (condition-case c | |
1002 (set-face-font face font-name frame) | |
1003 (error | |
1004 (display-error c nil) | |
1005 (sit-for 1))))) | |
1006 (if keep-size | |
1007 (set-frame-pixel-size frame fwd fht))) | |
1008 (run-hooks 'after-setting-font-hook)) | |
1009 | |
1010 (defun set-frame-property (frame prop val) | |
1011 "Set property PROP of FRAME to VAL. See `set-frame-properties'." | |
1012 (set-frame-properties frame (list prop val))) | |
1013 | |
5080
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
1014 (defun set-frame-background-placement (placement) |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
1015 "Set the background placement of the selected frame to PLACEMENT. |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
1016 When called interactively, prompt for the placement to use." |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
1017 (interactive (list (intern (completing-read "Placement: " |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
1018 '(("absolute" absolute) |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
1019 ("relative" relative)) |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
1020 nil t)))) |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
1021 (set-face-background-placement 'default placement (selected-frame))) |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
1022 |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
1023 (defun frame-background-placement () |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
1024 "Retrieve the selected frame's background placement." |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
1025 (interactive) |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
1026 (face-background-placement 'default (selected-frame))) |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
1027 |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
1028 (defun frame-background-placement-instance () |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
1029 "Retrieve the selected frame's background placement instance." |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
1030 (interactive) |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
1031 (face-background-placement-instance 'default (selected-frame))) |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
1032 |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
1033 ;; #### FIXME: misnomers ! The functions below should be called |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
1034 ;; set-frame-<blabla> -- dvl. |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
4783
diff
changeset
|
1035 |
1942 | 1036 ;; XEmacs change: this function differs significantly from Emacs. |
1037 (defun set-background-color (color-name) | |
1038 "Set the background color of the selected frame to COLOR-NAME. | |
1039 When called interactively, prompt for the name of the color to use. | |
1040 To get the frame's current background color, use | |
1041 `(face-background-name 'default)'." | |
1042 (interactive (list (read-color "Color: "))) | |
1043 ;; (set-face-foreground 'text-cursor color-name (selected-frame)) | |
1044 (set-face-background 'default color-name (selected-frame))) | |
1045 | |
1046 ;; XEmacs change: this function differs significantly from Emacs. | |
1047 (defun set-foreground-color (color-name) | |
1048 "Set the foreground color of the selected frame to COLOR-NAME. | |
1049 When called interactively, prompt for the name of the color to use. | |
1050 To get the frame's current foreground color, use | |
1051 `(face-foreground-name 'default)'." | |
1052 (interactive (list (read-color "Color: "))) | |
1053 (set-face-foreground 'default color-name (selected-frame))) | |
1054 | |
1055 ;; XEmacs change: this function differs significantly from Emacs. | |
1056 (defun set-cursor-color (color-name) | |
1057 "Set the text cursor color of the selected frame to COLOR-NAME. | |
1058 When called interactively, prompt for the name of the color to use. | |
1059 To get the frame's current cursor color, use | |
1060 '(face-background-name 'text-cursor)'." | |
1061 (interactive (list (read-color "Color: "))) | |
1062 (set-face-background 'text-cursor color-name (selected-frame))) | |
1063 | |
1064 ;; XEmacs change: this function differs significantly from Emacs. | |
1065 (defun set-mouse-color (color-name) | |
1066 "Set the color of the mouse pointer of the selected frame to COLOR-NAME. | |
1067 When called interactively, prompt for the name of the color to use. | |
1068 To get the frame's current mouse color, use | |
1069 `(face-foreground-name 'pointer)'." | |
1070 (interactive (list (read-color "Color: "))) | |
1071 (set-face-foreground 'pointer color-name (selected-frame))) | |
1072 | |
1073 ;; XEmacs change: this function differs significantly from Emacs. | |
1074 (defun set-border-color (color-name) | |
1075 "Set the color of the border of the selected frame to COLOR-NAME. | |
1076 When called interactively, prompt for the name of the color to use. | |
1077 To get the frame's current border color, use | |
1078 `(face-foreground-name 'border-glyph)'." | |
1079 (interactive (list (read-color "Color: "))) | |
1080 (set-face-foreground 'border-glyph color-name (selected-frame))) | |
1081 | |
1082 ;;; BEGIN XEmacs addition | |
1083 ;;; This is the traditional XEmacs auto-raise and auto-lower, which applies | |
1084 ;;; to all frames. | |
1085 | |
1086 (defcustom auto-raise-frame nil | |
1087 "*If true, frames will be raised to the top when selected. | |
1088 Under X, most ICCCM-compliant window managers will have an option to do this | |
1089 for you, but this variable is provided in case you're using a broken WM." | |
1090 :type 'boolean | |
1091 :group 'frames) | |
1092 | |
1093 (defcustom auto-lower-frame nil | |
1094 "*If true, frames will be lowered to the bottom when no longer selected. | |
1095 Under X, most ICCCM-compliant window managers will have an option to do this | |
1096 for you, but this variable is provided in case you're using a broken WM." | |
1097 :type 'boolean | |
1098 :group 'frames) | |
1099 | |
1100 (defun default-select-frame-hook () | |
1101 "Implement the `auto-raise-frame' variable. | |
1102 For use as the value of `select-frame-hook'." | |
1103 (if auto-raise-frame (raise-frame (selected-frame)))) | |
428 | 1104 |
1942 | 1105 (defun default-deselect-frame-hook () |
1106 "Implement the `auto-lower-frame' variable. | |
1107 For use as the value of `deselect-frame-hook'." | |
1108 (if auto-lower-frame (lower-frame (selected-frame))) | |
1109 (highlight-extent nil nil)) | |
1110 | |
1111 (or select-frame-hook | |
1112 (add-hook 'select-frame-hook 'default-select-frame-hook)) | |
1113 | |
1114 (or deselect-frame-hook | |
1115 (add-hook 'deselect-frame-hook 'default-deselect-frame-hook)) | |
1116 | |
1117 ;;; END XEmacs addition | |
1118 ;;; Following is the Emacs auto-raise/auto-lower interface, which lets the | |
1119 ;;; user select individual frames to auto-raise and auto-lower | |
1120 | |
1121 ;; XEmacs addition: the next two variables do not appear in Emacs | |
1122 (defvar auto-raise-specifier (make-boolean-specifier auto-raise-frame) | |
1123 "Specifier that determines which frames should auto-raise. | |
1124 A value of `t' means that a frame auto-raises; `nil' means it does not.") | |
1125 | |
1126 (defvar auto-lower-specifier (make-boolean-specifier auto-lower-frame) | |
1127 "Specifier that determines which frames should auto-lower. | |
1128 A value of `t' means that a frame auto-lowers; `nil' means it does not.") | |
1129 | |
1130 ;; XEmacs change: use specifiers instead of frame-parameters | |
1131 (defun auto-raise-mode (arg) | |
1132 "Toggle whether or not the selected frame should auto-raise. | |
1133 With arg, turn auto-raise mode on if and only if arg is positive. | |
1134 Note that this controls Emacs's own auto-raise feature. | |
1135 Some window managers allow you to enable auto-raise for certain windows. | |
1136 You can use that for Emacs windows if you wish, but if you do, | |
1137 that is beyond the control of Emacs and this command has no effect on it." | |
1138 (interactive "P") | |
1139 (if (null arg) | |
1140 (setq arg | |
1141 (if (specifier-instance auto-raise-specifier (selected-frame)) | |
1142 -1 1))) | |
1143 (if (> arg 0) | |
1144 (progn | |
1145 (raise-frame (selected-frame)) | |
1146 (add-hook 'select-frame-hook 'default-select-frame-hook)) | |
1147 (set-specifier auto-raise-specifier (> arg 0) (selected-frame)))) | |
1148 | |
1149 ;; XEmacs change: use specifiers instead of frame-parameters | |
1150 (defun auto-lower-mode (arg) | |
1151 "Toggle whether or not the selected frame should auto-lower. | |
1152 With arg, turn auto-lower mode on if and only if arg is positive. | |
1153 Note that this controls Emacs's own auto-lower feature. | |
1154 Some window managers allow you to enable auto-lower for certain windows. | |
1155 You can use that for Emacs windows if you wish, but if you do, | |
1156 that is beyond the control of Emacs and this command has no effect on it." | |
1157 (interactive "P") | |
1158 (if (null arg) | |
1159 (setq arg | |
1160 (if (specifier-instance auto-lower-specifier (selected-frame)) | |
1161 -1 1))) | |
1162 (if (> arg 0) | |
1163 (progn | |
1164 (lower-frame (selected-frame)) | |
1165 (add-hook 'deselect-frame-hook 'default-deselect-frame-hook)) | |
1166 (set-specifier auto-lower-specifier (> arg 0) (selected-frame)))) | |
428 | 1167 |
1942 | 1168 ;; XEmacs omission: XEmacs does not support changing the frame name |
1169 ;(defun set-frame-name (name) | |
1170 ; "Set the name of the selected frame to NAME. | |
1171 ;When called interactively, prompt for the name of the frame. | |
1172 ;The frame name is displayed on the modeline if the terminal displays only | |
1173 ;one frame, otherwise the name is displayed on the frame's caption bar." | |
1174 ; (interactive "sFrame name: ") | |
1175 ; (modify-frame-parameters (selected-frame) | |
1176 ; (list (cons 'name name)))) | |
1177 | |
1178 ;; XEmacs omission: XEmacs attaches scrollbars to windows, not frames. | |
1179 ;; See window-hscroll and ... what? window-start? | |
1180 ;(defun frame-current-scroll-bars (&optional frame) | |
1181 ; "Return the current scroll-bar settings in frame FRAME. | |
1182 ;Value is a cons (VERTICAL . HORISONTAL) where VERTICAL specifies the | |
1183 ;current location of the vertical scroll-bars (left, right, or nil), | |
1184 ;and HORISONTAL specifies the current location of the horisontal scroll | |
1185 ;bars (top, bottom, or nil)." | |
1186 ; (let ((vert (frame-parameter frame 'vertical-scroll-bars)) | |
1187 ; (hor nil)) | |
1188 ; (unless (memq vert '(left right nil)) | |
1189 ; (setq vert default-frame-scroll-bars)) | |
1190 ; (cons vert hor))) | |
1191 | |
1192 ;;;; Frame/display capabilities. | |
1193 (defun display-mouse-p (&optional display) | |
1194 "Return non-nil if DISPLAY has a mouse available. | |
1195 DISPLAY can be a frame, a device, a console, or nil (meaning the | |
1196 selected frame)." | |
4546
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1197 (let (type) |
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1198 (setq display (display-device display) |
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1199 type (device-type display)) |
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1200 (cond |
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1201 ((eq 'mswindows type) |
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1202 (> (declare-boundp mswindows-num-mouse-buttons) 0)) |
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1203 ((device-on-window-system-p display) |
4759
aa5ed11f473b
Remove support for obsolete systems. See xemacs-patches message with ID
Jerry James <james@xemacs.org>
parents:
4689
diff
changeset
|
1204 ;; We assume X, GTK and the rest always have a pointing device. |
4546
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1205 t) |
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1206 ((eq 'tty type) |
2367 | 1207 (and-fboundp 'gpm-is-supported-p |
4546
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1208 (gpm-is-supported-p display))) |
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1209 (t nil)))) |
1942 | 1210 |
1211 (defun display-popup-menus-p (&optional display) | |
1212 "Return non-nil if popup menus are supported on DISPLAY. | |
1213 DISPLAY can be a frame, a device, a console, or nil (meaning the selected | |
1214 frame). Support for popup menus requires that the mouse be available." | |
4546
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1215 (setq display (display-device display)) |
1942 | 1216 (and |
4546
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1217 (featurep 'menubar) |
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1218 (device-on-window-system-p display) |
1942 | 1219 (display-mouse-p display))) |
1220 | |
1221 (defun display-graphic-p (&optional display) | |
1222 "Return non-nil if DISPLAY is a graphic display. | |
1223 Graphical displays are those which are capable of displaying several | |
1224 frames and several different fonts at once. This is true for displays | |
1225 that use a window system such as X, and false for text-only terminals. | |
1226 DISPLAY can be a frame, a device, a console, or nil (meaning the selected | |
1227 frame)." | |
4586
732e3243f2e4
Correct a bug in #'display-graphic-p.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4546
diff
changeset
|
1228 (device-on-window-system-p (display-device display))) |
1942 | 1229 |
1230 (defun display-images-p (&optional display) | |
1231 "Return non-nil if DISPLAY can display images. | |
1232 DISPLAY can be a frame, a device, a console, or nil (meaning the selected | |
1233 frame)." | |
4546
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1234 (and (memq (image-instance-type (specifier-instance |
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1235 (glyph-image xemacs-logo) |
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1236 display)) |
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1237 '(color-pixmap mono-pixmap)) |
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1238 t)) |
1942 | 1239 |
1240 (defalias 'display-multi-frame-p 'display-graphic-p) | |
1241 (defalias 'display-multi-font-p 'display-graphic-p) | |
428 | 1242 |
1942 | 1243 (defun display-selections-p (&optional display) |
1244 "Return non-nil if DISPLAY supports selections. | |
1245 A selection is a way to transfer text or other data between programs | |
1246 via special system buffers called `selection' or `cut buffer' or | |
1247 `clipboard'. | |
1248 DISPLAY can be a frame, a device, a console, or nil (meaning the selected | |
1249 frame)." | |
4546
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1250 (or |
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1251 (device-on-window-system-p display) |
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1252 ;; GPM supports #'get-selection-foreign, but not #'own-selection. |
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1253 (and-fboundp 'gpm-is-supported-p |
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1254 (gpm-is-supported-p display)))) |
1942 | 1255 |
1256 (defun display-screens (&optional display) | |
1257 "Return the number of screens associated with DISPLAY." | |
1258 (device-num-screens (display-device display))) | |
1259 | |
1260 (defun display-pixel-height (&optional display) | |
1261 "Return the height of DISPLAY's screen in pixels. | |
1262 For character terminals, each character counts as a single pixel." | |
1263 (device-pixel-height (display-device display))) | |
1264 | |
1265 (defun display-pixel-width (&optional display) | |
1266 "Return the width of DISPLAY's screen in pixels. | |
1267 For character terminals, each character counts as a single pixel." | |
1268 (device-pixel-width (display-device display))) | |
1269 | |
1270 (defun display-mm-height (&optional display) | |
1271 "Return the height of DISPLAY's screen in millimeters. | |
1272 If the information is unavailable, value is nil." | |
1273 (device-mm-height (display-device display))) | |
1274 | |
1275 (defun display-mm-width (&optional display) | |
1276 "Return the width of DISPLAY's screen in millimeters. | |
1277 If the information is unavailable, value is nil." | |
1278 (device-mm-width (display-device display))) | |
1279 | |
1280 (defun display-backing-store (&optional display) | |
1281 "Return the backing store capability of DISPLAY's screen. | |
1282 The value may be `always', `when-mapped', `not-useful', or nil if | |
1283 the question is inapplicable to a certain kind of display." | |
1284 (device-backing-store (display-device display))) | |
1285 | |
1286 (defun display-save-under (&optional display) | |
1287 "Return non-nil if DISPLAY's screen supports the SaveUnder feature." | |
1288 (device-save-under (display-device display))) | |
1289 | |
1290 (defun display-planes (&optional display) | |
1291 "Return the number of planes supported by DISPLAY." | |
1292 (device-bitplanes (display-device display))) | |
1293 | |
1294 (defun display-color-cells (&optional display) | |
1295 "Return the number of color cells supported by DISPLAY." | |
1296 (device-color-cells (display-device display))) | |
1297 | |
1298 (defun display-visual-class (&optional display) | |
1299 "Returns the visual class of DISPLAY. | |
1300 The value is one of the symbols `static-gray', `gray-scale', | |
1301 `static-color', `pseudo-color', `true-color', or `direct-color'." | |
4546
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1302 (let (type planes) |
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1303 (setq display (display-device display) |
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1304 type (device-type display)) |
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1305 (cond |
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1306 ((eq 'x type) |
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1307 (declare-fboundp (x-display-visual-class display))) |
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1308 ((eq 'gtk type) |
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1309 (declare-fboundp (gtk-display-visual-class display))) |
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1310 ((device-on-window-system-p display) |
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1311 (setq planes (display-planes display)) |
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1312 (cond ((eq planes 1) 'static-gray) |
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1313 ((eq planes 4) 'static-color) |
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1314 ((> planes 8) 'true-color) |
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1315 (t 'pseudo-color))) |
44129f301385
Make functions in frame.el more general.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4506
diff
changeset
|
1316 (t 'static-gray)))) |
1942 | 1317 |
1318 | |
1319 ;; XEmacs change: omit the Emacs 18 compatibility functions: | |
1320 ;; screen-height, screen-width, set-screen-height, and set-screen-width. | |
1321 | |
1322 (defun delete-other-frames (&optional frame) | |
1323 "Delete all frames except FRAME. | |
1324 If FRAME uses another frame's minibuffer, the minibuffer frame is | |
1325 left untouched. FRAME nil or omitted means use the selected frame." | |
1326 (interactive) | |
1327 (unless frame | |
1328 (setq frame (selected-frame))) | |
1329 (let* ((mini-frame (window-frame (minibuffer-window frame))) | |
1330 (frames (delq mini-frame (delq frame (frame-list))))) | |
1331 (mapc 'delete-frame frames))) | |
1332 | |
1333 ;; XEmacs change: we still use delete-frame-hook | |
1334 ;; miscellaneous obsolescence declarations | |
1335 ;(defvaralias 'delete-frame-hook 'delete-frame-functions) | |
1336 ;(make-obsolete-variable 'delete-frame-hook 'delete-frame-functions "21.4") | |
1337 | |
1338 | |
1339 ;; Highlighting trailing whitespace. | |
1340 ;; XEmacs omission: this functionality is provided by whitespace-mode in the | |
1341 ;; text-modes package. | |
1342 | |
1343 ;(make-variable-buffer-local 'show-trailing-whitespace) | |
1344 | |
1345 ;(defcustom show-trailing-whitespace nil | |
1346 ; "*Non-nil means highlight trailing whitespace in face `trailing-whitespace'. | |
1347 ; | |
1348 ;Setting this variable makes it local to the current buffer." | |
1349 ; :tag "Highlight trailing whitespace." | |
1350 ; :type 'boolean | |
1351 ; :group 'font-lock) | |
1352 | |
1353 | |
1354 ;; Scrolling | |
1355 ;; XEmacs omission: This functionality is always enabled on XEmacs. | |
1356 | |
1357 ;(defgroup scrolling nil | |
1358 ; "Scrolling windows." | |
1359 ; :version "21.1" | |
1360 ; :group 'frames) | |
1361 | |
1362 ;(defcustom auto-hscroll-mode t | |
1363 ; "*Allow or disallow automatic scrolling windows horizontally. | |
1364 ;If non-nil, windows are automatically scrolled horizontally to make | |
1365 ;point visible." | |
1366 ; :version "21.1" | |
1367 ; :type 'boolean | |
1368 ; :group 'scrolling) | |
1369 ;(defvaralias 'automatic-hscrolling 'auto-hscroll-mode) | |
1370 | |
1371 | |
1372 ;; Blinking cursor | |
1373 ;; XEmacs omission: this functionality is provided by blink-cursor in the | |
1374 ;; edit-utils package. | |
1375 | |
1376 ; (defgroup cursor nil | |
1377 ; "Displaying text cursors." | |
1378 ; :version "21.1" | |
1379 ; :group 'frames) | |
428 | 1380 |
1942 | 1381 ; (defcustom blink-cursor-delay 0.5 |
1382 ; "*Seconds of idle time after which cursor starts to blink." | |
1383 ; :tag "Delay in seconds." | |
1384 ; :type 'number | |
1385 ; :group 'cursor) | |
1386 | |
1387 ; (defcustom blink-cursor-interval 0.5 | |
1388 ; "*Length of cursor blink interval in seconds." | |
1389 ; :tag "Blink interval in seconds." | |
1390 ; :type 'number | |
1391 ; :group 'cursor) | |
1392 | |
1393 ; (defvar blink-cursor-idle-timer nil | |
1394 ; "Timer started after `blink-cursor-delay' seconds of Emacs idle time. | |
1395 ; The function `blink-cursor-start' is called when the timer fires.") | |
1396 | |
1397 ; (defvar blink-cursor-timer nil | |
1398 ; "Timer started from `blink-cursor-start'. | |
1399 ; This timer calls `blink-cursor' every `blink-cursor-interval' seconds.") | |
1400 | |
1401 ; (defvar blink-cursor-mode nil | |
1402 ; "Non-nil means blinking cursor is active.") | |
1403 | |
1404 ; (defun blink-cursor-mode (arg) | |
1405 ; "Toggle blinking cursor mode. | |
1406 ; With a numeric argument, turn blinking cursor mode on iff ARG is positive. | |
1407 ; When blinking cursor mode is enabled, the cursor of the selected | |
1408 ; window blinks. | |
1409 | |
1410 ; Note that this command is effective only when Emacs | |
1411 ; displays through a window system, because then Emacs does its own | |
1412 ; cursor display. On a text-only terminal, this is not implemented." | |
1413 ; (interactive "P") | |
1414 ; (let ((on-p (if (null arg) | |
1415 ; (not blink-cursor-mode) | |
1416 ; (> (prefix-numeric-value arg) 0)))) | |
1417 ; (if blink-cursor-idle-timer | |
1418 ; (cancel-timer blink-cursor-idle-timer)) | |
1419 ; (if blink-cursor-timer | |
1420 ; (cancel-timer blink-cursor-timer)) | |
1421 ; (setq blink-cursor-idle-timer nil | |
1422 ; blink-cursor-timer nil | |
1423 ; blink-cursor-mode nil) | |
1424 ; (if on-p | |
1425 ; (progn | |
1426 ; ;; Hide the cursor. | |
1427 ; ;(internal-show-cursor nil nil) | |
1428 ; (setq blink-cursor-idle-timer | |
1429 ; (run-with-idle-timer blink-cursor-delay | |
1430 ; blink-cursor-delay | |
1431 ; 'blink-cursor-start)) | |
1432 ; (setq blink-cursor-mode t)) | |
1433 ; (internal-show-cursor nil t)))) | |
1434 | |
1435 ; ;; Note that this is really initialized from startup.el before | |
1436 ; ;; the init-file is read. | |
1437 | |
1438 ; (defcustom blink-cursor nil | |
1439 ; "*Non-nil means blinking cursor mode is active." | |
1440 ; :group 'cursor | |
1441 ; :tag "Blinking cursor" | |
1442 ; :type 'boolean | |
1443 ; :set #'(lambda (symbol value) | |
1444 ; (set-default symbol value) | |
1445 ; (blink-cursor-mode (or value 0)))) | |
428 | 1446 |
1942 | 1447 ; (defun blink-cursor-start () |
1448 ; "Timer function called from the timer `blink-cursor-idle-timer'. | |
1449 ; This starts the timer `blink-cursor-timer', which makes the cursor blink | |
1450 ; if appropriate. It also arranges to cancel that timer when the next | |
1451 ; command starts, by installing a pre-command hook." | |
1452 ; (when (null blink-cursor-timer) | |
1453 ; (add-hook 'pre-command-hook 'blink-cursor-end) | |
1454 ; (setq blink-cursor-timer | |
1455 ; (run-with-timer blink-cursor-interval blink-cursor-interval | |
1456 ; 'blink-cursor-timer-function)))) | |
1457 | |
1458 ; (defun blink-cursor-timer-function () | |
1459 ; "Timer function of timer `blink-cursor-timer'." | |
1460 ; (internal-show-cursor nil (not (internal-show-cursor-p)))) | |
1461 | |
1462 ; (defun blink-cursor-end () | |
1463 ; "Stop cursor blinking. | |
1464 ; This is installed as a pre-command hook by `blink-cursor-start'. | |
1465 ; When run, it cancels the timer `blink-cursor-timer' and removes | |
1466 ; itself as a pre-command hook." | |
1467 ; (remove-hook 'pre-command-hook 'blink-cursor-end) | |
1468 ; (internal-show-cursor nil t) | |
1469 ; (cancel-timer blink-cursor-timer) | |
1470 ; (setq blink-cursor-timer nil)) | |
1471 | |
428 | 1472 |
1942 | 1473 ;; Hourglass pointer |
1474 ;; XEmacs omission: this functionality is provided elsewhere. | |
1475 | |
1476 ; (defcustom display-hourglass t | |
1477 ; "*Non-nil means show an hourglass pointer when running under a window system." | |
1478 ; :tag "Hourglass pointer" | |
1479 ; :type 'boolean | |
1480 ; :group 'cursor) | |
1481 | |
1482 ; (defcustom hourglass-delay 1 | |
1483 ; "*Seconds to wait before displaying an hourglass pointer." | |
1484 ; :tag "Hourglass delay" | |
1485 ; :type 'number | |
1486 ; :group 'cursor) | |
1487 | |
1488 ; | |
1489 ; (defcustom cursor-in-non-selected-windows t | |
1490 ; "*Non-nil means show a hollow box cursor in non-selected-windows. | |
1491 ; If nil, don't show a cursor except in the selected window. | |
1492 ; Use Custom to set this variable to get the display updated." | |
1493 ; :tag "Cursor in non-selected windows" | |
1494 ; :type 'boolean | |
1495 ; :group 'cursor | |
1496 ; :set #'(lambda (symbol value) | |
1497 ; (set-default symbol value) | |
1498 ; (force-mode-line-update t))) | |
1499 | |
1500 | |
1501 ;;;; Key bindings | |
1502 ;; XEmacs change: these keybindings are in keydef.el. | |
1503 | |
1504 ;(define-key ctl-x-5-map "2" 'make-frame-command) | |
1505 ;(define-key ctl-x-5-map "1" 'delete-other-frames) | |
1506 ;(define-key ctl-x-5-map "0" 'delete-frame) | |
1507 ;(define-key ctl-x-5-map "o" 'other-frame) | |
1508 | |
1509 | |
1510 ;;; XEmacs addition: nothing below this point appears in the Emacs version. | |
1511 | |
428 | 1512 ;;; Iconifying emacs. |
1513 ;;; | |
1514 ;;; The function iconify-emacs replaces every non-iconified emacs window | |
1515 ;;; with a *single* icon. Iconified emacs windows are left alone. When | |
1516 ;;; emacs is in this globally-iconified state, de-iconifying any emacs icon | |
1517 ;;; will uniconify all frames that were visible, and iconify all frames | |
1518 ;;; that were not. This is done by temporarily changing the value of | |
1519 ;;; `map-frame-hook' to `deiconify-emacs' (which should never be called | |
1520 ;;; except from the map-frame-hook while emacs is iconified). | |
1521 ;;; | |
1522 ;;; The title of the icon representing all emacs frames is controlled by | |
1523 ;;; the variable `icon-name'. This is done by temporarily changing the | |
1524 ;;; value of `frame-icon-title-format'. Unfortunately, this changes the | |
1525 ;;; titles of all emacs icons, not just the "big" icon. | |
1526 ;;; | |
1527 ;;; It would be nice if existing icons were removed and restored by | |
1528 ;;; iconifying the emacs process, but I couldn't make that work yet. | |
1529 | |
1530 (defvar icon-name nil) ; set this at run time, not load time. | |
1531 | |
1532 (defvar iconification-data nil) | |
1533 | |
1534 (defun iconify-emacs () | |
1535 "Replace every non-iconified FRAME with a *single* icon. | |
1536 Iconified frames are left alone. When XEmacs is in this | |
1537 globally-iconified state, de-iconifying any emacs icon will uniconify | |
1538 all frames that were visible, and iconify all frames that were not." | |
1539 (interactive) | |
1540 (if iconification-data (error "already iconified?")) | |
1541 (let* ((frames (frame-list)) | |
1542 (rest frames) | |
1543 (me (selected-frame)) | |
1544 frame) | |
1545 (while rest | |
1546 (setq frame (car rest)) | |
1547 (setcar rest (cons frame (frame-visible-p frame))) | |
1548 ; (if (memq (cdr (car rest)) '(icon nil)) | |
1549 ; (progn | |
1550 ; (make-frame-visible frame) ; deiconify, and process the X event | |
1551 ; (sleep-for 500 t) ; process X events; I really want to XSync() here | |
1552 ; )) | |
1553 (or (eq frame me) (make-frame-invisible frame)) | |
1554 (setq rest (cdr rest))) | |
1555 (or (boundp 'map-frame-hook) (setq map-frame-hook nil)) | |
1556 (or icon-name | |
1557 (setq icon-name (concat invocation-name " @ " (system-name)))) | |
1558 (setq iconification-data | |
1559 (list frame-icon-title-format map-frame-hook frames) | |
1560 frame-icon-title-format icon-name | |
1561 map-frame-hook 'deiconify-emacs) | |
1562 (iconify-frame me))) | |
1563 | |
1564 | |
1565 (defun deiconify-emacs (&optional ignore) | |
1566 (or iconification-data (error "not iconified?")) | |
1567 (setq frame-icon-title-format (car iconification-data) | |
1568 map-frame-hook (car (cdr iconification-data)) | |
1569 iconification-data (car (cdr (cdr iconification-data)))) | |
1570 (while iconification-data | |
1571 (let ((visibility (cdr (car iconification-data)))) | |
1572 (cond (visibility ;; JV (Note non-nil means visible in XEmacs) | |
1573 (make-frame-visible (car (car iconification-data)))) | |
1574 ; (t ;; (eq visibility 'icon) ;; JV Not in XEmacs!!! | |
1575 ; (make-frame-visible (car (car iconification-data))) | |
1576 ; (sleep-for 500 t) ; process X events; I really want to XSync() here | |
1577 ; (iconify-frame (car (car iconification-data)))) | |
1578 ;; (t nil) | |
1579 )) | |
1580 (setq iconification-data (cdr iconification-data)))) | |
1581 | |
1582 (defun suspend-or-iconify-emacs () | |
3547 | 1583 "Call iconify-emacs if using a window system, otherwise suspend. |
1584 | |
1585 `suspend' here can mean different things; if the current TTY console was | |
1586 created by gnuclient, that console is suspended, and the related devices and | |
1587 frames are removed from the display. Otherwise the Emacs process as a whole | |
1588 is suspended--that is, the traditional Unix suspend takes place. " | |
428 | 1589 (interactive) |
1590 (cond ((device-on-window-system-p) | |
1591 (iconify-emacs)) | |
1592 ((and (eq (device-type) 'tty) | |
502 | 1593 (declare-fboundp (console-tty-controlling-process |
1594 (selected-console)))) | |
428 | 1595 (suspend-console (selected-console))) |
1596 (t | |
1597 (suspend-emacs)))) | |
1598 | |
1599 ;; This is quite a mouthful, but it should be descriptive, as it's | |
1600 ;; bound to C-z. FSF takes the easy way out by binding C-z to | |
1601 ;; different things depending on window-system. We can't do the same, | |
1602 ;; because we allow simultaneous X and TTY consoles. | |
1603 (defun suspend-emacs-or-iconify-frame () | |
3547 | 1604 "Iconify the selected frame if using a window system, otherwise suspend. |
1605 | |
1606 `suspend' here can mean different things; if the current TTY console was | |
1607 created by gnuclient, the console is suspended, and the related devices and | |
1608 frames are removed from the display. Otherwise the Emacs process as a whole | |
1609 is suspended--that is, the traditional Unix suspend takes place. " | |
428 | 1610 (interactive) |
1611 (cond ((device-on-window-system-p) | |
1612 (iconify-frame)) | |
1613 ((and (eq (frame-type) 'tty) | |
502 | 1614 (declare-fboundp (console-tty-controlling-process |
1615 (selected-console)))) | |
428 | 1616 (suspend-console (selected-console))) |
1617 (t | |
1618 (suspend-emacs)))) | |
1619 | |
1620 | |
1621 ;;; Application-specific frame-management | |
1622 | |
1623 (defcustom get-frame-for-buffer-default-frame-name nil | |
1624 "*The default frame to select; see doc of `get-frame-for-buffer'." | |
1625 :type 'string | |
1626 :group 'frames) | |
1627 | |
1628 (defcustom get-frame-for-buffer-default-instance-limit nil | |
1629 "*The default instance limit for creating new frames; | |
1630 see doc of `get-frame-for-buffer'." | |
1631 :type 'integer | |
1632 :group 'frames) | |
1633 | |
1634 (defun get-frame-name-for-buffer (buffer) | |
1635 (let ((mode (and (get-buffer buffer) | |
1636 (save-excursion (set-buffer buffer) | |
1637 major-mode)))) | |
1638 (or (get mode 'frame-name) | |
1639 get-frame-for-buffer-default-frame-name))) | |
1640 | |
1641 (defun get-frame-for-buffer-make-new-frame (buffer &optional frame-name plist) | |
1642 (let* ((fr (make-frame plist)) | |
1643 (w (frame-root-window fr))) | |
1644 ;; | |
1645 ;; Make the one buffer being displayed in this newly created | |
1646 ;; frame be the buffer of interest, instead of something | |
1647 ;; random, so that it won't be shown in two-window mode. | |
1648 ;; Avoid calling switch-to-buffer here, since that's something | |
1649 ;; people might want to call this routine from. | |
1650 ;; | |
1651 ;; (If the root window doesn't have a buffer, then that means | |
1652 ;; there is more than one window on the frame, which can only | |
1653 ;; happen if the user has done something funny on the frame- | |
1654 ;; creation-hook. If that's the case, leave it alone.) | |
1655 ;; | |
1656 (if (window-buffer w) | |
1657 (set-window-buffer w buffer)) | |
1658 fr)) | |
1659 | |
1660 (defcustom get-frame-for-buffer-default-to-current nil | |
1661 "*When non-nil, `get-frame-for-buffer' will default to the selected frame." | |
1662 :type 'boolean | |
1663 :group 'frames) | |
1664 | |
1665 (defun get-frame-for-buffer-noselect (buffer | |
1666 &optional not-this-window-p on-frame) | |
1667 "Return a frame in which to display BUFFER. | |
1668 This is a subroutine of `get-frame-for-buffer' (which see)." | |
1669 (let (name limit) | |
1670 (cond | |
1671 ((or on-frame (eq (selected-window) (minibuffer-window))) | |
1672 ;; don't switch frames if a frame was specified, or to list | |
1673 ;; completions from the minibuffer, etc. | |
1674 nil) | |
1675 | |
1676 ((setq name (get-frame-name-for-buffer buffer)) | |
1677 ;; | |
1678 ;; This buffer's mode expressed a preference for a frame of a particular | |
1679 ;; name. That always takes priority. | |
1680 ;; | |
1681 (let ((limit (get name 'instance-limit)) | |
1682 (defaults (get name 'frame-defaults)) | |
1683 (matching-frames '()) | |
1684 frames frame already-visible) | |
1685 ;; Sort the list so that iconic frames will be found last. They | |
1686 ;; will be used too, but mapped frames take precedence. And | |
1687 ;; fully visible frames come before occluded frames. | |
1688 ;; Hidden frames come after really visible ones | |
1689 (setq frames | |
1690 (sort (frame-list) | |
1691 #'(lambda (s1 s2) | |
1692 (cond ((frame-totally-visible-p s2) | |
1693 nil) | |
1694 ((not (frame-visible-p s2)) | |
1695 (frame-visible-p s1)) | |
1696 ((eq (frame-visible-p s2) 'hidden) | |
1697 (eq (frame-visible-p s1) t )) | |
1698 ((not (frame-totally-visible-p s2)) | |
1699 (and (frame-visible-p s1) | |
1700 (frame-totally-visible-p s1))))))) | |
1701 ;; but the selected frame should come first, even if it's occluded, | |
1702 ;; to minimize thrashing. | |
1703 (setq frames (cons (selected-frame) | |
1704 (delq (selected-frame) frames))) | |
1705 | |
1706 (setq name (symbol-name name)) | |
1707 (while frames | |
1708 (setq frame (car frames)) | |
1709 (if (equal name (frame-name frame)) | |
1710 (if (get-buffer-window buffer frame) | |
1711 (setq already-visible frame | |
1712 frames nil) | |
1713 (setq matching-frames (cons frame matching-frames)))) | |
1714 (setq frames (cdr frames))) | |
1715 (cond (already-visible | |
1716 already-visible) | |
1717 ((or (null matching-frames) | |
1718 (eq limit 0) ; means create with reckless abandon | |
1719 (and limit (< (length matching-frames) limit))) | |
1720 (get-frame-for-buffer-make-new-frame | |
1721 buffer | |
1722 name | |
1723 (alist-to-plist (acons 'name name | |
1724 (plist-to-alist defaults))))) | |
1725 (t | |
1726 ;; do not switch any of the window/buffer associations in an | |
1727 ;; existing frame; this function only picks a frame; the | |
1728 ;; determination of which windows on it get reused is up to | |
1729 ;; display-buffer itself. | |
1730 ;; (or (window-dedicated-p (selected-window)) | |
1731 ;; (switch-to-buffer buffer)) | |
1732 (car matching-frames))))) | |
1733 | |
1734 ((setq limit get-frame-for-buffer-default-instance-limit) | |
1735 ;; | |
1736 ;; This buffer's mode did not express a preference for a frame of a | |
1737 ;; particular name, but the user wants a new frame rather than | |
1738 ;; reusing the existing one. | |
1739 (let* ((defname | |
1740 (or (plist-get default-frame-plist 'name) | |
1741 default-frame-name)) | |
1742 (frames | |
5367
8b70d37ab80e
Use Common Lisp-derived builtins in a few more places in core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5264
diff
changeset
|
1743 (sort (remove-if-not #'(lambda (x) |
8b70d37ab80e
Use Common Lisp-derived builtins in a few more places in core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5264
diff
changeset
|
1744 (or (frame-visible-p x) |
8b70d37ab80e
Use Common Lisp-derived builtins in a few more places in core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5264
diff
changeset
|
1745 (frame-iconified-p x))) |
8b70d37ab80e
Use Common Lisp-derived builtins in a few more places in core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5264
diff
changeset
|
1746 (frame-list)) |
428 | 1747 #'(lambda (s1 s2) |
1748 (cond ((and (frame-visible-p s1) | |
1749 (not (frame-visible-p s2)))) | |
1750 ((and (eq (frame-visible-p s1) t) | |
1751 (eq (frame-visible-p s2) 'hidden))) | |
1752 ((and (frame-visible-p s2) | |
1753 (not (frame-visible-p s1))) | |
1754 nil) | |
1755 ((and (equal (frame-name s1) defname) | |
1756 (not (equal (frame-name s2) defname)))) | |
1757 ((and (equal (frame-name s2) defname) | |
1758 (not (equal (frame-name s1) defname))) | |
1759 nil) | |
1760 ((frame-totally-visible-p s2) | |
1761 nil) | |
1762 (t)))))) | |
1763 ;; put the selected frame last. The user wants a new frame, | |
1764 ;; so don't reuse the existing one unless forced to. | |
1765 (setq frames (append (delq (selected-frame) frames) (list frames))) | |
1766 (if (or (eq limit 0) ; means create with reckless abandon | |
1767 (< (length frames) limit)) | |
1768 (get-frame-for-buffer-make-new-frame buffer) | |
1769 (car frames)))) | |
1770 | |
1771 (not-this-window-p | |
1772 (let ((w-list (windows-of-buffer buffer)) | |
1773 f w | |
1774 (first-choice nil) | |
1775 (second-choice (if get-frame-for-buffer-default-to-current | |
1776 (selected-frame) | |
1777 nil)) | |
1778 (last-resort nil)) | |
1779 (while (and w-list (null first-choice)) | |
1780 (setq w (car w-list) | |
1781 f (window-frame w)) | |
1782 (cond ((eq w (selected-window)) nil) | |
1783 ((not (frame-visible-p f)) | |
1784 (if (null last-resort) | |
1785 (setq last-resort f))) | |
1786 ((eq f (selected-frame)) | |
1787 (setq first-choice f)) | |
1788 ((null second-choice) | |
1789 (setq second-choice f))) | |
1790 (setq w-list (cdr w-list))) | |
1791 (or first-choice second-choice last-resort))) | |
1792 | |
1793 (get-frame-for-buffer-default-to-current (selected-frame)) | |
1794 | |
1795 (t | |
1796 ;; | |
1797 ;; This buffer's mode did not express a preference for a frame of a | |
1798 ;; particular name. So try to find a frame already displaying this | |
1799 ;; buffer. | |
1800 ;; | |
1801 (let ((w (or (get-buffer-window buffer nil) ; check current first | |
1802 (get-buffer-window buffer 'visible) ; then visible | |
1803 (get-buffer-window buffer 0)))) ; then iconic | |
1804 (cond ((null w) | |
1805 ;; It's not in any window - return nil, meaning no frame has | |
1806 ;; preference. | |
1807 nil) | |
1808 (t | |
1809 ;; Otherwise, return the frame of the buffer's window. | |
1810 (window-frame w)))))))) | |
1811 | |
1812 | |
1813 ;; The pre-display-buffer-function is called for effect, so this needs to | |
1814 ;; actually select the frame it wants. Fdisplay_buffer() takes notice of | |
1815 ;; changes to the selected frame. | |
903 | 1816 (defun get-frame-for-buffer (buffer &optional not-this-window-p on-frame |
1817 shrink-to-fit) | |
428 | 1818 "Select and return a frame in which to display BUFFER. |
1819 Normally, the buffer will simply be displayed in the selected frame. | |
3061 | 1820 But if the symbol naming the major-mode of the buffer has a `frame-name' |
428 | 1821 property (which should be a symbol), then the buffer will be displayed in |
1822 a frame of that name. If there is no frame of that name, then one is | |
1823 created. | |
1824 | |
3061 | 1825 If the major-mode doesn't have a `frame-name' property, then the frame |
428 | 1826 named by `get-frame-for-buffer-default-frame-name' will be used. If |
1827 that is nil (the default) then the currently selected frame will used. | |
1828 | |
3061 | 1829 If the frame-name symbol has an `instance-limit' property (an integer) |
428 | 1830 then each time a buffer of the mode in question is displayed, a new frame |
1831 with that name will be created, until there are `instance-limit' of them. | |
1832 If instance-limit is 0, then a new frame will be created each time. | |
1833 | |
1834 If a buffer is already displayed in a frame, then `instance-limit' is | |
1835 ignored, and that frame is used. | |
1836 | |
3061 | 1837 If the frame-name symbol has a `frame-defaults' property, then that is |
428 | 1838 prepended to the `default-frame-plist' when creating a frame for the |
1839 first time. | |
1840 | |
1841 This function may be used as the value of `pre-display-buffer-function', | |
444 | 1842 to cause the `display-buffer' function and its callers to exhibit the |
1843 above behavior." | |
428 | 1844 (let ((frame (get-frame-for-buffer-noselect |
1845 buffer not-this-window-p on-frame))) | |
1846 (if (not (eq frame (selected-frame))) | |
1847 frame | |
1848 (select-frame frame) | |
1849 (or (frame-visible-p frame) | |
1850 ;; If the frame was already visible, just focus on it. | |
1851 ;; If it wasn't visible (it was just created, or it used | |
1852 ;; to be iconified) then uniconify, raise, etc. | |
1853 (make-frame-visible frame)) | |
1854 frame))) | |
1855 | |
1856 (defun frames-of-buffer (&optional buffer visible-only) | |
1857 "Return list of frames that BUFFER is currently being displayed on. | |
1858 If the buffer is being displayed on the currently selected frame, that frame | |
1859 is first in the list. VISIBLE-ONLY will only list non-iconified frames." | |
1860 (let ((list (windows-of-buffer buffer)) | |
1861 (cur-frame (selected-frame)) | |
1862 next-frame frames save-frame) | |
1863 | |
1864 (while list | |
1865 (if (memq (setq next-frame (window-frame (car list))) | |
1866 frames) | |
1867 nil | |
1868 (if (eq cur-frame next-frame) | |
1869 (setq save-frame next-frame) | |
1870 (and | |
1871 (or (not visible-only) | |
1872 (frame-visible-p next-frame)) | |
1873 (setq frames (append frames (list next-frame)))))) | |
1874 (setq list (cdr list))) | |
1875 | |
1876 (if save-frame | |
1877 (append (list save-frame) frames) | |
1878 frames))) | |
1879 | |
1880 (defcustom temp-buffer-shrink-to-fit nil | |
1881 "*When non-nil resize temporary output buffers to minimize blank lines." | |
1882 :type 'boolean | |
1883 :group 'frames) | |
1884 | |
1885 (defcustom temp-buffer-max-height .5 | |
1886 "*Proportion of frame to use for temp windows." | |
1887 :type 'number | |
1888 :group 'frames) | |
1889 | |
4506
bd28481bb0e1
Port #'window-buffer-height, #'fit-window-to-buffer, & window, buf, functions.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4044
diff
changeset
|
1890 ;; See also #'temp-buffer-resize-mode in help.el. |
bd28481bb0e1
Port #'window-buffer-height, #'fit-window-to-buffer, & window, buf, functions.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4044
diff
changeset
|
1891 |
428 | 1892 (defun show-temp-buffer-in-current-frame (buffer) |
444 | 1893 "For use as the value of `temp-buffer-show-function': |
428 | 1894 always displays the buffer in the selected frame, regardless of the behavior |
1895 that would otherwise be introduced by the `pre-display-buffer-function', which | |
1896 is normally set to `get-frame-for-buffer' (which see)." | |
1897 (let ((pre-display-buffer-function nil)) ; turn it off, whatever it is | |
903 | 1898 (let ((window (display-buffer buffer nil nil temp-buffer-shrink-to-fit))) |
428 | 1899 (if (not (eq (last-nonminibuf-frame) (window-frame window))) |
1900 ;; only the pre-display-buffer-function should ever do this. | |
1901 (error "display-buffer switched frames on its own!!")) | |
1902 (setq minibuffer-scroll-window window) | |
1903 (set-window-start window 1) ; obeys narrowing | |
1904 (set-window-point window 1) | |
1905 nil))) | |
1906 | |
1907 (setq temp-buffer-show-function 'show-temp-buffer-in-current-frame) | |
1908 | |
1909 | |
1910 ;; from Bob Weiner <bweiner@pts.mot.com>, modified by Ben Wing | |
1911 | |
1912 ;; By adding primitives to directly access the window hierarchy, | |
1913 ;; we can move many functions into Lisp. We do it this way | |
1914 ;; because the implementations are simpler in Lisp, and because | |
1915 ;; new functions like this can be added without requiring C | |
1916 ;; additions. | |
1917 | |
1918 (defun frame-utmost-window-2 (window position left-right-p major-end-p | |
1919 minor-end-p) | |
1920 ;; LEFT-RIGHT-P means we're looking for the leftmost or rightmost | |
1921 ;; window, instead of the highest or lowest. In this case, we | |
1922 ;; say that the "major axis" goes left-to-right instead of top-to- | |
1923 ;; bottom. The "minor axis" always goes perpendicularly. | |
1924 ;; | |
1925 ;; If MAJOR-END-P is t, we're looking for a windows that abut the | |
1926 ;; end (i.e. right or bottom) of the major axis, instead of the | |
1927 ;; start. | |
1928 ;; | |
1929 ;; If MINOR-END-P is t, then we want to start counting from the | |
1930 ;; end of the minor axis instead of the beginning. | |
1931 ;; | |
1932 ;; Here's the general idea: Imagine we're trying to count the number | |
1933 ;; of windows that abut the top; call this function foo(). So, we | |
1934 ;; start with the root window. If this is a vertical combination | |
1935 ;; window, then foo() applied to the root window is the same as | |
1936 ;; foo() applied to the first child. If the root is a horizontal | |
1937 ;; combination window, then foo() applied to the root is the | |
1938 ;; same as the sum of foo() applied to each of the children. | |
1939 ;; Otherwise, the root window is a leaf window, and foo() is 1. | |
1940 ;; Now it's clear that, each time foo() encounters a leaf window, | |
1941 ;; it's encountering a different window that abuts the top. | |
1942 ;; With a little examining, you can see that foo encounters the | |
1943 ;; top-abutting windows in order from left to right. We can | |
1944 ;; modify foo() to return the nth top-abutting window by simply | |
1945 ;; keeping a global variable that is decremented each time | |
1946 ;; foo() encounters a leaf window and would return 1. If the | |
1947 ;; global counter gets to zero, we've encountered the window | |
1948 ;; we were looking for, so we exit right away using a `throw'. | |
1949 ;; Otherwise, we make sure that all normal paths return nil. | |
1950 | |
1951 (let (child) | |
1952 (cond ((setq child (if left-right-p | |
1953 (window-first-hchild window) | |
1954 (window-first-vchild window))) | |
1955 (if major-end-p | |
1956 (while (window-next-child child) | |
1957 (setq child (window-next-child child)))) | |
1958 (frame-utmost-window-2 child position left-right-p major-end-p | |
1959 minor-end-p)) | |
1960 ((setq child (if left-right-p | |
1961 (window-first-vchild window) | |
1962 (window-first-hchild window))) | |
1963 (if minor-end-p | |
1964 (while (window-next-child child) | |
1965 (setq child (window-next-child child)))) | |
1966 (while child | |
1967 (frame-utmost-window-2 child position left-right-p major-end-p | |
1968 minor-end-p) | |
1969 (setq child (if minor-end-p | |
1970 (window-previous-child child) | |
1971 (window-next-child child)))) | |
1972 nil) | |
1973 (t | |
1974 (setcar position (1- (car position))) | |
1975 (if (= (car position) 0) | |
1976 (throw 'fhw-exit window) | |
1977 nil))))) | |
1978 | |
1979 (defun frame-utmost-window-1 (frame position left-right-p major-end-p) | |
1980 (let (minor-end-p) | |
1981 (or frame (setq frame (selected-frame))) | |
1982 (or position (setq position 0)) | |
1983 (if (>= position 0) | |
1984 (setq position (1+ position)) | |
1985 (setq minor-end-p t) | |
1986 (setq position (- position))) | |
1987 (catch 'fhw-exit | |
1988 ;; we use a cons here as a simple form of call-by-reference. | |
1989 ;; scheme has "boxes" for the same purpose. | |
1990 (frame-utmost-window-2 (frame-root-window frame) (list position) | |
1991 left-right-p major-end-p minor-end-p)))) | |
1992 | |
1993 | |
1994 (defun frame-highest-window (&optional frame position) | |
1995 "Return the highest window on FRAME which is at POSITION. | |
1996 If omitted, FRAME defaults to the currently selected frame. | |
1997 POSITION is used to distinguish between multiple windows that abut | |
1998 the top of the frame: 0 means the leftmost window abutting the | |
1999 top of the frame, 1 the next-leftmost, etc. POSITION can also | |
2000 be less than zero: -1 means the rightmost window abutting the | |
2001 top of the frame, -2 the next-rightmost, etc. | |
2002 If omitted, POSITION defaults to 0, i.e. the leftmost highest window. | |
2003 If there is no window at the given POSITION, return nil." | |
2004 (frame-utmost-window-1 frame position nil nil)) | |
2005 | |
2006 (defun frame-lowest-window (&optional frame position) | |
2007 "Return the lowest window on FRAME which is at POSITION. | |
2008 If omitted, FRAME defaults to the currently selected frame. | |
2009 POSITION is used to distinguish between multiple windows that abut | |
2010 the bottom of the frame: 0 means the leftmost window abutting the | |
2011 bottom of the frame, 1 the next-leftmost, etc. POSITION can also | |
2012 be less than zero: -1 means the rightmost window abutting the | |
2013 bottom of the frame, -2 the next-rightmost, etc. | |
2014 If omitted, POSITION defaults to 0, i.e. the leftmost lowest window. | |
2015 If there is no window at the given POSITION, return nil." | |
2016 (frame-utmost-window-1 frame position nil t)) | |
2017 | |
2018 (defun frame-leftmost-window (&optional frame position) | |
2019 "Return the leftmost window on FRAME which is at POSITION. | |
2020 If omitted, FRAME defaults to the currently selected frame. | |
2021 POSITION is used to distinguish between multiple windows that abut | |
2022 the left edge of the frame: 0 means the highest window abutting the | |
2023 left edge of the frame, 1 the next-highest, etc. POSITION can also | |
2024 be less than zero: -1 means the lowest window abutting the | |
2025 left edge of the frame, -2 the next-lowest, etc. | |
2026 If omitted, POSITION defaults to 0, i.e. the highest leftmost window. | |
2027 If there is no window at the given POSITION, return nil." | |
2028 (frame-utmost-window-1 frame position t nil)) | |
2029 | |
2030 (defun frame-rightmost-window (&optional frame position) | |
2031 "Return the rightmost window on FRAME which is at POSITION. | |
2032 If omitted, FRAME defaults to the currently selected frame. | |
2033 POSITION is used to distinguish between multiple windows that abut | |
2034 the right edge of the frame: 0 means the highest window abutting the | |
2035 right edge of the frame, 1 the next-highest, etc. POSITION can also | |
2036 be less than zero: -1 means the lowest window abutting the | |
2037 right edge of the frame, -2 the next-lowest, etc. | |
2038 If omitted, POSITION defaults to 0, i.e. the highest rightmost window. | |
2039 If there is no window at the given POSITION, return nil." | |
2040 (frame-utmost-window-1 frame position t t)) | |
2041 | |
2042 | |
2043 | |
2044 ;; frame properties. | |
2045 | |
2046 (put 'cursor-color 'frame-property-alias [text-cursor background]) | |
2047 (put 'modeline 'frame-property-alias 'has-modeline-p) | |
2048 | |
2049 | |
2050 (provide 'frame) | |
2051 | |
2052 ;;; frame.el ends here |