(rmail-mode-map): Fix the Get New Mail entry.
[bpt/emacs.git] / lisp / frame.el
CommitLineData
dc6d9681 1;;; frame.el --- multi-frame management independent of window systems.
c88ab9ce 2
8f1204db 3;;;; Copyright (C) 1993, 1994 Free Software Foundation, Inc.
3a801d0c 4
fc68affa 5;; Maintainer: FSF
fd7fa35a 6;; Keywords: internal
fc68affa 7
64c669bc
JB
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
de49a6d3 12;;; the Free Software Foundation; either version 2, or (at your option)
64c669bc
JB
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
fc68affa
ER
24;;; Code:
25
dc6d9681
JB
26(defvar frame-creation-function nil
27 "Window-system dependent function to call to create a new frame.
28The window system startup file should set this to its frame creation
64c669bc
JB
29function, which should take an alist of parameters as its argument.")
30
7eadab74
JB
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.
9e2b097b 34(defvar initial-frame-alist '((minibuffer . t))
eaa974e1
JB
35 "Alist of frame parameters for creating the initial X window frame.
36You can set this in your `.emacs' file; for example,
dc6d9681 37 (setq initial-frame-alist '((top . 1) (left . 1) (width . 80) (height . 55)))
de17da15
RS
38Parameters specified here supersede the values given in `default-frame-alist'.
39
40If the value calls for a frame without a minibuffer, and you have not created
41a minibuffer frame on your own, one is created according to
7eadab74 42`minibuffer-frame-alist'.
de17da15
RS
43
44You can specify geometry-related options for just the initial frame
45by setting this variable in your `.emacs' file; however, they won't
46take affect until Emacs reads `.emacs', which happens after first creating
47the frame. If you want the frame to have the proper geometry as soon
48as 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'.")
64c669bc 54
7eadab74 55(defvar minibuffer-frame-alist '((width . 80) (height . 2))
eaa974e1
JB
56 "Alist of frame parameters for initially creating a minibuffer frame.
57You can set this in your `.emacs' file; for example,
dc6d9681 58 (setq minibuffer-frame-alist
7eadab74 59 '((top . 1) (left . 1) (width . 80) (height . 2)))
eaa974e1
JB
60Parameters specified here supersede the values given in
61`default-frame-alist'.")
64c669bc 62
dc6d9681 63(defvar pop-up-frame-alist nil
eaa974e1 64 "Alist of frame parameters used when creating pop-up frames.
dc6d9681 65Pop-up frames are used for completions, help, and the like.
64c669bc 66This variable can be set in your init file, like this:
dc6d9681 67 (setq pop-up-frame-alist '((width . 80) (height . 20)))
eb8c3be9 68These supersede the values given in `default-frame-alist'.")
64c669bc 69
dc6d9681 70(setq pop-up-frame-function
64c669bc 71 (function (lambda ()
6eb018ba 72 (make-frame pop-up-frame-alist))))
64c669bc 73
8a9e86e6
RS
74(defvar special-display-frame-alist
75 '((height . 14) (width . 80) (unsplittable . t))
76 "*Alist of frame parameters used when creating special frames.
77Special frames are used for buffers whose names are in
78`special-display-buffer-names' and for buffers whose names match
79one of the regular expressions in `special-display-regexps'.
80This variable can be set in your init file, like this:
81 (setq special-display-frame-alist '((width . 80) (height . 20)))
82These 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.
6eb018ba 96 (let ((frame (make-frame special-display-frame-alist)))
8a9e86e6
RS
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)
64c669bc 102\f
dc6d9681 103;;;; Arrangement of frames at startup
64c669bc
JB
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
dc6d9681 107;;; file should create any frames specified in the window system defaults.
64c669bc 108;;;
dc6d9681 109;;; 2) If no frames have been opened, we open an initial text frame.
64c669bc
JB
110;;;
111;;; 3) Once the init file is done, we apply any newly set parameters
dc6d9681 112;;; in initial-frame-alist to the frame.
64c669bc 113
fc4d4afb
RS
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)
64c669bc 119
dc6d9681
JB
120;;; If we create the initial frame, this is it.
121(defvar frame-initial-frame nil)
64c669bc 122
3f2f8c83
RS
123;; Record the parameters used in frame-initialize to make the initial frame.
124(defvar frame-initial-frame-alist)
125
791e09d8
RS
126(defvar frame-initial-geometry-arguments nil)
127
64c669bc 128;;; startup.el calls this function before loading the user's init
dc6d9681 129;;; file - if there is no frame with a minibuffer open now, create
64c669bc 130;;; one to display messages while loading the init file.
dc6d9681 131(defun frame-initialize ()
64c669bc
JB
132
133 ;; Are we actually running under a window system at all?
134 (if (and window-system (not noninteractive))
7eadab74
JB
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))
36fc9c9f 141 (progn
3f2f8c83
RS
142 (setq frame-initial-frame-alist
143 (append initial-frame-alist default-frame-alist))
a8bb5882
RS
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)))
36fc9c9f
RS
154 (setq default-minibuffer-frame
155 (setq frame-initial-frame
6eb018ba 156 (make-frame initial-frame-alist)))
11281034
RS
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.
58bf6042 161 (setq initial-frame-alist
c2079f0a 162 (frame-remove-geometry-params initial-frame-alist))))
dc6d9681
JB
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))
64c669bc
JB
167
168 ;; No, we're not running a window system. Arrange to cause errors.
dc6d9681 169 (setq frame-creation-function
9198945a
MB
170 (function
171 (lambda (parameters)
172 (error
8290babd 173 "Can't create multiple frames without a window system"))))))
64c669bc 174
7eadab74
JB
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.
dc6d9681 178(defun frame-notice-user-settings ()
7eadab74 179
2ffa6186
RS
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
7eadab74
JB
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 ;;
ec558adc
JB
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.
7eadab74
JB
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.
b65e2f74
RS
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
6eb018ba
RS
224 default-frame-alist
225 (frame-parameters frame-initial-frame)
226 nil))
c1e67401
RS
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 (delq (assq 'height parms) parms)))
232 (if (assq 'width frame-initial-geometry-arguments)
233 (setq parms (delq (assq 'width parms) parms)))
234 (if (assq 'left frame-initial-geometry-arguments)
235 (setq parms (delq (assq 'left parms) parms)))
236 (if (assq 'top frame-initial-geometry-arguments)
237 (setq parms (delq (assq 'top parms) 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)))
7eadab74
JB
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))
6eb018ba 247 (make-frame (append minibuffer-frame-alist
7eadab74
JB
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))))
ec558adc
JB
288
289 ;; Redirect events enqueued at this frame to the new frame.
290 ;; Is this a good idea?
7eadab74 291 (redirect-frame-focus frame-initial-frame new)
ec558adc 292
7eadab74 293 ;; Finally, get rid of the old frame.
0cffbbb9 294 (delete-frame frame-initial-frame t))
7eadab74
JB
295
296 ;; Otherwise, we don't need all that rigamarole; just apply
297 ;; the new parameters.
3f2f8c83
RS
298 (let (newparms allparms tail)
299 (setq allparms (append initial-frame-alist
300 default-frame-alist))
301 (setq tail allparms)
302 ;; Find just the parms that have changed since we first
303 ;; made this frame. Those are the ones actually set by
304 ;; the init file. For those parms whose values we already knew
305 ;; (such as those spec'd by command line options)
306 ;; it is undesirable to specify the parm again
307 ;; once the user has seen the frame and been able to alter it
308 ;; manually.
309 (while tail
310 (let (newval oldval)
311 (setq oldval (cdr (assq (car (car tail))
312 frame-initial-frame-alist)))
313 (setq newval (cdr (assq (car (car tail)) allparms)))
314 (or (eq oldval newval)
315 (setq newparms
316 (cons (cons (car (car tail)) newval) newparms))))
317 (setq tail (cdr tail)))
318 (modify-frame-parameters frame-initial-frame
319 (nreverse newparms)))))
64c669bc 320
7eadab74
JB
321 ;; Restore the original buffer.
322 (set-buffer old-buffer)
323
324 ;; Make sure the initial frame can be GC'd if it is ever deleted.
d202f1f2
JB
325 ;; Make sure frame-notice-user-settings does nothing if called twice.
326 (setq frame-initial-frame nil)))
64c669bc
JB
327
328\f
7eadab74 329;;;; Creation of additional frames, and other frame miscellanea
dc6d9681 330
7eadab74 331;;; Return some frame other than the current frame, creating one if
eb8c3be9 332;;; necessary. Note that the minibuffer frame, if separate, is not
7eadab74 333;;; considered (see next-frame).
7253d8e0 334(defun get-other-frame ()
dc6d9681 335 (let ((s (if (equal (next-frame (selected-frame)) (selected-frame))
6eb018ba 336 (make-frame)
dc6d9681 337 (next-frame (selected-frame)))))
64c669bc
JB
338 s))
339
dc6d9681
JB
340(defun next-multiframe-window ()
341 "Select the next window, regardless of which frame it is on."
64c669bc
JB
342 (interactive)
343 (select-window (next-window (selected-window)
344 (> (minibuffer-depth) 0)
345 t)))
346
dc6d9681
JB
347(defun previous-multiframe-window ()
348 "Select the previous window, regardless of which frame it is on."
64c669bc
JB
349 (interactive)
350 (select-window (previous-window (selected-window)
351 (> (minibuffer-depth) 0)
352 t)))
353
92e443b1 354;; Alias, kept temporarily.
31e1d920 355(defalias 'new-frame 'make-frame)
92e443b1 356(defun make-frame (&optional parameters)
dc6d9681 357 "Create a new frame, displaying the current buffer.
bc93c097 358
43a2e52c 359Optional argument PARAMETERS is an alist of parameters for the new
dc6d9681 360frame. Specifically, PARAMETERS is a list of pairs, each having one
43a2e52c
JB
361of the following forms:
362
eaa974e1 363\(name . STRING) - The frame should be named STRING.
43a2e52c 364
eaa974e1 365\(height . NUMBER) - The frame should be NUMBER text lines high. If
43a2e52c
JB
366 this parameter is present, the width parameter must also be
367 given.
368
eaa974e1 369\(width . NUMBER) - The frame should be NUMBER characters in width.
43a2e52c
JB
370 If this parameter is present, the height parameter must also
371 be given.
372
eaa974e1 373\(minibuffer . t) - the frame should have a minibuffer
0ca90494 374\(minibuffer . nil) - the frame should have no minibuffer
eaa974e1 375\(minibuffer . only) - the frame should contain only a minibuffer
8dbd5c78 376\(minibuffer . WINDOW) - the frame should use WINDOW as its minibuffer window."
64c669bc 377 (interactive)
4133ab49
RS
378 (let ((nframe))
379 (run-hooks 'before-make-frame-hook)
380 (setq nframe (funcall frame-creation-function parameters))
381 (run-hooks 'after-make-frame-hook)
382 nframe))
64c669bc 383
7eadab74
JB
384(defun filtered-frame-list (predicate)
385 "Return a list of all live frames which satisfy PREDICATE."
386 (let ((frames (frame-list))
387 good-frames)
388 (while (consp frames)
389 (if (funcall predicate (car frames))
390 (setq good-frames (cons (car frames) good-frames)))
391 (setq frames (cdr frames)))
392 good-frames))
393
394(defun minibuffer-frame-list ()
395 "Return a list of all frames with their own minibuffers."
396 (filtered-frame-list
397 (function (lambda (frame)
398 (eq frame (window-frame (minibuffer-window frame)))))))
399
58bf6042
JB
400(defun frame-remove-geometry-params (param-list)
401 "Return the parameter list PARAM-LIST, but with geometry specs removed.
402This deletes all bindings in PARAM-LIST for `top', `left', `width',
791e09d8 403`height', `user-size' and `user-position' parameters.
58bf6042
JB
404Emacs uses this to avoid overriding explicit moves and resizings from
405the user during startup."
406 (setq param-list (cons nil param-list))
407 (let ((tail param-list))
408 (while (consp (cdr tail))
409 (if (and (consp (car (cdr tail)))
791e09d8
RS
410 (memq (car (car (cdr tail)))
411 '(height width top left user-position user-size)))
412 (progn
413 (setq frame-initial-geometry-arguments
414 (cons (car (cdr tail)) frame-initial-geometry-arguments))
415 (setcdr tail (cdr (cdr tail))))
58bf6042 416 (setq tail (cdr tail)))))
e11c3dc2
KH
417 (setq frame-initial-geometry-arguments
418 (nreverse frame-initial-geometry-arguments))
58bf6042
JB
419 (cdr param-list))
420
421
ceab6935 422(defun other-frame (arg)
a569dbc3 423 "Select the ARG'th different visible frame, and raise it.
ceab6935
RM
424All frames are arranged in a cyclic order.
425This command selects the frame ARG steps away in that order.
426A negative ARG moves in the opposite order."
427 (interactive "p")
428 (let ((frame (selected-frame)))
429 (while (> arg 0)
a569dbc3
RM
430 (setq frame (next-frame frame))
431 (while (not (eq (frame-visible-p frame) t))
432 (setq frame (next-frame frame)))
433 (setq arg (1- arg)))
ceab6935 434 (while (< arg 0)
a569dbc3
RM
435 (setq frame (previous-frame frame))
436 (while (not (eq (frame-visible-p frame) t))
437 (setq frame (previous-frame frame)))
915cfd1f 438 (setq arg (1+ arg)))
ceab6935 439 (raise-frame frame)
699213bc 440 (select-frame frame)
2b88f7a0 441 (set-mouse-position (selected-frame) (1- (frame-width)) 0)
699213bc 442 (unfocus-frame)))
64c669bc 443\f
dc6d9681
JB
444;;;; Frame configurations
445
446(defun current-frame-configuration ()
447 "Return a list describing the positions and states of all frames.
376a7584
JB
448Its car is `frame-configuration'.
449Each element of the cdr is a list of the form (FRAME ALIST WINDOW-CONFIG),
450where
451 FRAME is a frame object,
452 ALIST is an association list specifying some of FRAME's parameters, and
453 WINDOW-CONFIG is a window configuration object for FRAME."
454 (cons 'frame-configuration
455 (mapcar (function
456 (lambda (frame)
457 (list frame
458 (frame-parameters frame)
459 (current-window-configuration frame))))
460 (frame-list))))
dc6d9681 461
68cd265f 462(defun set-frame-configuration (configuration &optional nodelete)
dc6d9681
JB
463 "Restore the frames to the state described by CONFIGURATION.
464Each frame listed in CONFIGURATION has its position, size, window
68cd265f 465configuration, and other parameters set as specified in CONFIGURATION.
a78db71c
RS
466Ordinarily, this function deletes all existing frames not
467listed in CONFIGURATION. But if optional second argument NODELETE
5da841d2 468is given and non-nil, the unwanted frames are iconified instead."
376a7584
JB
469 (or (frame-configuration-p configuration)
470 (signal 'wrong-type-argument
471 (list 'frame-configuration-p configuration)))
472 (let ((config-alist (cdr configuration))
473 frames-to-delete)
06b1a5ef 474 (mapcar (function
dc6d9681 475 (lambda (frame)
376a7584 476 (let ((parameters (assq frame config-alist)))
06b1a5ef
JB
477 (if parameters
478 (progn
98e9d14b
JB
479 (modify-frame-parameters
480 frame
481 ;; Since we can't set a frame's minibuffer status,
482 ;; we might as well omit the parameter altogether.
483 (let* ((parms (nth 1 parameters))
484 (mini (assq 'minibuffer parms)))
485 (if mini (setq parms (delq mini parms)))
486 parms))
06b1a5ef 487 (set-window-configuration (nth 2 parameters)))
dc6d9681
JB
488 (setq frames-to-delete (cons frame frames-to-delete))))))
489 (frame-list))
a78db71c 490 (if nodelete
5da841d2
RS
491 ;; Note: making frames invisible here was tried
492 ;; but led to some strange behavior--each time the frame
493 ;; was made visible again, the window manager asked afresh
494 ;; for where to put it.
495 (mapcar 'iconify-frame frames-to-delete)
a78db71c 496 (mapcar 'delete-frame frames-to-delete))))
64c669bc 497
376a7584
JB
498(defun frame-configuration-p (object)
499 "Return non-nil if OBJECT seems to be a frame configuration.
500Any list whose car is `frame-configuration' is assumed to be a frame
501configuration."
502 (and (consp object)
503 (eq (car object) 'frame-configuration)))
504
64c669bc 505\f
dc6d9681
JB
506;;;; Convenience functions for accessing and interactively changing
507;;;; frame parameters.
64c669bc 508
151bdc83 509(defun frame-height (&optional frame)
dc6d9681
JB
510 "Return number of lines available for display on FRAME.
511If FRAME is omitted, describe the currently selected frame."
151bdc83 512 (cdr (assq 'height (frame-parameters frame))))
dc6d9681
JB
513
514(defun frame-width (&optional frame)
515 "Return number of columns available for display on FRAME.
516If FRAME is omitted, describe the currently selected frame."
151bdc83 517 (cdr (assq 'width (frame-parameters frame))))
dc6d9681 518
64c669bc 519(defun set-default-font (font-name)
7eadab74
JB
520 "Set the font of the selected frame to FONT.
521When called interactively, prompt for the name of the font to use."
64c669bc 522 (interactive "sFont name: ")
dc6d9681 523 (modify-frame-parameters (selected-frame)
4033f46b
RS
524 (list (cons 'font font-name)))
525 ;; Update faces that want a bold or italic version of the default font.
526 (frame-update-faces (selected-frame)))
64c669bc 527
8290babd 528(defun set-background-color (color-name)
7eadab74
JB
529 "Set the background color of the selected frame to COLOR.
530When called interactively, prompt for the name of the color to use."
64c669bc 531 (interactive "sColor: ")
dc6d9681 532 (modify-frame-parameters (selected-frame)
7eadab74 533 (list (cons 'background-color color-name))))
64c669bc 534
8290babd 535(defun set-foreground-color (color-name)
7eadab74
JB
536 "Set the foreground color of the selected frame to COLOR.
537When called interactively, prompt for the name of the color to use."
64c669bc 538 (interactive "sColor: ")
dc6d9681 539 (modify-frame-parameters (selected-frame)
7eadab74 540 (list (cons 'foreground-color color-name))))
64c669bc
JB
541
542(defun set-cursor-color (color-name)
7eadab74
JB
543 "Set the text cursor color of the selected frame to COLOR.
544When called interactively, prompt for the name of the color to use."
64c669bc 545 (interactive "sColor: ")
dc6d9681 546 (modify-frame-parameters (selected-frame)
7eadab74 547 (list (cons 'cursor-color color-name))))
64c669bc 548
eaa974e1 549(defun set-mouse-color (color-name)
7eadab74
JB
550 "Set the color of the mouse pointer of the selected frame to COLOR.
551When called interactively, prompt for the name of the color to use."
64c669bc 552 (interactive "sColor: ")
dc6d9681 553 (modify-frame-parameters (selected-frame)
7eadab74
JB
554 (list (cons 'mouse-color color-name))))
555
eaa974e1
JB
556(defun set-border-color (color-name)
557 "Set the color of the border of the selected frame to COLOR.
558When called interactively, prompt for the name of the color to use."
559 (interactive "sColor: ")
560 (modify-frame-parameters (selected-frame)
561 (list (cons 'border-color color-name))))
562
563(defun auto-raise-mode (arg)
7eadab74 564 "Toggle whether or not the selected frame should auto-raise.
79e6ae33
RS
565With arg, turn auto-raise mode on if and only if arg is positive.
566Note that this controls Emacs's own auto-raise feature.
567Some window managers allow you to enable auto-raise for certain windows.
568You can use that for Emacs windows if you wish, but if you do,
569that is beyond the control of Emacs and this command has no effect on it."
7eadab74
JB
570 (interactive "P")
571 (if (null arg)
572 (setq arg
573 (if (cdr (assq 'auto-raise (frame-parameters (selected-frame))))
574 -1 1)))
dc6d9681 575 (modify-frame-parameters (selected-frame)
7eadab74
JB
576 (list (cons 'auto-raise (> arg 0)))))
577
eaa974e1 578(defun auto-lower-mode (arg)
7eadab74 579 "Toggle whether or not the selected frame should auto-lower.
79e6ae33
RS
580With arg, turn auto-lower mode on if and only if arg is positive.
581Note that this controls Emacs's own auto-lower feature.
582Some window managers allow you to enable auto-lower for certain windows.
583You can use that for Emacs windows if you wish, but if you do,
584that is beyond the control of Emacs and this command has no effect on it."
7eadab74
JB
585 (interactive "P")
586 (if (null arg)
587 (setq arg
588 (if (cdr (assq 'auto-lower (frame-parameters (selected-frame))))
589 -1 1)))
dc6d9681 590 (modify-frame-parameters (selected-frame)
7eadab74
JB
591 (list (cons 'auto-lower (> arg 0)))))
592
7e85c6b5 593(defun toggle-scroll-bar (arg)
0ca90494
JB
594 "Toggle whether or not the selected frame has vertical scroll bars.
595With arg, turn vertical scroll bars on if and only if arg is positive."
7eadab74
JB
596 (interactive "P")
597 (if (null arg)
598 (setq arg
0ca90494 599 (if (cdr (assq 'vertical-scroll-bars
7eadab74
JB
600 (frame-parameters (selected-frame))))
601 -1 1)))
dc6d9681 602 (modify-frame-parameters (selected-frame)
0ca90494 603 (list (cons 'vertical-scroll-bars (> arg 0)))))
7eadab74 604
8290babd 605(defun toggle-horizontal-scroll-bar (arg)
0ca90494
JB
606 "Toggle whether or not the selected frame has horizontal scroll bars.
607With arg, turn horizontal scroll bars on if and only if arg is positive.
608Horizontal scroll bars aren't implemented yet."
7eadab74 609 (interactive "P")
8290babd 610 (error "Horizontal scroll bars aren't implemented yet"))
64c669bc 611
64c669bc 612\f
dc6d9681 613;;;; Aliases for backward compatibility with Emacs 18.
31e1d920
ER
614(defalias 'screen-height 'frame-height)
615(defalias 'screen-width 'frame-width)
9e2b097b
JB
616
617(defun set-screen-width (cols &optional pretend)
618 "Obsolete function to change the size of the screen to COLS columns.\n\
619Optional second arg non-nil means that redisplay should use COLS columns\n\
620but that the idea of the actual width of the frame should not be changed.\n\
621This function is provided only for compatibility with Emacs 18; new code\n\
fe668515 622should use `set-frame-width instead'."
9e2b097b
JB
623 (set-frame-width (selected-frame) cols pretend))
624
625(defun set-screen-height (lines &optional pretend)
626 "Obsolete function to change the height of the screen to LINES lines.\n\
627Optional second arg non-nil means that redisplay should use LINES lines\n\
628but that the idea of the actual height of the screen should not be changed.\n\
629This function is provided only for compatibility with Emacs 18; new code\n\
fe668515 630should use `set-frame-width' instead."
9e2b097b
JB
631 (set-frame-height (selected-frame) lines pretend))
632
633(make-obsolete 'screen-height 'frame-height)
634(make-obsolete 'screen-width 'frame-width)
635(make-obsolete 'set-screen-width 'set-frame-width)
636(make-obsolete 'set-screen-height 'set-frame-height)
dc6d9681
JB
637
638\f
64c669bc 639;;;; Key bindings
daa37602 640(defvar ctl-x-5-map (make-sparse-keymap)
dc6d9681 641 "Keymap for frame commands.")
31e1d920 642(defalias 'ctl-x-5-prefix ctl-x-5-map)
daa37602 643(define-key ctl-x-map "5" 'ctl-x-5-prefix)
64c669bc 644
6eb018ba 645(define-key ctl-x-5-map "2" 'make-frame)
dc6d9681 646(define-key ctl-x-5-map "0" 'delete-frame)
ceab6935 647(define-key ctl-x-5-map "o" 'other-frame)
49116ac0 648
dc6d9681 649(provide 'frame)
c88ab9ce 650
dc6d9681 651;;; frame.el ends here