(frame-delete-all): New function.
[bpt/emacs.git] / lisp / frame.el
1 ;;; frame.el --- multi-frame management independent of window systems.
2
3 ;;;; Copyright (C) 1993, 1994 Free Software Foundation, Inc.
4
5 ;; Maintainer: FSF
6 ;; Keywords: internal
7
8 ;;; This file is part of GNU Emacs.
9 ;;;
10 ;;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;;; it under the terms of the GNU General Public License as published by
12 ;;; the Free Software Foundation; either version 2, or (at your option)
13 ;;; any later version.
14 ;;;
15 ;;; GNU Emacs is distributed in the hope that it will be useful,
16 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;;; GNU General Public License for more details.
19 ;;;
20 ;;; You should have received a copy of the GNU General Public License
21 ;;; along with GNU Emacs; see the file COPYING. If not, write to
22 ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
23
24 ;;; Code:
25
26 (defvar frame-creation-function nil
27 "Window-system dependent function to call to create a new frame.
28 The window system startup file should set this to its frame creation
29 function, which should take an alist of parameters as its argument.")
30
31 ;;; The initial value given here for this must ask for a minibuffer.
32 ;;; There must always exist a frame with a minibuffer, and after we
33 ;;; delete the terminal frame, this will be the only frame.
34 (defvar initial-frame-alist '((minibuffer . t))
35 "Alist of frame parameters for creating the initial X window frame.
36 You can set this in your `.emacs' file; for example,
37 (setq initial-frame-alist '((top . 1) (left . 1) (width . 80) (height . 55)))
38 Parameters specified here supersede the values given in `default-frame-alist'.
39
40 If the value calls for a frame without a minibuffer, and you have not created
41 a minibuffer frame on your own, one is created according to
42 `minibuffer-frame-alist'.
43
44 You can specify geometry-related options for just the initial frame
45 by setting this variable in your `.emacs' file; however, they won't
46 take affect until Emacs reads `.emacs', which happens after first creating
47 the frame. If you want the frame to have the proper geometry as soon
48 as it appears, you need to use this three-step process:
49 * Specify X resources to give the geometry you want.
50 * Set `default-frame-alist' to override these options so that they
51 don't affect subsequent frames.
52 * Set `initial-frame-alist' in a way that matches the X resources,
53 to override what you put in `default-frame-alist'.")
54
55 (defvar minibuffer-frame-alist '((width . 80) (height . 2))
56 "Alist of frame parameters for initially creating a minibuffer frame.
57 You can set this in your `.emacs' file; for example,
58 (setq minibuffer-frame-alist
59 '((top . 1) (left . 1) (width . 80) (height . 2)))
60 Parameters specified here supersede the values given in
61 `default-frame-alist'.")
62
63 (defvar pop-up-frame-alist nil
64 "Alist of frame parameters used when creating pop-up frames.
65 Pop-up frames are used for completions, help, and the like.
66 This variable can be set in your init file, like this:
67 (setq pop-up-frame-alist '((width . 80) (height . 20)))
68 These supersede the values given in `default-frame-alist'.")
69
70 (setq pop-up-frame-function
71 (function (lambda ()
72 (make-frame pop-up-frame-alist))))
73
74 (defvar special-display-frame-alist
75 '((height . 14) (width . 80) (unsplittable . t))
76 "*Alist of frame parameters used when creating special frames.
77 Special frames are used for buffers whose names are in
78 `special-display-buffer-names' and for buffers whose names match
79 one of the regular expressions in `special-display-regexps'.
80 This variable can be set in your init file, like this:
81 (setq special-display-frame-alist '((width . 80) (height . 20)))
82 These supersede the values given in `default-frame-alist'.")
83
84 ;; Display BUFFER in its own frame, reusing an existing window if any.
85 ;; Return the window chosen.
86 ;; Currently we do not insist on selecting the window within its frame.
87 (defun special-display-popup-frame (buffer)
88 (let ((window (get-buffer-window buffer t)))
89 (if window
90 ;; If we have a window already, make it visible.
91 (let ((frame (window-frame window)))
92 (make-frame-visible frame)
93 (raise-frame frame)
94 window)
95 ;; If no window yet, make one in a new frame.
96 (let ((frame (make-frame special-display-frame-alist)))
97 (set-window-buffer (frame-selected-window frame) buffer)
98 (set-window-dedicated-p (frame-selected-window frame) t)
99 (frame-selected-window frame)))))
100
101 (setq special-display-function 'special-display-popup-frame)
102 \f
103 ;;;; Arrangement of frames at startup
104
105 ;;; 1) Load the window system startup file from the lisp library and read the
106 ;;; high-priority arguments (-q and the like). The window system startup
107 ;;; file should create any frames specified in the window system defaults.
108 ;;;
109 ;;; 2) If no frames have been opened, we open an initial text frame.
110 ;;;
111 ;;; 3) Once the init file is done, we apply any newly set parameters
112 ;;; in initial-frame-alist to the frame.
113
114 ;; These are now called explicitly at the proper times,
115 ;; since that is easier to understand.
116 ;; Actually using hooks within Emacs is bad for future maintenance. --rms.
117 ;; (add-hook 'before-init-hook 'frame-initialize)
118 ;; (add-hook 'window-setup-hook 'frame-notice-user-settings)
119
120 ;;; If we create the initial frame, this is it.
121 (defvar frame-initial-frame nil)
122
123 ;; Record the parameters used in frame-initialize to make the initial frame.
124 (defvar frame-initial-frame-alist)
125
126 (defvar frame-initial-geometry-arguments nil)
127
128 ;;; startup.el calls this function before loading the user's init
129 ;;; file - if there is no frame with a minibuffer open now, create
130 ;;; one to display messages while loading the init file.
131 (defun frame-initialize ()
132
133 ;; Are we actually running under a window system at all?
134 (if (and window-system (not noninteractive))
135 (progn
136 ;; If there is no frame with a minibuffer besides the terminal
137 ;; frame, then we need to create the opening frame. Make sure
138 ;; it has a minibuffer, but let initial-frame-alist omit the
139 ;; minibuffer spec.
140 (or (delq terminal-frame (minibuffer-frame-list))
141 (progn
142 (setq frame-initial-frame-alist
143 (append initial-frame-alist default-frame-alist))
144 ;; Record these with their default values
145 ;; if they don't have any values explicitly.
146 (or (assq 'vertical-scroll-bars frame-initial-frame-alist)
147 (setq frame-initial-frame-alist
148 (cons '(vertical-scroll-bars . t)
149 frame-initial-frame-alist)))
150 (or (assq 'horizontal-scroll-bars frame-initial-frame-alist)
151 (setq frame-initial-frame-alist
152 (cons '(horizontal-scroll-bars . t)
153 frame-initial-frame-alist)))
154 (setq default-minibuffer-frame
155 (setq frame-initial-frame
156 (make-frame initial-frame-alist)))
157 ;; Delete any specifications for window geometry parameters
158 ;; so that we won't reapply them in frame-notice-user-settings.
159 ;; It would be wrong to reapply them then,
160 ;; because that would override explicit user resizing.
161 (setq initial-frame-alist
162 (frame-remove-geometry-params initial-frame-alist))))
163 ;; At this point, we know that we have a frame open, so we
164 ;; can delete the terminal frame.
165 (delete-frame terminal-frame)
166 (setq terminal-frame nil))
167
168 ;; No, we're not running a window system. Arrange to cause errors.
169 (setq frame-creation-function
170 (function
171 (lambda (parameters)
172 (error
173 "Can't create multiple frames without a window system"))))))
174
175 ;;; startup.el calls this function after loading the user's init
176 ;;; file. Now default-frame-alist and initial-frame-alist contain
177 ;;; information to which we must react; do what needs to be done.
178 (defun frame-notice-user-settings ()
179
180 ;; Make menu-bar-mode and default-frame-alist consistent.
181 (let ((default (assq 'menu-bar-lines default-frame-alist)))
182 (if default
183 (setq menu-bar-mode (not (eq (cdr default) 0)))
184 (setq default-frame-alist
185 (cons (cons 'menu-bar-lines (if menu-bar-mode 1 0))
186 default-frame-alist))))
187
188 ;; Creating and deleting frames may shift the selected frame around,
189 ;; and thus the current buffer. Protect against that. We don't
190 ;; want to use save-excursion here, because that may also try to set
191 ;; the buffer of the selected window, which fails when the selected
192 ;; window is the minibuffer.
193 (let ((old-buffer (current-buffer)))
194
195 ;; If the initial frame is still around, apply initial-frame-alist
196 ;; and default-frame-alist to it.
197 (if (frame-live-p frame-initial-frame)
198
199 ;; The initial frame we create above always has a minibuffer.
200 ;; If the user wants to remove it, or make it a minibuffer-only
201 ;; frame, then we'll have to delete the current frame and make a
202 ;; new one; you can't remove or add a root window to/from an
203 ;; existing frame.
204 ;;
205 ;; NOTE: default-frame-alist was nil when we created the
206 ;; existing frame. We need to explicitly include
207 ;; default-frame-alist in the parameters of the screen we
208 ;; create here, so that its new value, gleaned from the user's
209 ;; .emacs file, will be applied to the existing screen.
210 (if (not (eq (cdr (or (assq 'minibuffer initial-frame-alist)
211 (assq 'minibuffer default-frame-alist)
212 '(minibuffer . t)))
213 t))
214 ;; Create the new frame.
215 (let (parms new)
216 ;; If the frame isn't visible yet, wait till it is.
217 ;; If the user has to position the window,
218 ;; Emacs doesn't know its real position until
219 ;; the frame is seen to be visible.
220 (while (not (cdr (assq 'visibility
221 (frame-parameters frame-initial-frame))))
222 (sleep-for 1))
223 (setq parms (append initial-frame-alist
224 default-frame-alist
225 (frame-parameters frame-initial-frame)
226 nil))
227 ;; Get rid of `reverse', because that was handled
228 ;; when we first made the frame.
229 (setq parms (cons '(reverse) (delq (assq 'reverse parms) parms)))
230 (if (assq 'height frame-initial-geometry-arguments)
231 (setq parms (frame-delete-all 'height parms)))
232 (if (assq 'width frame-initial-geometry-arguments)
233 (setq parms (frame-delete-all 'width parms)))
234 (if (assq 'left frame-initial-geometry-arguments)
235 (setq parms (frame-delete-all 'left parms)))
236 (if (assq 'top frame-initial-geometry-arguments)
237 (setq parms (frame-delete-all 'top parms)))
238 (setq new
239 (make-frame
240 ;; Use the geometry args that created the existing
241 ;; frame, rather than the parms we get for it.
242 (append frame-initial-geometry-arguments parms)))
243 ;; The initial frame, which we are about to delete, may be
244 ;; the only frame with a minibuffer. If it is, create a
245 ;; new one.
246 (or (delq frame-initial-frame (minibuffer-frame-list))
247 (make-frame (append minibuffer-frame-alist
248 '((minibuffer . only)))))
249
250 ;; If the initial frame is serving as a surrogate
251 ;; minibuffer frame for any frames, we need to wean them
252 ;; onto a new frame. The default-minibuffer-frame
253 ;; variable must be handled similarly.
254 (let ((users-of-initial
255 (filtered-frame-list
256 (function (lambda (frame)
257 (and (not (eq frame frame-initial-frame))
258 (eq (window-frame
259 (minibuffer-window frame))
260 frame-initial-frame)))))))
261 (if (or users-of-initial
262 (eq default-minibuffer-frame frame-initial-frame))
263
264 ;; Choose an appropriate frame. Prefer frames which
265 ;; are only minibuffers.
266 (let* ((new-surrogate
267 (car
268 (or (filtered-frame-list
269 (function
270 (lambda (frame)
271 (eq (cdr (assq 'minibuffer
272 (frame-parameters frame)))
273 'only))))
274 (minibuffer-frame-list))))
275 (new-minibuffer (minibuffer-window new-surrogate)))
276
277 (if (eq default-minibuffer-frame frame-initial-frame)
278 (setq default-minibuffer-frame new-surrogate))
279
280 ;; Wean the frames using frame-initial-frame as
281 ;; their minibuffer frame.
282 (mapcar
283 (function
284 (lambda (frame)
285 (modify-frame-parameters
286 frame (list (cons 'minibuffer new-minibuffer)))))
287 users-of-initial))))
288
289 ;; Redirect events enqueued at this frame to the new frame.
290 ;; Is this a good idea?
291 (redirect-frame-focus frame-initial-frame new)
292
293 ;; Finally, get rid of the old frame.
294 (delete-frame frame-initial-frame t))
295
296 ;; Otherwise, we don't need all that rigamarole; just apply
297 ;; the new parameters.
298 (let (newparms allparms tail)
299 (setq allparms (append initial-frame-alist
300 default-frame-alist))
301 (if (assq 'height frame-initial-geometry-arguments)
302 (setq allparms (frame-delete-all 'height allparms)))
303 (if (assq 'width frame-initial-geometry-arguments)
304 (setq allparms (frame-delete-all 'width allparms)))
305 (if (assq 'left frame-initial-geometry-arguments)
306 (setq allparms (frame-delete-all 'left allparms)))
307 (if (assq 'top frame-initial-geometry-arguments)
308 (setq allparms (frame-delete-all 'top allparms)))
309 (setq tail allparms)
310 ;; Find just the parms that have changed since we first
311 ;; made this frame. Those are the ones actually set by
312 ;; the init file. For those parms whose values we already knew
313 ;; (such as those spec'd by command line options)
314 ;; it is undesirable to specify the parm again
315 ;; once the user has seen the frame and been able to alter it
316 ;; manually.
317 (while tail
318 (let (newval oldval)
319 (setq oldval (cdr (assq (car (car tail))
320 frame-initial-frame-alist)))
321 (setq newval (cdr (assq (car (car tail)) allparms)))
322 (or (eq oldval newval)
323 (setq newparms
324 (cons (cons (car (car tail)) newval) newparms))))
325 (setq tail (cdr tail)))
326 (modify-frame-parameters frame-initial-frame
327 (nreverse newparms)))))
328
329 ;; Restore the original buffer.
330 (set-buffer old-buffer)
331
332 ;; Make sure the initial frame can be GC'd if it is ever deleted.
333 ;; Make sure frame-notice-user-settings does nothing if called twice.
334 (setq frame-initial-frame nil)))
335
336 ;; Delete from ALIST all elements whose car is KEY.
337 ;; Return the modified alist.
338 (defun frame-delete-all (key alist)
339 (let ((tail alist))
340 (while tail
341 (if (eq (car (car tail)) key)
342 (setq alist (delq (car tail) alist)))
343 (setq tail (cdr tail)))
344 alist))
345 \f
346 ;;;; Creation of additional frames, and other frame miscellanea
347
348 ;;; Return some frame other than the current frame, creating one if
349 ;;; necessary. Note that the minibuffer frame, if separate, is not
350 ;;; considered (see next-frame).
351 (defun get-other-frame ()
352 (let ((s (if (equal (next-frame (selected-frame)) (selected-frame))
353 (make-frame)
354 (next-frame (selected-frame)))))
355 s))
356
357 (defun next-multiframe-window ()
358 "Select the next window, regardless of which frame it is on."
359 (interactive)
360 (select-window (next-window (selected-window)
361 (> (minibuffer-depth) 0)
362 t)))
363
364 (defun previous-multiframe-window ()
365 "Select the previous window, regardless of which frame it is on."
366 (interactive)
367 (select-window (previous-window (selected-window)
368 (> (minibuffer-depth) 0)
369 t)))
370
371 ;; Alias, kept temporarily.
372 (defalias 'new-frame 'make-frame)
373 (defun make-frame (&optional parameters)
374 "Create a new frame, displaying the current buffer.
375
376 Optional argument PARAMETERS is an alist of parameters for the new
377 frame. Specifically, PARAMETERS is a list of pairs, each having one
378 of the following forms:
379
380 \(name . STRING) - The frame should be named STRING.
381
382 \(height . NUMBER) - The frame should be NUMBER text lines high. If
383 this parameter is present, the width parameter must also be
384 given.
385
386 \(width . NUMBER) - The frame should be NUMBER characters in width.
387 If this parameter is present, the height parameter must also
388 be given.
389
390 \(minibuffer . t) - the frame should have a minibuffer
391 \(minibuffer . nil) - the frame should have no minibuffer
392 \(minibuffer . only) - the frame should contain only a minibuffer
393 \(minibuffer . WINDOW) - the frame should use WINDOW as its minibuffer window."
394 (interactive)
395 (let ((nframe))
396 (run-hooks 'before-make-frame-hook)
397 (setq nframe (funcall frame-creation-function parameters))
398 (run-hooks 'after-make-frame-hook)
399 nframe))
400
401 (defun filtered-frame-list (predicate)
402 "Return a list of all live frames which satisfy PREDICATE."
403 (let ((frames (frame-list))
404 good-frames)
405 (while (consp frames)
406 (if (funcall predicate (car frames))
407 (setq good-frames (cons (car frames) good-frames)))
408 (setq frames (cdr frames)))
409 good-frames))
410
411 (defun minibuffer-frame-list ()
412 "Return a list of all frames with their own minibuffers."
413 (filtered-frame-list
414 (function (lambda (frame)
415 (eq frame (window-frame (minibuffer-window frame)))))))
416
417 (defun frame-remove-geometry-params (param-list)
418 "Return the parameter list PARAM-LIST, but with geometry specs removed.
419 This deletes all bindings in PARAM-LIST for `top', `left', `width',
420 `height', `user-size' and `user-position' parameters.
421 Emacs uses this to avoid overriding explicit moves and resizings from
422 the user during startup."
423 (setq param-list (cons nil param-list))
424 (let ((tail param-list))
425 (while (consp (cdr tail))
426 (if (and (consp (car (cdr tail)))
427 (memq (car (car (cdr tail)))
428 '(height width top left user-position user-size)))
429 (progn
430 (setq frame-initial-geometry-arguments
431 (cons (car (cdr tail)) frame-initial-geometry-arguments))
432 (setcdr tail (cdr (cdr tail))))
433 (setq tail (cdr tail)))))
434 (setq frame-initial-geometry-arguments
435 (nreverse frame-initial-geometry-arguments))
436 (cdr param-list))
437
438
439 (defun other-frame (arg)
440 "Select the ARG'th different visible frame, and raise it.
441 All frames are arranged in a cyclic order.
442 This command selects the frame ARG steps away in that order.
443 A negative ARG moves in the opposite order."
444 (interactive "p")
445 (let ((frame (selected-frame)))
446 (while (> arg 0)
447 (setq frame (next-frame frame))
448 (while (not (eq (frame-visible-p frame) t))
449 (setq frame (next-frame frame)))
450 (setq arg (1- arg)))
451 (while (< arg 0)
452 (setq frame (previous-frame frame))
453 (while (not (eq (frame-visible-p frame) t))
454 (setq frame (previous-frame frame)))
455 (setq arg (1+ arg)))
456 (raise-frame frame)
457 (select-frame frame)
458 (set-mouse-position (selected-frame) (1- (frame-width)) 0)
459 (unfocus-frame)))
460 \f
461 ;;;; Frame configurations
462
463 (defun current-frame-configuration ()
464 "Return a list describing the positions and states of all frames.
465 Its car is `frame-configuration'.
466 Each element of the cdr is a list of the form (FRAME ALIST WINDOW-CONFIG),
467 where
468 FRAME is a frame object,
469 ALIST is an association list specifying some of FRAME's parameters, and
470 WINDOW-CONFIG is a window configuration object for FRAME."
471 (cons 'frame-configuration
472 (mapcar (function
473 (lambda (frame)
474 (list frame
475 (frame-parameters frame)
476 (current-window-configuration frame))))
477 (frame-list))))
478
479 (defun set-frame-configuration (configuration &optional nodelete)
480 "Restore the frames to the state described by CONFIGURATION.
481 Each frame listed in CONFIGURATION has its position, size, window
482 configuration, and other parameters set as specified in CONFIGURATION.
483 Ordinarily, this function deletes all existing frames not
484 listed in CONFIGURATION. But if optional second argument NODELETE
485 is given and non-nil, the unwanted frames are iconified instead."
486 (or (frame-configuration-p configuration)
487 (signal 'wrong-type-argument
488 (list 'frame-configuration-p configuration)))
489 (let ((config-alist (cdr configuration))
490 frames-to-delete)
491 (mapcar (function
492 (lambda (frame)
493 (let ((parameters (assq frame config-alist)))
494 (if parameters
495 (progn
496 (modify-frame-parameters
497 frame
498 ;; Since we can't set a frame's minibuffer status,
499 ;; we might as well omit the parameter altogether.
500 (let* ((parms (nth 1 parameters))
501 (mini (assq 'minibuffer parms)))
502 (if mini (setq parms (delq mini parms)))
503 parms))
504 (set-window-configuration (nth 2 parameters)))
505 (setq frames-to-delete (cons frame frames-to-delete))))))
506 (frame-list))
507 (if nodelete
508 ;; Note: making frames invisible here was tried
509 ;; but led to some strange behavior--each time the frame
510 ;; was made visible again, the window manager asked afresh
511 ;; for where to put it.
512 (mapcar 'iconify-frame frames-to-delete)
513 (mapcar 'delete-frame frames-to-delete))))
514
515 (defun frame-configuration-p (object)
516 "Return non-nil if OBJECT seems to be a frame configuration.
517 Any list whose car is `frame-configuration' is assumed to be a frame
518 configuration."
519 (and (consp object)
520 (eq (car object) 'frame-configuration)))
521
522 \f
523 ;;;; Convenience functions for accessing and interactively changing
524 ;;;; frame parameters.
525
526 (defun frame-height (&optional frame)
527 "Return number of lines available for display on FRAME.
528 If FRAME is omitted, describe the currently selected frame."
529 (cdr (assq 'height (frame-parameters frame))))
530
531 (defun frame-width (&optional frame)
532 "Return number of columns available for display on FRAME.
533 If FRAME is omitted, describe the currently selected frame."
534 (cdr (assq 'width (frame-parameters frame))))
535
536 (defun set-default-font (font-name)
537 "Set the font of the selected frame to FONT.
538 When called interactively, prompt for the name of the font to use."
539 (interactive "sFont name: ")
540 (modify-frame-parameters (selected-frame)
541 (list (cons 'font font-name)))
542 ;; Update faces that want a bold or italic version of the default font.
543 (frame-update-faces (selected-frame)))
544
545 (defun set-background-color (color-name)
546 "Set the background color of the selected frame to COLOR.
547 When called interactively, prompt for the name of the color to use."
548 (interactive "sColor: ")
549 (modify-frame-parameters (selected-frame)
550 (list (cons 'background-color color-name))))
551
552 (defun set-foreground-color (color-name)
553 "Set the foreground color of the selected frame to COLOR.
554 When called interactively, prompt for the name of the color to use."
555 (interactive "sColor: ")
556 (modify-frame-parameters (selected-frame)
557 (list (cons 'foreground-color color-name))))
558
559 (defun set-cursor-color (color-name)
560 "Set the text cursor color of the selected frame to COLOR.
561 When called interactively, prompt for the name of the color to use."
562 (interactive "sColor: ")
563 (modify-frame-parameters (selected-frame)
564 (list (cons 'cursor-color color-name))))
565
566 (defun set-mouse-color (color-name)
567 "Set the color of the mouse pointer of the selected frame to COLOR.
568 When called interactively, prompt for the name of the color to use."
569 (interactive "sColor: ")
570 (modify-frame-parameters (selected-frame)
571 (list (cons 'mouse-color color-name))))
572
573 (defun set-border-color (color-name)
574 "Set the color of the border of the selected frame to COLOR.
575 When called interactively, prompt for the name of the color to use."
576 (interactive "sColor: ")
577 (modify-frame-parameters (selected-frame)
578 (list (cons 'border-color color-name))))
579
580 (defun auto-raise-mode (arg)
581 "Toggle whether or not the selected frame should auto-raise.
582 With arg, turn auto-raise mode on if and only if arg is positive.
583 Note that this controls Emacs's own auto-raise feature.
584 Some window managers allow you to enable auto-raise for certain windows.
585 You can use that for Emacs windows if you wish, but if you do,
586 that is beyond the control of Emacs and this command has no effect on it."
587 (interactive "P")
588 (if (null arg)
589 (setq arg
590 (if (cdr (assq 'auto-raise (frame-parameters (selected-frame))))
591 -1 1)))
592 (modify-frame-parameters (selected-frame)
593 (list (cons 'auto-raise (> arg 0)))))
594
595 (defun auto-lower-mode (arg)
596 "Toggle whether or not the selected frame should auto-lower.
597 With arg, turn auto-lower mode on if and only if arg is positive.
598 Note that this controls Emacs's own auto-lower feature.
599 Some window managers allow you to enable auto-lower for certain windows.
600 You can use that for Emacs windows if you wish, but if you do,
601 that is beyond the control of Emacs and this command has no effect on it."
602 (interactive "P")
603 (if (null arg)
604 (setq arg
605 (if (cdr (assq 'auto-lower (frame-parameters (selected-frame))))
606 -1 1)))
607 (modify-frame-parameters (selected-frame)
608 (list (cons 'auto-lower (> arg 0)))))
609
610 (defun toggle-scroll-bar (arg)
611 "Toggle whether or not the selected frame has vertical scroll bars.
612 With arg, turn vertical scroll bars on if and only if arg is positive."
613 (interactive "P")
614 (if (null arg)
615 (setq arg
616 (if (cdr (assq 'vertical-scroll-bars
617 (frame-parameters (selected-frame))))
618 -1 1)))
619 (modify-frame-parameters (selected-frame)
620 (list (cons 'vertical-scroll-bars (> arg 0)))))
621
622 (defun toggle-horizontal-scroll-bar (arg)
623 "Toggle whether or not the selected frame has horizontal scroll bars.
624 With arg, turn horizontal scroll bars on if and only if arg is positive.
625 Horizontal scroll bars aren't implemented yet."
626 (interactive "P")
627 (error "Horizontal scroll bars aren't implemented yet"))
628
629 \f
630 ;;;; Aliases for backward compatibility with Emacs 18.
631 (defalias 'screen-height 'frame-height)
632 (defalias 'screen-width 'frame-width)
633
634 (defun set-screen-width (cols &optional pretend)
635 "Obsolete function to change the size of the screen to COLS columns.\n\
636 Optional second arg non-nil means that redisplay should use COLS columns\n\
637 but that the idea of the actual width of the frame should not be changed.\n\
638 This function is provided only for compatibility with Emacs 18; new code\n\
639 should use `set-frame-width instead'."
640 (set-frame-width (selected-frame) cols pretend))
641
642 (defun set-screen-height (lines &optional pretend)
643 "Obsolete function to change the height of the screen to LINES lines.\n\
644 Optional second arg non-nil means that redisplay should use LINES lines\n\
645 but that the idea of the actual height of the screen should not be changed.\n\
646 This function is provided only for compatibility with Emacs 18; new code\n\
647 should use `set-frame-width' instead."
648 (set-frame-height (selected-frame) lines pretend))
649
650 (make-obsolete 'screen-height 'frame-height)
651 (make-obsolete 'screen-width 'frame-width)
652 (make-obsolete 'set-screen-width 'set-frame-width)
653 (make-obsolete 'set-screen-height 'set-frame-height)
654
655 \f
656 ;;;; Key bindings
657 (defvar ctl-x-5-map (make-sparse-keymap)
658 "Keymap for frame commands.")
659 (defalias 'ctl-x-5-prefix ctl-x-5-map)
660 (define-key ctl-x-map "5" 'ctl-x-5-prefix)
661
662 (define-key ctl-x-5-map "2" 'make-frame)
663 (define-key ctl-x-5-map "0" 'delete-frame)
664 (define-key ctl-x-5-map "o" 'other-frame)
665
666 (provide 'frame)
667
668 ;;; frame.el ends here