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