Merge from trunk
[bpt/emacs.git] / lisp / frame.el
CommitLineData
55535639 1;;; frame.el --- multi-frame management independent of window systems
c88ab9ce 2
73b0cd50 3;; Copyright (C) 1993-1994, 1996-1997, 2000-2011
e9bffc61 4;; Free Software Foundation, Inc.
3a801d0c 5
fc68affa 6;; Maintainer: FSF
fd7fa35a 7;; Keywords: internal
bd78fa1d 8;; Package: emacs
fc68affa 9
b578f267
EN
10;; This file is part of GNU Emacs.
11
eb3fa2cf 12;; GNU Emacs is free software: you can redistribute it and/or modify
b578f267 13;; it under the terms of the GNU General Public License as published by
eb3fa2cf
GM
14;; the Free Software Foundation, either version 3 of the License, or
15;; (at your option) any later version.
b578f267
EN
16
17;; GNU Emacs is distributed in the hope that it will be useful,
18;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20;; GNU General Public License for more details.
21
22;; You should have received a copy of the GNU General Public License
eb3fa2cf 23;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
64c669bc 24
55535639
PJ
25;;; Commentary:
26
fc68affa 27;;; Code:
f44379e7 28(eval-when-compile (require 'cl))
fc68affa 29
2246281f
KL
30(defvar frame-creation-function-alist
31 (list (cons nil
32 (if (fboundp 'tty-create-frame-with-faces)
33 'tty-create-frame-with-faces
371fed4e
SM
34 (lambda (parameters)
35 (error "Can't create multiple frames without a window system")))))
2246281f
KL
36 "Alist of window-system dependent functions to call to create a new frame.
37The window system startup file should add its frame creation
38function to this list, which should take an alist of parameters
39as its argument.")
114a8b8c 40
bf1ba39f
KL
41(defvar window-system-default-frame-alist nil
42 "Alist of window-system dependent default frame parameters.
dca6c418
MR
43Parameters specified here supersede the values given in
44`default-frame-alist'.")
bf1ba39f 45
7e573c4a
SM
46;; The initial value given here used to ask for a minibuffer.
47;; But that's not necessary, because the default is to have one.
48;; By not specifying it here, we let an X resource specify it.
fac580eb 49(defcustom initial-frame-alist nil
dca6c418
MR
50 "Alist of parameters for the initial X window frame.
51You can set this in your init file; for example,
52
53 (setq initial-frame-alist
54 '((top . 1) (left . 1) (width . 80) (height . 55)))
55
56Parameters specified here supersede the values given in
57`default-frame-alist'.
58
59If the value calls for a frame without a minibuffer, and you have
60not created a minibuffer frame on your own, a minibuffer frame is
61created according to `minibuffer-frame-alist'.
62
63You can specify geometry-related options for just the initial
64frame by setting this variable in your init file; however, they
65won't take effect until Emacs reads your init file, which happens
66after creating the initial frame. If you want the initial frame
67to have the proper geometry as soon as it appears, you need to
68use this three-step process:
de17da15
RS
69* Specify X resources to give the geometry you want.
70* Set `default-frame-alist' to override these options so that they
71 don't affect subsequent frames.
72* Set `initial-frame-alist' in a way that matches the X resources,
0c966f88
RS
73 to override what you put in `default-frame-alist'."
74 :type '(repeat (cons :format "%v"
75 (symbol :tag "Parameter")
76 (sexp :tag "Value")))
77 :group 'frames)
64c669bc 78
0b9d32af 79(defcustom minibuffer-frame-alist '((width . 80) (height . 2))
92e02072
CY
80 "Alist of parameters for the initial minibuffer frame.
81This is the minibuffer frame created if `initial-frame-alist'
82calls for a frame without a minibuffer. The parameters specified
83here supersede those given in `default-frame-alist', for the
84initial minibuffer frame.
85
dca6c418
MR
86You can set this in your init file; for example,
87
dc6d9681 88 (setq minibuffer-frame-alist
dca6c418
MR
89 '((top . 1) (left . 1) (width . 80) (height . 2)))
90
92e02072
CY
91It is not necessary to include (minibuffer . only); that is
92appended when the minibuffer frame is created."
0b9d32af
RS
93 :type '(repeat (cons :format "%v"
94 (symbol :tag "Parameter")
95 (sexp :tag "Value")))
96 :group 'frames)
64c669bc 97
0b9d32af 98(defcustom pop-up-frame-alist nil
dca6c418
MR
99 "Alist of parameters for automatically generated new frames.
100You can set this in your init file; for example,
101
dc6d9681 102 (setq pop-up-frame-alist '((width . 80) (height . 20)))
dca6c418
MR
103
104If non-nil, the value you specify here is used by the default
105`pop-up-frame-function' for the creation of new frames.
106
107Since `pop-up-frame-function' is used by `display-buffer' for
60898913 108making new frames, any value specified here by default affects
dca6c418
MR
109the automatic generation of new frames via `display-buffer' and
110all functions based on it. The behavior of `make-frame' is not
111affected by this variable."
0b9d32af
RS
112 :type '(repeat (cons :format "%v"
113 (symbol :tag "Parameter")
114 (sexp :tag "Value")))
115 :group 'frames)
64c669bc 116
25831d66
MR
117(defcustom pop-up-frame-function
118 (lambda () (make-frame pop-up-frame-alist))
dca6c418
MR
119 "Function used by `display-buffer' for creating a new frame.
120This function is called with no arguments and should return a new
121frame. The default value calls `make-frame' with the argument
122`pop-up-frame-alist'."
36fc0932 123 :type 'function
25831d66 124 :group 'frames)
64c669bc 125
30e19aee 126(defcustom special-display-frame-alist
8a9e86e6 127 '((height . 14) (width . 80) (unsplittable . t))
dca6c418 128 "Alist of parameters for special frames.
60898913 129Special frames are used for buffers whose names are listed in
8a9e86e6
RS
130`special-display-buffer-names' and for buffers whose names match
131one of the regular expressions in `special-display-regexps'.
dca6c418 132
8a9e86e6 133This variable can be set in your init file, like this:
dca6c418 134
8a9e86e6 135 (setq special-display-frame-alist '((width . 80) (height . 20)))
dca6c418 136
30e19aee
RS
137These supersede the values given in `default-frame-alist'."
138 :type '(repeat (cons :format "%v"
139 (symbol :tag "Parameter")
140 (sexp :tag "Value")))
141 :group 'frames)
8a9e86e6 142
95e6cf39 143(defun special-display-popup-frame (buffer &optional args)
60898913
MR
144 "Display BUFFER and return the window chosen.
145If BUFFER is already displayed in a visible or iconified frame,
146raise that frame. Otherwise, display BUFFER in a new frame.
147
148Optional argument ARGS is a list specifying additional
149information.
150
151If ARGS is an alist, use it as a list of frame parameters. If
152these parameters contain \(same-window . t), display BUFFER in
153the selected window. If they contain \(same-frame . t), display
154BUFFER in a window of the selected frame.
155
156If ARGS is a list whose car is a symbol, use (car ARGS) as a
157function to do the work. Pass it BUFFER as first argument,
158and (cdr ARGS) as second."
95e6cf39
RS
159 (if (and args (symbolp (car args)))
160 (apply (car args) buffer (cdr args))
bb2c34b1 161 (let ((window (get-buffer-window buffer 0)))
7e573c4a
SM
162 (or
163 ;; If we have a window already, make it visible.
164 (when window
165 (let ((frame (window-frame window)))
166 (make-frame-visible frame)
167 (raise-frame frame)
168 window))
169 ;; Reuse the current window if the user requested it.
170 (when (cdr (assq 'same-window args))
171 (condition-case nil
172 (progn (switch-to-buffer buffer) (selected-window))
173 (error nil)))
174 ;; Stay on the same frame if requested.
175 (when (or (cdr (assq 'same-frame args)) (cdr (assq 'same-window args)))
60898913
MR
176 (let* ((pop-up-windows t)
177 pop-up-frames
178 special-display-buffer-names special-display-regexps)
179 (display-buffer buffer)))
7e573c4a 180 ;; If no window yet, make one in a new frame.
bf247b6e 181 (let ((frame
86bd482f
RS
182 (with-current-buffer buffer
183 (make-frame (append args special-display-frame-alist)))))
7e573c4a
SM
184 (set-window-buffer (frame-selected-window frame) buffer)
185 (set-window-dedicated-p (frame-selected-window frame) t)
186 (frame-selected-window frame))))))
8a9e86e6 187
924be53a 188(defun handle-delete-frame (event)
40d34803 189 "Handle delete-frame events from the X server."
924be53a
RS
190 (interactive "e")
191 (let ((frame (posn-window (event-start event)))
192 (i 0)
193 (tail (frame-list)))
194 (while tail
195 (and (frame-visible-p (car tail))
196 (not (eq (car tail) frame))
197 (setq i (1+ i)))
198 (setq tail (cdr tail)))
199 (if (> i 0)
200 (delete-frame frame t)
a9562d19
RS
201 ;; Gildea@x.org says it is ok to ask questions before terminating.
202 (save-buffers-kill-emacs))))
64c669bc 203\f
dc6d9681 204;;;; Arrangement of frames at startup
64c669bc 205
7e573c4a
SM
206;; 1) Load the window system startup file from the lisp library and read the
207;; high-priority arguments (-q and the like). The window system startup
208;; file should create any frames specified in the window system defaults.
209;;
210;; 2) If no frames have been opened, we open an initial text frame.
211;;
212;; 3) Once the init file is done, we apply any newly set parameters
213;; in initial-frame-alist to the frame.
64c669bc 214
85557d7e 215;; These are now called explicitly at the proper times,
fc4d4afb
RS
216;; since that is easier to understand.
217;; Actually using hooks within Emacs is bad for future maintenance. --rms.
218;; (add-hook 'before-init-hook 'frame-initialize)
219;; (add-hook 'window-setup-hook 'frame-notice-user-settings)
64c669bc 220
7e573c4a 221;; If we create the initial frame, this is it.
dc6d9681 222(defvar frame-initial-frame nil)
64c669bc 223
3f2f8c83
RS
224;; Record the parameters used in frame-initialize to make the initial frame.
225(defvar frame-initial-frame-alist)
226
791e09d8
RS
227(defvar frame-initial-geometry-arguments nil)
228
7e573c4a
SM
229;; startup.el calls this function before loading the user's init
230;; file - if there is no frame with a minibuffer open now, create
231;; one to display messages while loading the init file.
dc6d9681 232(defun frame-initialize ()
ff2a1c79 233 "Create an initial frame if necessary."
64c669bc 234 ;; Are we actually running under a window system at all?
2246281f
KL
235 (if (and initial-window-system
236 (not noninteractive)
237 (not (eq initial-window-system 'pc)))
7eadab74
JB
238 (progn
239 ;; If there is no frame with a minibuffer besides the terminal
240 ;; frame, then we need to create the opening frame. Make sure
241 ;; it has a minibuffer, but let initial-frame-alist omit the
242 ;; minibuffer spec.
243 (or (delq terminal-frame (minibuffer-frame-list))
36fc9c9f 244 (progn
3f2f8c83 245 (setq frame-initial-frame-alist
9688894d 246 (append initial-frame-alist default-frame-alist nil))
a8bb5882
RS
247 (or (assq 'horizontal-scroll-bars frame-initial-frame-alist)
248 (setq frame-initial-frame-alist
249 (cons '(horizontal-scroll-bars . t)
250 frame-initial-frame-alist)))
2246281f
KL
251 (setq frame-initial-frame-alist
252 (cons (cons 'window-system initial-window-system)
253 frame-initial-frame-alist))
36fc9c9f
RS
254 (setq default-minibuffer-frame
255 (setq frame-initial-frame
96a84970 256 (make-frame frame-initial-frame-alist)))
11281034
RS
257 ;; Delete any specifications for window geometry parameters
258 ;; so that we won't reapply them in frame-notice-user-settings.
259 ;; It would be wrong to reapply them then,
260 ;; because that would override explicit user resizing.
58bf6042 261 (setq initial-frame-alist
c2079f0a 262 (frame-remove-geometry-params initial-frame-alist))))
a13f8f50
KL
263 ;; Copy the environment of the Emacs process into the new frame.
264 (set-frame-parameter frame-initial-frame 'environment
265 (frame-parameter terminal-frame 'environment))
85557d7e 266 ;; At this point, we know that we have a frame open, so we
dc6d9681
JB
267 ;; can delete the terminal frame.
268 (delete-frame terminal-frame)
2246281f 269 (setq terminal-frame nil))))
85557d7e 270
8f2a992b
GM
271(defvar frame-notice-user-settings t
272 "Non-nil means function `frame-notice-user-settings' wasn't run yet.")
273
aa360da1
GM
274(declare-function tool-bar-mode "tool-bar" (&optional arg))
275
7e573c4a
SM
276;; startup.el calls this function after loading the user's init
277;; file. Now default-frame-alist and initial-frame-alist contain
278;; information to which we must react; do what needs to be done.
dc6d9681 279(defun frame-notice-user-settings ()
40d34803 280 "Act on user's init file settings of frame parameters.
0e1bfc78
KL
281React to settings of `initial-frame-alist',
282`window-system-default-frame-alist' and `default-frame-alist'
283there (in decreasing order of priority)."
7eadab74
JB
284 ;; Creating and deleting frames may shift the selected frame around,
285 ;; and thus the current buffer. Protect against that. We don't
286 ;; want to use save-excursion here, because that may also try to set
287 ;; the buffer of the selected window, which fails when the selected
288 ;; window is the minibuffer.
0e1bfc78 289 (let ((old-buffer (current-buffer))
cb01ce3f
SM
290 (window-system-frame-alist
291 (cdr (assq initial-window-system
292 window-system-default-frame-alist))))
7eadab74 293
8f2a992b
GM
294 (when (and frame-notice-user-settings
295 (null frame-initial-frame))
42002db5
EZ
296 ;; This case happens when we don't have a window system, and
297 ;; also for MS-DOS frames.
0216b738 298 (let ((parms (frame-parameters)))
8f2a992b
GM
299 ;; Don't change the frame names.
300 (setq parms (delq (assq 'name parms) parms))
301 ;; Can't modify the minibuffer parameter, so don't try.
302 (setq parms (delq (assq 'minibuffer parms) parms))
0216b738
CY
303 (modify-frame-parameters
304 nil
305 (if initial-window-system
306 parms
307 ;; initial-frame-alist and default-frame-alist were already
308 ;; applied in pc-win.el.
309 (append initial-frame-alist window-system-frame-alist
310 default-frame-alist parms nil)))
2246281f 311 (if (null initial-window-system) ;; MS-DOS does this differently in pc-win.el
42002db5
EZ
312 (let ((newparms (frame-parameters))
313 (frame (selected-frame)))
314 (tty-handle-reverse-video frame newparms)
315 ;; If we changed the background color, we need to update
316 ;; the background-mode parameter, and maybe some faces,
317 ;; too.
318 (when (assq 'background-color newparms)
319 (unless (or (assq 'background-mode initial-frame-alist)
320 (assq 'background-mode default-frame-alist))
321 (frame-set-background-mode frame))
322 (face-set-after-frame-default frame))))))
8f2a992b 323
7eadab74
JB
324 ;; If the initial frame is still around, apply initial-frame-alist
325 ;; and default-frame-alist to it.
9688894d
GM
326 (when (frame-live-p frame-initial-frame)
327
328 ;; When tool-bar has been switched off, correct the frame size
329 ;; by the lines added in x-create-frame for the tool-bar and
330 ;; switch `tool-bar-mode' off.
085ef9b3
GM
331 (when (display-graphic-p)
332 (let ((tool-bar-lines (or (assq 'tool-bar-lines initial-frame-alist)
0e1bfc78 333 (assq 'tool-bar-lines window-system-frame-alist)
085ef9b3 334 (assq 'tool-bar-lines default-frame-alist))))
5c39a60f
JR
335 (when (and tool-bar-originally-present
336 (or (null tool-bar-lines)
337 (null (cdr tool-bar-lines))
338 (eq 0 (cdr tool-bar-lines))))
085ef9b3 339 (let* ((char-height (frame-char-height frame-initial-frame))
5c39a60f 340 (image-height tool-bar-images-pixel-height)
085ef9b3
GM
341 (margin (cond ((and (consp tool-bar-button-margin)
342 (integerp (cdr tool-bar-button-margin))
343 (> tool-bar-button-margin 0))
344 (cdr tool-bar-button-margin))
345 ((and (integerp tool-bar-button-margin)
346 (> tool-bar-button-margin 0))
347 tool-bar-button-margin)
348 (t 0)))
349 (relief (if (and (integerp tool-bar-button-relief)
350 (> tool-bar-button-relief 0))
351 tool-bar-button-relief 3))
f39784dd 352 (lines (/ (+ image-height
085ef9b3
GM
353 (* 2 margin)
354 (* 2 relief)
355 (1- char-height))
356 char-height))
357 (height (frame-parameter frame-initial-frame 'height))
358 (newparms (list (cons 'height (- height lines))))
f39784dd 359 (initial-top (cdr (assq 'top
085ef9b3
GM
360 frame-initial-geometry-arguments)))
361 (top (frame-parameter frame-initial-frame 'top)))
362 (when (and (consp initial-top) (eq '- (car initial-top)))
7f18ce22
RS
363 (let ((adjusted-top
364 (cond ((and (consp top)
365 (eq '+ (car top)))
366 (list '+
367 (+ (cadr top)
368 (* lines char-height))))
369 ((and (consp top)
370 (eq '- (car top)))
371 (list '-
372 (- (cadr top)
373 (* lines char-height))))
374 (t (+ top (* lines char-height))))))
375 (setq newparms
376 (append newparms
377 `((top . ,adjusted-top))
378 nil))))
085ef9b3
GM
379 (modify-frame-parameters frame-initial-frame newparms)
380 (tool-bar-mode -1)))))
9688894d
GM
381
382 ;; The initial frame we create above always has a minibuffer.
383 ;; If the user wants to remove it, or make it a minibuffer-only
384 ;; frame, then we'll have to delete the current frame and make a
385 ;; new one; you can't remove or add a root window to/from an
386 ;; existing frame.
387 ;;
388 ;; NOTE: default-frame-alist was nil when we created the
389 ;; existing frame. We need to explicitly include
390 ;; default-frame-alist in the parameters of the screen we
391 ;; create here, so that its new value, gleaned from the user's
392 ;; .emacs file, will be applied to the existing screen.
de2f5dbe 393 (if (not (eq (cdr (or (assq 'minibuffer initial-frame-alist)
0e1bfc78 394 (assq 'minibuffer window-system-frame-alist)
de2f5dbe
GM
395 (assq 'minibuffer default-frame-alist)
396 '(minibuffer . t)))
397 t))
398 ;; Create the new frame.
399 (let (parms new)
400 ;; If the frame isn't visible yet, wait till it is.
401 ;; If the user has to position the window,
402 ;; Emacs doesn't know its real position until
403 ;; the frame is seen to be visible.
404 (while (not (cdr (assq 'visibility
405 (frame-parameters frame-initial-frame))))
406 (sleep-for 1))
407 (setq parms (frame-parameters frame-initial-frame))
9688894d 408
f39784dd 409 ;; Get rid of `name' unless it was specified explicitly before.
de2f5dbe
GM
410 (or (assq 'name frame-initial-frame-alist)
411 (setq parms (delq (assq 'name parms) parms)))
2f5bb432
SM
412 ;; An explicit parent-id is a request to XEmbed the frame.
413 (or (assq 'parent-id frame-initial-frame-alist)
414 (setq parms (delq (assq 'parent-id parms) parms)))
de2f5dbe
GM
415
416 (setq parms (append initial-frame-alist
0e1bfc78 417 window-system-frame-alist
de2f5dbe
GM
418 default-frame-alist
419 parms
420 nil))
421
422 ;; Get rid of `reverse', because that was handled
423 ;; when we first made the frame.
424 (setq parms (cons '(reverse) (delq (assq 'reverse parms) parms)))
425
426 (if (assq 'height frame-initial-geometry-arguments)
427 (setq parms (assq-delete-all 'height parms)))
428 (if (assq 'width frame-initial-geometry-arguments)
429 (setq parms (assq-delete-all 'width parms)))
430 (if (assq 'left frame-initial-geometry-arguments)
431 (setq parms (assq-delete-all 'left parms)))
432 (if (assq 'top frame-initial-geometry-arguments)
433 (setq parms (assq-delete-all 'top parms)))
434 (setq new
435 (make-frame
436 ;; Use the geometry args that created the existing
437 ;; frame, rather than the parms we get for it.
438 (append frame-initial-geometry-arguments
439 '((user-size . t) (user-position . t))
440 parms)))
441 ;; The initial frame, which we are about to delete, may be
442 ;; the only frame with a minibuffer. If it is, create a
443 ;; new one.
444 (or (delq frame-initial-frame (minibuffer-frame-list))
445 (make-initial-minibuffer-frame nil))
446
447 ;; If the initial frame is serving as a surrogate
448 ;; minibuffer frame for any frames, we need to wean them
449 ;; onto a new frame. The default-minibuffer-frame
450 ;; variable must be handled similarly.
451 (let ((users-of-initial
452 (filtered-frame-list
b7de6024
SM
453 (lambda (frame)
454 (and (not (eq frame frame-initial-frame))
455 (eq (window-frame
456 (minibuffer-window frame))
457 frame-initial-frame))))))
458 (if (or users-of-initial
de2f5dbe
GM
459 (eq default-minibuffer-frame frame-initial-frame))
460
461 ;; Choose an appropriate frame. Prefer frames which
462 ;; are only minibuffers.
463 (let* ((new-surrogate
464 (car
465 (or (filtered-frame-list
b7de6024
SM
466 (lambda (frame)
467 (eq (cdr (assq 'minibuffer
468 (frame-parameters frame)))
469 'only)))
de2f5dbe
GM
470 (minibuffer-frame-list))))
471 (new-minibuffer (minibuffer-window new-surrogate)))
472
473 (if (eq default-minibuffer-frame frame-initial-frame)
474 (setq default-minibuffer-frame new-surrogate))
475
476 ;; Wean the frames using frame-initial-frame as
477 ;; their minibuffer frame.
b7de6024
SM
478 (dolist (frame users-of-initial)
479 (modify-frame-parameters
480 frame (list (cons 'minibuffer new-minibuffer)))))))
481
482 ;; Redirect events enqueued at this frame to the new frame.
de2f5dbe
GM
483 ;; Is this a good idea?
484 (redirect-frame-focus frame-initial-frame new)
485
486 ;; Finally, get rid of the old frame.
487 (delete-frame frame-initial-frame t))
9688894d
GM
488
489 ;; Otherwise, we don't need all that rigamarole; just apply
490 ;; the new parameters.
491 (let (newparms allparms tail)
492 (setq allparms (append initial-frame-alist
0e1bfc78 493 window-system-frame-alist
9688894d
GM
494 default-frame-alist nil))
495 (if (assq 'height frame-initial-geometry-arguments)
496 (setq allparms (assq-delete-all 'height allparms)))
497 (if (assq 'width frame-initial-geometry-arguments)
498 (setq allparms (assq-delete-all 'width allparms)))
499 (if (assq 'left frame-initial-geometry-arguments)
500 (setq allparms (assq-delete-all 'left allparms)))
501 (if (assq 'top frame-initial-geometry-arguments)
502 (setq allparms (assq-delete-all 'top allparms)))
503 (setq tail allparms)
504 ;; Find just the parms that have changed since we first
505 ;; made this frame. Those are the ones actually set by
f39784dd 506 ;; the init file. For those parms whose values we already knew
9688894d
GM
507 ;; (such as those spec'd by command line options)
508 ;; it is undesirable to specify the parm again
f39784dd 509 ;; once the user has seen the frame and been able to alter it
9688894d 510 ;; manually.
0216b738
CY
511 (let (newval oldval)
512 (dolist (entry tail)
513 (setq oldval (assq (car entry) frame-initial-frame-alist))
514 (setq newval (cdr (assq (car entry) allparms)))
9688894d
GM
515 (or (and oldval (eq (cdr oldval) newval))
516 (setq newparms
0216b738 517 (cons (cons (car entry) newval) newparms)))))
9688894d 518 (setq newparms (nreverse newparms))
0216b738
CY
519
520 (let ((new-bg (assq 'background-color newparms)))
521 ;; If the `background-color' parameter is changed, apply
522 ;; it first, then make sure that the `background-mode'
523 ;; parameter and other faces are updated, before applying
524 ;; the other parameters.
525 (when new-bg
526 (modify-frame-parameters frame-initial-frame
527 (list new-bg))
528 (unless (assq 'background-mode newparms)
529 (frame-set-background-mode frame-initial-frame))
530 (face-set-after-frame-default frame-initial-frame)
531 (setq newparms (delq new-bg newparms)))
532 (modify-frame-parameters frame-initial-frame newparms)))))
64c669bc 533
7eadab74
JB
534 ;; Restore the original buffer.
535 (set-buffer old-buffer)
536
537 ;; Make sure the initial frame can be GC'd if it is ever deleted.
d202f1f2 538 ;; Make sure frame-notice-user-settings does nothing if called twice.
8f2a992b 539 (setq frame-notice-user-settings nil)
d202f1f2 540 (setq frame-initial-frame nil)))
64c669bc 541
746bd265
KH
542(defun make-initial-minibuffer-frame (display)
543 (let ((parms (append minibuffer-frame-alist '((minibuffer . only)))))
544 (if display
545 (make-frame-on-display display parms)
546 (make-frame parms))))
547
7eadab74 548;;;; Creation of additional frames, and other frame miscellanea
dc6d9681 549
63019bad 550(defun modify-all-frames-parameters (alist)
d398de43 551 "Modify all current and future frames' parameters according to ALIST.
63019bad 552This changes `default-frame-alist' and possibly `initial-frame-alist'.
095fe281
KL
553Furthermore, this function removes all parameters in ALIST from
554`window-system-default-frame-alist'.
63019bad 555See help of `modify-frame-parameters' for more information."
095fe281
KL
556 (dolist (frame (frame-list))
557 (modify-frame-parameters frame alist))
558
559 (dolist (pair alist) ;; conses to add/replace
560 ;; initial-frame-alist needs setting only when
561 ;; frame-notice-user-settings is true.
562 (and frame-notice-user-settings
563 (setq initial-frame-alist
564 (assq-delete-all (car pair) initial-frame-alist)))
565 (setq default-frame-alist
566 (assq-delete-all (car pair) default-frame-alist))
567 ;; Remove any similar settings from the window-system specific
568 ;; parameters---they would override default-frame-alist.
569 (dolist (w window-system-default-frame-alist)
570 (setcdr w (assq-delete-all (car pair) (cdr w)))))
571
63019bad
JB
572 (and frame-notice-user-settings
573 (setq initial-frame-alist (append initial-frame-alist alist)))
574 (setq default-frame-alist (append default-frame-alist alist)))
575
7253d8e0 576(defun get-other-frame ()
40d34803
DL
577 "Return some frame other than the current frame.
578Create one if necessary. Note that the minibuffer frame, if separate,
579is not considered (see `next-frame')."
dc6d9681 580 (let ((s (if (equal (next-frame (selected-frame)) (selected-frame))
6eb018ba 581 (make-frame)
dc6d9681 582 (next-frame (selected-frame)))))
64c669bc
JB
583 s))
584
dc6d9681
JB
585(defun next-multiframe-window ()
586 "Select the next window, regardless of which frame it is on."
64c669bc
JB
587 (interactive)
588 (select-window (next-window (selected-window)
589 (> (minibuffer-depth) 0)
bb2c34b1 590 0))
030f4537 591 (select-frame-set-input-focus (selected-frame)))
64c669bc 592
dc6d9681
JB
593(defun previous-multiframe-window ()
594 "Select the previous window, regardless of which frame it is on."
64c669bc
JB
595 (interactive)
596 (select-window (previous-window (selected-window)
597 (> (minibuffer-depth) 0)
bb2c34b1 598 0))
030f4537 599 (select-frame-set-input-focus (selected-frame)))
64c669bc 600
bbf6ef44 601(declare-function x-initialize-window-system "term/x-win" ())
4c1863cd 602(declare-function ns-initialize-window-system "term/ns-win" ())
5f9214ee 603(defvar x-display-name) ; term/x-win
bbf6ef44 604
6d73e337 605(defun make-frame-on-display (display &optional parameters)
c5a8bc01
CY
606 "Make a frame on display DISPLAY.
607The optional argument PARAMETERS specifies additional frame parameters."
6d73e337 608 (interactive "sMake frame on display: ")
c5a8bc01
CY
609 (cond ((featurep 'ns)
610 (when (and (boundp 'ns-initialized) (not ns-initialized))
611 (setq x-display-name display)
612 (ns-initialize-window-system))
613 (make-frame `((window-system . ns)
614 (display . ,display) . ,parameters)))
615 ((eq system-type 'windows-nt)
616 ;; On Windows, ignore DISPLAY.
617 (make-frame parameters))
618 (t
69135f12 619 (unless (string-match-p "\\`[^:]*:[0-9]+\\(\\.[0-9]+\\)?\\'" display)
c5a8bc01
CY
620 (error "Invalid display, not HOST:SERVER or HOST:SERVER.SCREEN"))
621 (when (and (boundp 'x-initialized) (not x-initialized))
622 (setq x-display-name display)
623 (x-initialize-window-system))
624 (make-frame `((window-system . x)
625 (display . ,display) . ,parameters)))))
6d73e337 626
aa360da1
GM
627(declare-function x-close-connection "xfns.c" (terminal))
628
b7de6024
SM
629(defun close-display-connection (display)
630 "Close the connection to a display, deleting all its associated frames.
631For DISPLAY, specify either a frame or a display name (a string).
632If DISPLAY is nil, that stands for the selected frame's display."
633 (interactive
634 (list
635 (let* ((default (frame-parameter nil 'display))
636 (display (completing-read
637 (format "Close display (default %s): " default)
638 (delete-dups
639 (mapcar (lambda (frame)
640 (frame-parameter frame 'display))
641 (frame-list)))
642 nil t nil nil
643 default)))
644 (if (zerop (length display)) default display))))
645 (let ((frames (delq nil
646 (mapcar (lambda (frame)
647 (if (equal display
648 (frame-parameter frame 'display))
649 frame))
650 (frame-list)))))
651 (if (and (consp frames)
652 (not (y-or-n-p (if (cdr frames)
653 (format "Delete %s frames? " (length frames))
654 (format "Delete %s ? " (car frames))))))
655 (error "Abort!")
656 (mapc 'delete-frame frames)
657 (x-close-connection display))))
658
6238bfaf 659(defun make-frame-command ()
e9e6aee8
CY
660 "Make a new frame, on the same terminal as the selected frame.
661If the terminal is a text-only terminal, this also selects the
662new frame."
6238bfaf 663 (interactive)
e9e6aee8 664 (if (display-graphic-p)
6238bfaf
RS
665 (make-frame)
666 (select-frame (make-frame))))
667
45c4fdeb
SM
668(defvar before-make-frame-hook nil
669 "Functions to run before a frame is created.")
670
671(defvar after-make-frame-functions nil
672 "Functions to run after a frame is created.
673The functions are run with one arg, the newly created frame.")
674
72bf1a8b 675(defvar after-setting-font-hook nil
81b99826
GM
676 "Functions to run after a frame's font has been changed.")
677
92e443b1 678;; Alias, kept temporarily.
84ed1560 679(define-obsolete-function-alias 'new-frame 'make-frame "22.1")
bc93c097 680
9e483377 681(defvar frame-inherited-parameters '()
ab6198b2
SM
682 ;; FIXME: Shouldn't we add `font' here as well?
683 "Parameters `make-frame' copies from the `selected-frame' to the new frame.")
684
45c4fdeb
SM
685(defun make-frame (&optional parameters)
686 "Return a newly created frame displaying the current buffer.
c1ef4455
CY
687Optional argument PARAMETERS is an alist of frame parameters for
688the new frame. Each element of PARAMETERS should have the
689form (NAME . VALUE), for example:
a105105a 690
45c4fdeb 691 (name . STRING) The frame should be named STRING.
43a2e52c 692
45c4fdeb
SM
693 (width . NUMBER) The frame should be NUMBER characters in width.
694 (height . NUMBER) The frame should be NUMBER text lines high.
43a2e52c 695
c1ef4455
CY
696You cannot specify either `width' or `height', you must specify
697neither or both.
43a2e52c 698
45c4fdeb
SM
699 (minibuffer . t) The frame should have a minibuffer.
700 (minibuffer . nil) The frame should have no minibuffer.
701 (minibuffer . only) The frame should contain only a minibuffer.
702 (minibuffer . WINDOW) The frame should use WINDOW as its minibuffer window.
43a2e52c 703
2246281f
KL
704 (window-system . nil) The frame should be displayed on a terminal device.
705 (window-system . x) The frame should be displayed in an X window.
706
d51f6378 707 (terminal . TERMINAL) The frame should use the terminal object TERMINAL.
b6660415 708
c1ef4455
CY
709In addition, any parameter specified in `default-frame-alist',
710but not present in PARAMETERS, is applied.
8de9d3f6 711
c1ef4455
CY
712Before creating the frame (via `frame-creation-function-alist'),
713this function runs the hook `before-make-frame-hook'. After
714creating the frame, it runs the hook `after-make-frame-functions'
715with one arg, the newly created frame.
716
717On graphical displays, this function does not itself make the new
718frame the selected frame. However, the window system may select
719the new frame according to its own rules."
64c669bc 720 (interactive)
b6660415 721 (let* ((w (cond
6ed8eeff
KL
722 ((assq 'terminal parameters)
723 (let ((type (terminal-live-p (cdr (assq 'terminal parameters)))))
b6660415
KL
724 (cond
725 ((eq type t) nil)
cb01ce3f
SM
726 ((eq type nil) (error "Terminal %s does not exist"
727 (cdr (assq 'terminal parameters))))
b6660415
KL
728 (t type))))
729 ((assq 'window-system parameters)
730 (cdr (assq 'window-system parameters)))
731 (t window-system)))
2246281f 732 (frame-creation-function (cdr (assq w frame-creation-function-alist)))
da8e8fc1 733 (oldframe (selected-frame))
c1ef4455 734 (params parameters)
2246281f
KL
735 frame)
736 (unless frame-creation-function
737 (error "Don't know how to create a frame on window system %s" w))
c1ef4455
CY
738 ;; Add parameters from `window-system-default-frame-alist'.
739 (dolist (p (cdr (assq w window-system-default-frame-alist)))
21bd02a6 740 (unless (assq (car p) params)
c1ef4455
CY
741 (push p params)))
742 ;; Add parameters from `default-frame-alist'.
743 (dolist (p default-frame-alist)
21bd02a6 744 (unless (assq (car p) params)
c1ef4455
CY
745 (push p params)))
746 ;; Now make the frame.
2246281f 747 (run-hooks 'before-make-frame-hook)
c1ef4455 748 (setq frame (funcall frame-creation-function params))
30a2fded 749 (normal-erase-is-backspace-setup-frame frame)
ab6198b2
SM
750 ;; Inherit the original frame's parameters.
751 (dolist (param frame-inherited-parameters)
752 (unless (assq param parameters) ;Overridden by explicit parameters.
753 (let ((val (frame-parameter oldframe param)))
754 (when val (set-frame-parameter frame param val)))))
45c4fdeb
SM
755 (run-hook-with-args 'after-make-frame-functions frame)
756 frame))
64c669bc 757
7eadab74
JB
758(defun filtered-frame-list (predicate)
759 "Return a list of all live frames which satisfy PREDICATE."
047bc928
GM
760 (let* ((frames (frame-list))
761 (list frames))
7eadab74 762 (while (consp frames)
047bc928
GM
763 (unless (funcall predicate (car frames))
764 (setcar frames nil))
7eadab74 765 (setq frames (cdr frames)))
047bc928 766 (delq nil list)))
7eadab74
JB
767
768(defun minibuffer-frame-list ()
769 "Return a list of all frames with their own minibuffers."
770 (filtered-frame-list
b7de6024
SM
771 (lambda (frame)
772 (eq frame (window-frame (minibuffer-window frame))))))
7eadab74 773
371fed4e
SM
774;; Used to be called `terminal-id' in termdev.el.
775(defun get-device-terminal (device)
776 "Return the terminal corresponding to DEVICE.
777DEVICE can be a terminal, a frame, nil (meaning the selected frame's terminal),
778the name of an X display device (HOST.SERVER.SCREEN) or a tty device file."
779 (cond
780 ((or (null device) (framep device))
781 (frame-terminal device))
782 ((stringp device)
783 (let ((f (car (filtered-frame-list
784 (lambda (frame)
785 (or (equal (frame-parameter frame 'display) device)
786 (equal (frame-parameter frame 'tty) device)))))))
787 (or f (error "Display %s does not exist" device))
788 (frame-terminal f)))
789 ((terminal-live-p device) device)
790 (t
791 (error "Invalid argument %s in `get-device-terminal'" device))))
792
793(defun frames-on-display-list (&optional device)
794 "Return a list of all frames on DEVICE.
795
796DEVICE should be a terminal, a frame,
797or a name of an X display or tty (a string of the form
9684e4c9 798HOST:SERVER.SCREEN).
b6660415 799
371fed4e 800If DEVICE is omitted or nil, it defaults to the selected
9684e4c9 801frame's terminal device."
371fed4e 802 (let* ((terminal (get-device-terminal device))
047bc928 803 (func #'(lambda (frame)
6ed8eeff 804 (eq (frame-terminal frame) terminal))))
9911648b
EZ
805 (filtered-frame-list func)))
806
f35ca2fe
KL
807(defun framep-on-display (&optional terminal)
808 "Return the type of frames on TERMINAL.
809TERMINAL may be a terminal id, a display name or a frame. If it
810is a frame, its type is returned. If TERMINAL is omitted or nil,
811it defaults to the selected frame's terminal device. All frames
812on a given display are of the same type."
6ed8eeff 813 (or (terminal-live-p terminal)
f35ca2fe
KL
814 (framep terminal)
815 (framep (car (frames-on-display-list terminal)))))
9911648b 816
58bf6042
JB
817(defun frame-remove-geometry-params (param-list)
818 "Return the parameter list PARAM-LIST, but with geometry specs removed.
819This deletes all bindings in PARAM-LIST for `top', `left', `width',
791e09d8 820`height', `user-size' and `user-position' parameters.
58bf6042
JB
821Emacs uses this to avoid overriding explicit moves and resizings from
822the user during startup."
823 (setq param-list (cons nil param-list))
824 (let ((tail param-list))
825 (while (consp (cdr tail))
826 (if (and (consp (car (cdr tail)))
791e09d8
RS
827 (memq (car (car (cdr tail)))
828 '(height width top left user-position user-size)))
829 (progn
830 (setq frame-initial-geometry-arguments
831 (cons (car (cdr tail)) frame-initial-geometry-arguments))
832 (setcdr tail (cdr (cdr tail))))
58bf6042 833 (setq tail (cdr tail)))))
e11c3dc2
KH
834 (setq frame-initial-geometry-arguments
835 (nreverse frame-initial-geometry-arguments))
58bf6042
JB
836 (cdr param-list))
837
aa360da1
GM
838(declare-function x-focus-frame "xfns.c" (frame))
839
030f4537 840(defun select-frame-set-input-focus (frame)
bbca16d8 841 "Select FRAME, raise it, and set input focus, if possible.
e343066f 842If `mouse-autoselect-window' is non-nil, also move mouse pointer
bbca16d8
MR
843to FRAME's selected window. Otherwise, if `focus-follows-mouse'
844is non-nil, move mouse cursor to FRAME."
b0c7121c
MR
845 (select-frame frame)
846 (raise-frame frame)
bbca16d8 847 ;; Ensure, if possible, that FRAME gets input focus.
b0c7121c
MR
848 (when (memq (window-system frame) '(x w32 ns))
849 (x-focus-frame frame))
bbca16d8
MR
850 ;; Move mouse cursor if necessary.
851 (cond
852 (mouse-autoselect-window
853 (let ((edges (window-inside-edges (frame-selected-window frame))))
854 ;; Move mouse cursor into FRAME's selected window to avoid that
855 ;; Emacs mouse-autoselects another window.
856 (set-mouse-position frame (nth 2 edges) (nth 1 edges))))
857 (focus-follows-mouse
858 ;; Move mouse cursor into FRAME to avoid that another frame gets
859 ;; selected by the window manager.
860 (set-mouse-position frame (1- (frame-width frame)) 0))))
030f4537 861
ceab6935 862(defun other-frame (arg)
c2c93894 863 "Select the ARGth different visible frame on current display, and raise it.
ceab6935
RM
864All frames are arranged in a cyclic order.
865This command selects the frame ARG steps away in that order.
bb578a72
RS
866A negative ARG moves in the opposite order.
867
868To make this command work properly, you must tell Emacs
869how the system (or the window manager) generally handles
870focus-switching between windows. If moving the mouse onto a window
871selects it (gives it focus), set `focus-follows-mouse' to t.
872Otherwise, that variable should be nil."
ceab6935
RM
873 (interactive "p")
874 (let ((frame (selected-frame)))
875 (while (> arg 0)
a569dbc3
RM
876 (setq frame (next-frame frame))
877 (while (not (eq (frame-visible-p frame) t))
878 (setq frame (next-frame frame)))
879 (setq arg (1- arg)))
ceab6935 880 (while (< arg 0)
a569dbc3
RM
881 (setq frame (previous-frame frame))
882 (while (not (eq (frame-visible-p frame) t))
883 (setq frame (previous-frame frame)))
915cfd1f 884 (setq arg (1+ arg)))
030f4537 885 (select-frame-set-input-focus frame)))
845cde06 886
3db7df06
SM
887(defun iconify-or-deiconify-frame ()
888 "Iconify the selected frame, or deiconify if it's currently an icon."
889 (interactive)
890 (if (eq (cdr (assq 'visibility (frame-parameters))) t)
891 (iconify-frame)
892 (make-frame-visible)))
893
0b0d3e0b
KL
894(defun suspend-frame ()
895 "Do whatever is right to suspend the current frame.
f35ca2fe
KL
896Calls `suspend-emacs' if invoked from the controlling tty device,
897`suspend-tty' from a secondary tty device, and
0b0d3e0b
KL
898`iconify-or-deiconify-frame' from an X frame."
899 (interactive)
900 (let ((type (framep (selected-frame))))
901 (cond
edfda783 902 ((memq type '(x ns w32)) (iconify-or-deiconify-frame))
0b0d3e0b 903 ((eq type t)
6ed8eeff 904 (if (controlling-tty-p)
4a933ef8
KL
905 (suspend-emacs)
906 (suspend-tty)))
0b0d3e0b
KL
907 (t (suspend-emacs)))))
908
845cde06 909(defun make-frame-names-alist ()
e2c3f530 910 ;; Only consider the frames on the same display.
845cde06
EZ
911 (let* ((current-frame (selected-frame))
912 (falist
913 (cons
914 (cons (frame-parameter current-frame 'name) current-frame) nil))
e2c3f530 915 (frame (next-frame nil 0)))
845cde06
EZ
916 (while (not (eq frame current-frame))
917 (progn
e2c3f530
SM
918 (push (cons (frame-parameter frame 'name) frame) falist)
919 (setq frame (next-frame frame 0))))
845cde06
EZ
920 falist))
921
922(defvar frame-name-history nil)
845cde06 923(defun select-frame-by-name (name)
563283b1 924 "Select the frame on the current terminal whose name is NAME and raise it.
845cde06
EZ
925If there is no frame by that name, signal an error."
926 (interactive
716ff1c9
RS
927 (let* ((frame-names-alist (make-frame-names-alist))
928 (default (car (car frame-names-alist)))
929 (input (completing-read
930 (format "Select Frame (default %s): " default)
931 frame-names-alist nil t nil 'frame-name-history)))
845cde06
EZ
932 (if (= (length input) 0)
933 (list default)
934 (list input))))
716ff1c9
RS
935 (let* ((frame-names-alist (make-frame-names-alist))
936 (frame (cdr (assoc name frame-names-alist))))
bbca16d8
MR
937 (if frame
938 (select-frame-set-input-focus frame)
939 (error "There is no frame named `%s'" name))))
64c669bc 940\f
dc6d9681
JB
941;;;; Frame configurations
942
943(defun current-frame-configuration ()
944 "Return a list describing the positions and states of all frames.
376a7584
JB
945Its car is `frame-configuration'.
946Each element of the cdr is a list of the form (FRAME ALIST WINDOW-CONFIG),
947where
948 FRAME is a frame object,
949 ALIST is an association list specifying some of FRAME's parameters, and
950 WINDOW-CONFIG is a window configuration object for FRAME."
951 (cons 'frame-configuration
b7de6024
SM
952 (mapcar (lambda (frame)
953 (list frame
954 (frame-parameters frame)
955 (current-window-configuration frame)))
376a7584 956 (frame-list))))
dc6d9681 957
68cd265f 958(defun set-frame-configuration (configuration &optional nodelete)
dc6d9681
JB
959 "Restore the frames to the state described by CONFIGURATION.
960Each frame listed in CONFIGURATION has its position, size, window
68cd265f 961configuration, and other parameters set as specified in CONFIGURATION.
d398de43
LT
962However, this function does not restore deleted frames.
963
a78db71c
RS
964Ordinarily, this function deletes all existing frames not
965listed in CONFIGURATION. But if optional second argument NODELETE
5da841d2 966is given and non-nil, the unwanted frames are iconified instead."
376a7584
JB
967 (or (frame-configuration-p configuration)
968 (signal 'wrong-type-argument
969 (list 'frame-configuration-p configuration)))
970 (let ((config-alist (cdr configuration))
971 frames-to-delete)
b7de6024
SM
972 (dolist (frame (frame-list))
973 (let ((parameters (assq frame config-alist)))
974 (if parameters
975 (progn
976 (modify-frame-parameters
977 frame
978 ;; Since we can't set a frame's minibuffer status,
979 ;; we might as well omit the parameter altogether.
980 (let* ((parms (nth 1 parameters))
b2529d56
MB
981 (mini (assq 'minibuffer parms))
982 (name (assq 'name parms))
983 (explicit-name (cdr (assq 'explicit-name parms))))
984 (when mini (setq parms (delq mini parms)))
985 ;; Leave name in iff it was set explicitly.
986 ;; This should fix the behavior reported in
987 ;; http://lists.gnu.org/archive/html/emacs-devel/2007-08/msg01632.html
988 (when (and name (not explicit-name))
989 (setq parms (delq name parms)))
b7de6024
SM
990 parms))
991 (set-window-configuration (nth 2 parameters)))
992 (setq frames-to-delete (cons frame frames-to-delete)))))
993 (mapc (if nodelete
994 ;; Note: making frames invisible here was tried
995 ;; but led to some strange behavior--each time the frame
996 ;; was made visible again, the window manager asked afresh
997 ;; for where to put it.
998 'iconify-frame
999 'delete-frame)
1000 frames-to-delete)))
64c669bc 1001\f
dc6d9681
JB
1002;;;; Convenience functions for accessing and interactively changing
1003;;;; frame parameters.
64c669bc 1004
151bdc83 1005(defun frame-height (&optional frame)
dc6d9681 1006 "Return number of lines available for display on FRAME.
4619ff5e
GM
1007If FRAME is omitted, describe the currently selected frame.
1008Exactly what is included in the return value depends on the
1009window-system and toolkit in use - see `frame-pixel-height' for
1010more details. The lines are in units of the default font height.
1011
1012The result is roughly related to the frame pixel height via
1013height in pixels = height in lines * `frame-char-height'.
1014However, this is only approximate, and is complicated e.g. by the
1015fact that individual window lines and menu bar lines can have
1016differing font heights."
151bdc83 1017 (cdr (assq 'height (frame-parameters frame))))
dc6d9681
JB
1018
1019(defun frame-width (&optional frame)
1020 "Return number of columns available for display on FRAME.
1021If FRAME is omitted, describe the currently selected frame."
151bdc83 1022 (cdr (assq 'width (frame-parameters frame))))
dc6d9681 1023
aa360da1
GM
1024(declare-function x-list-fonts "xfaces.c"
1025 (pattern &optional face frame maximum width))
1026
52ef9375 1027(define-obsolete-function-alias 'set-default-font 'set-frame-font "23.1")
1cef6541 1028(defun set-frame-font (font-name &optional keep-size)
40d34803 1029 "Set the font of the selected frame to FONT-NAME.
61298010 1030When called interactively, prompt for the name of the font to use.
1cef6541
JB
1031To get the frame's current default font, use `frame-parameters'.
1032
1033The default behavior is to keep the numbers of lines and columns in
84ed1560 1034the frame, thus may change its pixel size. If optional KEEP-SIZE is
1cef6541
JB
1035non-nil (interactively, prefix argument) the current frame size (in
1036pixels) is kept by adjusting the numbers of the lines and columns."
f39784dd 1037 (interactive
1cef6541
JB
1038 (let* ((completion-ignore-case t)
1039 (font (completing-read "Font name: "
1cef6541
JB
1040 ;; x-list-fonts will fail with an error
1041 ;; if this frame doesn't support fonts.
b7de6024
SM
1042 (x-list-fonts "*" nil (selected-frame))
1043 nil nil nil nil
1044 (frame-parameter nil 'font))))
1cef6541
JB
1045 (list font current-prefix-arg)))
1046 (let (fht fwd)
1047 (if keep-size
1048 (setq fht (* (frame-parameter nil 'height) (frame-char-height))
1049 fwd (* (frame-parameter nil 'width) (frame-char-width))))
1050 (modify-frame-parameters (selected-frame)
1051 (list (cons 'font font-name)))
1052 (if keep-size
1053 (modify-frame-parameters
1054 (selected-frame)
1055 (list (cons 'height (round fht (frame-char-height)))
1056 (cons 'width (round fwd (frame-char-width)))))))
72bf1a8b 1057 (run-hooks 'after-setting-font-hook 'after-setting-font-hooks))
64c669bc 1058
7e573c4a 1059(defun set-frame-parameter (frame parameter value)
0dac35b8
KL
1060 "Set frame parameter PARAMETER to VALUE on FRAME.
1061If FRAME is nil, it defaults to the selected frame.
c2c93894 1062See `modify-frame-parameters'."
7e573c4a
SM
1063 (modify-frame-parameters frame (list (cons parameter value))))
1064
8290babd 1065(defun set-background-color (color-name)
40d34803 1066 "Set the background color of the selected frame to COLOR-NAME.
61298010
RS
1067When called interactively, prompt for the name of the color to use.
1068To get the frame's current background color, use `frame-parameters'."
9317e499 1069 (interactive (list (read-color "Background color: ")))
dc6d9681 1070 (modify-frame-parameters (selected-frame)
528e1416
EZ
1071 (list (cons 'background-color color-name)))
1072 (or window-system
1073 (face-set-after-frame-default (selected-frame))))
64c669bc 1074
8290babd 1075(defun set-foreground-color (color-name)
40d34803 1076 "Set the foreground color of the selected frame to COLOR-NAME.
61298010
RS
1077When called interactively, prompt for the name of the color to use.
1078To get the frame's current foreground color, use `frame-parameters'."
9317e499 1079 (interactive (list (read-color "Foreground color: ")))
dc6d9681 1080 (modify-frame-parameters (selected-frame)
528e1416
EZ
1081 (list (cons 'foreground-color color-name)))
1082 (or window-system
1083 (face-set-after-frame-default (selected-frame))))
64c669bc
JB
1084
1085(defun set-cursor-color (color-name)
40d34803 1086 "Set the text cursor color of the selected frame to COLOR-NAME.
61298010
RS
1087When called interactively, prompt for the name of the color to use.
1088To get the frame's current cursor color, use `frame-parameters'."
9317e499 1089 (interactive (list (read-color "Cursor color: ")))
dc6d9681 1090 (modify-frame-parameters (selected-frame)
7eadab74 1091 (list (cons 'cursor-color color-name))))
64c669bc 1092
eaa974e1 1093(defun set-mouse-color (color-name)
40d34803 1094 "Set the color of the mouse pointer of the selected frame to COLOR-NAME.
61298010
RS
1095When called interactively, prompt for the name of the color to use.
1096To get the frame's current mouse color, use `frame-parameters'."
9317e499 1097 (interactive (list (read-color "Mouse color: ")))
dc6d9681 1098 (modify-frame-parameters (selected-frame)
ec6d4463
KH
1099 (list (cons 'mouse-color
1100 (or color-name
1101 (cdr (assq 'mouse-color
1102 (frame-parameters))))))))
7eadab74 1103
eaa974e1 1104(defun set-border-color (color-name)
40d34803 1105 "Set the color of the border of the selected frame to COLOR-NAME.
61298010
RS
1106When called interactively, prompt for the name of the color to use.
1107To get the frame's current border color, use `frame-parameters'."
9317e499 1108 (interactive (list (read-color "Border color: ")))
eaa974e1
JB
1109 (modify-frame-parameters (selected-frame)
1110 (list (cons 'border-color color-name))))
1111
f44379e7 1112(define-minor-mode auto-raise-mode
7eadab74 1113 "Toggle whether or not the selected frame should auto-raise.
6cda144f 1114With ARG, turn auto-raise mode on if and only if ARG is positive.
79e6ae33
RS
1115Note that this controls Emacs's own auto-raise feature.
1116Some window managers allow you to enable auto-raise for certain windows.
1117You can use that for Emacs windows if you wish, but if you do,
1118that is beyond the control of Emacs and this command has no effect on it."
f44379e7
SM
1119 :variable (frame-parameter nil 'auto-raise)
1120 (if (frame-parameter nil 'auto-raise)
1121 (raise-frame)))
7eadab74 1122
f44379e7 1123(define-minor-mode auto-lower-mode
7eadab74 1124 "Toggle whether or not the selected frame should auto-lower.
6cda144f 1125With ARG, turn auto-lower mode on if and only if ARG is positive.
79e6ae33
RS
1126Note that this controls Emacs's own auto-lower feature.
1127Some window managers allow you to enable auto-lower for certain windows.
1128You can use that for Emacs windows if you wish, but if you do,
1129that is beyond the control of Emacs and this command has no effect on it."
f44379e7
SM
1130 :variable (frame-parameter nil 'auto-lower))
1131
7777d03b
EZ
1132(defun set-frame-name (name)
1133 "Set the name of the selected frame to NAME.
1134When called interactively, prompt for the name of the frame.
1135The frame name is displayed on the modeline if the terminal displays only
1136one frame, otherwise the name is displayed on the frame's caption bar."
1137 (interactive "sFrame name: ")
1138 (modify-frame-parameters (selected-frame)
1139 (list (cons 'name name))))
56cfea72
KS
1140
1141(defun frame-current-scroll-bars (&optional frame)
1142 "Return the current scroll-bar settings in frame FRAME.
1cecf04d 1143Value is a cons (VERTICAL . HORIZ0NTAL) where VERTICAL specifies the
56cfea72 1144current location of the vertical scroll-bars (left, right, or nil),
1cecf04d 1145and HORIZONTAL specifies the current location of the horizontal scroll
56cfea72
KS
1146bars (top, bottom, or nil)."
1147 (let ((vert (frame-parameter frame 'vertical-scroll-bars))
1148 (hor nil))
1149 (unless (memq vert '(left right nil))
1150 (setq vert default-frame-scroll-bars))
1151 (cons vert hor)))
64c669bc 1152\f
9911648b 1153;;;; Frame/display capabilities.
6ed8eeff
KL
1154(defun selected-terminal ()
1155 "Return the terminal that is now selected."
1156 (frame-terminal (selected-frame)))
b6660415 1157
73e6adaa
DN
1158(declare-function msdos-mouse-p "dosfns.c")
1159
9911648b
EZ
1160(defun display-mouse-p (&optional display)
1161 "Return non-nil if DISPLAY has a mouse available.
1162DISPLAY can be a display name, a frame, or nil (meaning the selected
1163frame's display)."
1164 (let ((frame-type (framep-on-display display)))
1165 (cond
1166 ((eq frame-type 'pc)
1167 (msdos-mouse-p))
1168 ((eq system-type 'windows-nt)
9fa5bb32
RS
1169 (with-no-warnings
1170 (> w32-num-mouse-buttons 0)))
9e2a2647
DN
1171 ((memq frame-type '(x ns))
1172 t) ;; We assume X and NeXTstep *always* have a pointing device
9911648b 1173 (t
7565ee93
DL
1174 (or (and (featurep 'xt-mouse)
1175 xterm-mouse-mode)
1176 ;; t-mouse is distributed with the GPM package. It doesn't have
1177 ;; a toggle.
1178 (featurep 't-mouse))))))
9911648b
EZ
1179
1180(defun display-popup-menus-p (&optional display)
1181 "Return non-nil if popup menus are supported on DISPLAY.
1182DISPLAY can be a display name, a frame, or nil (meaning the selected
1183frame's display).
1184Support for popup menus requires that the mouse be available."
1185 (and
1186 (let ((frame-type (framep-on-display display)))
9e2a2647 1187 (memq frame-type '(x w32 pc ns)))
9911648b
EZ
1188 (display-mouse-p display)))
1189
1190(defun display-graphic-p (&optional display)
1191 "Return non-nil if DISPLAY is a graphic display.
1192Graphical displays are those which are capable of displaying several
1193frames and several different fonts at once. This is true for displays
1194that use a window system such as X, and false for text-only terminals.
1195DISPLAY can be a display name, a frame, or nil (meaning the selected
1196frame's display)."
9e2a2647 1197 (not (null (memq (framep-on-display display) '(x w32 ns)))))
9911648b 1198
ddc456e4
EZ
1199(defun display-images-p (&optional display)
1200 "Return non-nil if DISPLAY can display images.
1201
1202DISPLAY can be a display name, a frame, or nil (meaning the selected
1203frame's display)."
1204 (and (display-graphic-p display)
1205 (fboundp 'image-mask-p)
fcc6f5cc 1206 (fboundp 'image-size)))
ddc456e4 1207
6693b279
EZ
1208(defalias 'display-multi-frame-p 'display-graphic-p)
1209(defalias 'display-multi-font-p 'display-graphic-p)
1210
9911648b
EZ
1211(defun display-selections-p (&optional display)
1212 "Return non-nil if DISPLAY supports selections.
1213A selection is a way to transfer text or other data between programs
45240125 1214via special system buffers called `selection' or `clipboard'.
9911648b
EZ
1215DISPLAY can be a display name, a frame, or nil (meaning the selected
1216frame's display)."
1217 (let ((frame-type (framep-on-display display)))
1218 (cond
1219 ((eq frame-type 'pc)
1220 ;; MS-DOG frames support selections when Emacs runs inside
1221 ;; the Windows' DOS Box.
9fa5bb32
RS
1222 (with-no-warnings
1223 (not (null dos-windows-version))))
9e2a2647 1224 ((memq frame-type '(x w32 ns))
9911648b
EZ
1225 t) ;; FIXME?
1226 (t
1227 nil))))
1228
aa360da1
GM
1229(declare-function x-display-screens "xfns.c" (&optional terminal))
1230
9911648b
EZ
1231(defun display-screens (&optional display)
1232 "Return the number of screens associated with DISPLAY."
1233 (let ((frame-type (framep-on-display display)))
1234 (cond
9e2a2647 1235 ((memq frame-type '(x w32 ns))
9911648b 1236 (x-display-screens display))
bb9404d6 1237 (t
9911648b
EZ
1238 1))))
1239
aa360da1
GM
1240(declare-function x-display-pixel-height "xfns.c" (&optional terminal))
1241
9911648b
EZ
1242(defun display-pixel-height (&optional display)
1243 "Return the height of DISPLAY's screen in pixels.
1244For character terminals, each character counts as a single pixel."
1245 (let ((frame-type (framep-on-display display)))
1246 (cond
9e2a2647 1247 ((memq frame-type '(x w32 ns))
9911648b
EZ
1248 (x-display-pixel-height display))
1249 (t
1250 (frame-height (if (framep display) display (selected-frame)))))))
1251
aa360da1
GM
1252(declare-function x-display-pixel-width "xfns.c" (&optional terminal))
1253
9911648b
EZ
1254(defun display-pixel-width (&optional display)
1255 "Return the width of DISPLAY's screen in pixels.
1256For character terminals, each character counts as a single pixel."
1257 (let ((frame-type (framep-on-display display)))
1258 (cond
9e2a2647 1259 ((memq frame-type '(x w32 ns))
9911648b
EZ
1260 (x-display-pixel-width display))
1261 (t
1262 (frame-width (if (framep display) display (selected-frame)))))))
1263
51e39dfc
KS
1264(defcustom display-mm-dimensions-alist nil
1265 "Alist for specifying screen dimensions in millimeters.
1266The dimensions will be used for `display-mm-height' and
1267`display-mm-width' if defined for the respective display.
1268
1269Each element of the alist has the form (display . (width . height)),
1270e.g. (\":0.0\" . (287 . 215)).
1271
1272If `display' equals t, it specifies dimensions for all graphical
1273displays not explicitely specified."
1274 :version "22.1"
1275 :type '(alist :key-type (choice (string :tag "Display name")
1276 (const :tag "Default" t))
1277 :value-type (cons :tag "Dimensions"
1278 (integer :tag "Width")
1279 (integer :tag "Height")))
1280 :group 'frames)
1281
aa360da1
GM
1282(declare-function x-display-mm-height "xfns.c" (&optional terminal))
1283
9911648b
EZ
1284(defun display-mm-height (&optional display)
1285 "Return the height of DISPLAY's screen in millimeters.
d7cd2d8b 1286System values can be overridden by `display-mm-dimensions-alist'.
9911648b 1287If the information is unavailable, value is nil."
9e2a2647 1288 (and (memq (framep-on-display display) '(x w32 ns))
51e39dfc
KS
1289 (or (cddr (assoc (or display (frame-parameter nil 'display))
1290 display-mm-dimensions-alist))
1291 (cddr (assoc t display-mm-dimensions-alist))
1292 (x-display-mm-height display))))
9911648b 1293
aa360da1
GM
1294(declare-function x-display-mm-width "xfns.c" (&optional terminal))
1295
9911648b
EZ
1296(defun display-mm-width (&optional display)
1297 "Return the width of DISPLAY's screen in millimeters.
d7cd2d8b 1298System values can be overridden by `display-mm-dimensions-alist'.
9911648b 1299If the information is unavailable, value is nil."
9e2a2647 1300 (and (memq (framep-on-display display) '(x w32 ns))
51e39dfc
KS
1301 (or (cadr (assoc (or display (frame-parameter nil 'display))
1302 display-mm-dimensions-alist))
1303 (cadr (assoc t display-mm-dimensions-alist))
1304 (x-display-mm-width display))))
9911648b 1305
aa360da1
GM
1306(declare-function x-display-backing-store "xfns.c" (&optional terminal))
1307
9911648b
EZ
1308(defun display-backing-store (&optional display)
1309 "Return the backing store capability of DISPLAY's screen.
1310The value may be `always', `when-mapped', `not-useful', or nil if
1311the question is inapplicable to a certain kind of display."
1312 (let ((frame-type (framep-on-display display)))
1313 (cond
9e2a2647 1314 ((memq frame-type '(x w32 ns))
9911648b
EZ
1315 (x-display-backing-store display))
1316 (t
1317 'not-useful))))
1318
aa360da1
GM
1319(declare-function x-display-save-under "xfns.c" (&optional terminal))
1320
9911648b
EZ
1321(defun display-save-under (&optional display)
1322 "Return non-nil if DISPLAY's screen supports the SaveUnder feature."
1323 (let ((frame-type (framep-on-display display)))
1324 (cond
9e2a2647 1325 ((memq frame-type '(x w32 ns))
9911648b
EZ
1326 (x-display-save-under display))
1327 (t
1328 'not-useful))))
1329
aa360da1
GM
1330(declare-function x-display-planes "xfns.c" (&optional terminal))
1331
9911648b
EZ
1332(defun display-planes (&optional display)
1333 "Return the number of planes supported by DISPLAY."
1334 (let ((frame-type (framep-on-display display)))
1335 (cond
9e2a2647 1336 ((memq frame-type '(x w32 ns))
9911648b
EZ
1337 (x-display-planes display))
1338 ((eq frame-type 'pc)
1339 4)
1340 (t
1341 (truncate (log (length (tty-color-alist)) 2))))))
1342
aa360da1
GM
1343(declare-function x-display-color-cells "xfns.c" (&optional terminal))
1344
9911648b
EZ
1345(defun display-color-cells (&optional display)
1346 "Return the number of color cells supported by DISPLAY."
1347 (let ((frame-type (framep-on-display display)))
1348 (cond
9e2a2647 1349 ((memq frame-type '(x w32 ns))
9911648b
EZ
1350 (x-display-color-cells display))
1351 ((eq frame-type 'pc)
1352 16)
1353 (t
3224dac1 1354 (tty-display-color-cells display)))))
9911648b 1355
aa360da1
GM
1356(declare-function x-display-visual-class "xfns.c" (&optional terminal))
1357
9911648b 1358(defun display-visual-class (&optional display)
6cda144f 1359 "Return the visual class of DISPLAY.
9911648b
EZ
1360The value is one of the symbols `static-gray', `gray-scale',
1361`static-color', `pseudo-color', `true-color', or `direct-color'."
1362 (let ((frame-type (framep-on-display display)))
1363 (cond
9e2a2647 1364 ((memq frame-type '(x w32 ns))
9911648b
EZ
1365 (x-display-visual-class display))
1366 ((and (memq frame-type '(pc t))
1367 (tty-display-color-p display))
1368 'static-color)
1369 (t
1370 'static-gray))))
1371
1372\f
a32c1804
RS
1373;;;; Frame geometry values
1374
1375(defun frame-geom-value-cons (type value &optional frame)
1376 "Return equivalent geometry value for FRAME as a cons with car `+'.
1377A geometry value equivalent to VALUE for FRAME is returned,
1378where the value is a cons with car `+', not numeric.
1379TYPE is the car of the original geometry spec (TYPE . VALUE).
1380 It is `top' or `left', depending on which edge VALUE is related to.
1381VALUE is the cdr of a frame geometry spec: (left/top . VALUE).
1382If VALUE is a number, then it is converted to a cons value, perhaps
1383 relative to the opposite frame edge from that in the original spec.
1384FRAME defaults to the selected frame.
1385
1386Examples (measures in pixels) -
1387 Assuming display height/width=1024, frame height/width=600:
1388 300 inside display edge: 300 => (+ 300)
1389 (+ 300) => (+ 300)
1390 300 inside opposite display edge: (- 300) => (+ 124)
1391 -300 => (+ 124)
1392 300 beyond display edge
1393 (= 724 inside opposite display edge): (+ -300) => (+ -300)
1394 300 beyond display edge
1395 (= 724 inside opposite display edge): (- -300) => (+ 724)
1396
1397In the 3rd, 4th, and 6th examples, the returned value is relative to
1398the opposite frame edge from the edge indicated in the input spec."
1399 (cond ((and (consp value) (eq '+ (car value))) ; e.g. (+ 300), (+ -300)
1400 value)
1401 ((natnump value) (list '+ value)) ; e.g. 300 => (+ 300)
1402 (t ; e.g. -300, (- 300), (- -300)
1403 (list '+ (- (if (eq 'left type) ; => (+ 124), (+ 124), (+ 724)
1404 (x-display-pixel-width)
1405 (x-display-pixel-height))
1406 (if (integerp value) (- value) (cadr value))
1407 (if (eq 'left type)
1408 (frame-pixel-width frame)
1409 (frame-pixel-height frame)))))))
1410
1411(defun frame-geom-spec-cons (spec &optional frame)
1412 "Return equivalent geometry spec for FRAME as a cons with car `+'.
1413A geometry specification equivalent to SPEC for FRAME is returned,
1414where the value is a cons with car `+', not numeric.
1415SPEC is a frame geometry spec: (left . VALUE) or (top . VALUE).
1416If VALUE is a number, then it is converted to a cons value, perhaps
1417 relative to the opposite frame edge from that in the original spec.
1418FRAME defaults to the selected frame.
1419
1420Examples (measures in pixels) -
1421 Assuming display height=1024, frame height=600:
1422 top 300 below display top: (top . 300) => (top + 300)
1423 (top + 300) => (top + 300)
1424 bottom 300 above display bottom: (top - 300) => (top + 124)
1425 (top . -300) => (top + 124)
1426 top 300 above display top
1427 (= bottom 724 above display bottom): (top + -300) => (top + -300)
1428 bottom 300 below display bottom
1429 (= top 724 below display top): (top - -300) => (top + 724)
1430
1431In the 3rd, 4th, and 6th examples, the returned value is relative to
1432the opposite frame edge from the edge indicated in the input spec."
1433 (cons (car spec) (frame-geom-value-cons (car spec) (cdr spec))))
1434\f
9e2b097b 1435
154a757e
GM
1436(defun delete-other-frames (&optional frame)
1437 "Delete all frames except FRAME.
a2125918
GM
1438If FRAME uses another frame's minibuffer, the minibuffer frame is
1439left untouched. FRAME nil or omitted means use the selected frame."
154a757e
GM
1440 (interactive)
1441 (unless frame
1442 (setq frame (selected-frame)))
a2125918
GM
1443 (let* ((mini-frame (window-frame (minibuffer-window frame)))
1444 (frames (delq mini-frame (delq frame (frame-list)))))
5e5ae184
SM
1445 ;; Only consider frames on the same terminal.
1446 (dolist (frame (prog1 frames (setq frames nil)))
1447 (if (eq (frame-terminal) (frame-terminal frame))
1448 (push frame frames)))
a2125918
GM
1449 ;; Delete mon-minibuffer-only frames first, because `delete-frame'
1450 ;; signals an error when trying to delete a mini-frame that's
1451 ;; still in use by another frame.
1452 (dolist (frame frames)
1453 (unless (eq (frame-parameter frame 'minibuffer) 'only)
1454 (delete-frame frame)))
1455 ;; Delete minibuffer-only frames.
1456 (dolist (frame frames)
1457 (when (eq (frame-parameter frame 'minibuffer) 'only)
1458 (delete-frame frame)))))
154a757e 1459
da7829a3 1460;; miscellaneous obsolescence declarations
84ed1560
JB
1461(define-obsolete-variable-alias 'delete-frame-hook
1462 'delete-frame-functions "22.1")
da7829a3 1463
dc6d9681 1464\f
7e573c4a 1465;; Highlighting trailing whitespace.
81b99826
GM
1466
1467(make-variable-buffer-local 'show-trailing-whitespace)
1468
81b99826 1469\f
7e573c4a 1470;; Scrolling
79b14b94
GM
1471
1472(defgroup scrolling nil
1473 "Scrolling windows."
1474 :version "21.1"
1475 :group 'frames)
1476
968ecc28 1477(defvaralias 'automatic-hscrolling 'auto-hscroll-mode)
79b14b94
GM
1478
1479\f
7e573c4a 1480;; Blinking cursor
81b99826
GM
1481
1482(defgroup cursor nil
ca693be8 1483 "Displaying text cursors."
40d34803 1484 :version "21.1"
81b99826
GM
1485 :group 'frames)
1486
1487(defcustom blink-cursor-delay 0.5
6cda144f 1488 "Seconds of idle time after which cursor starts to blink."
81b99826
GM
1489 :type 'number
1490 :group 'cursor)
1491
1492(defcustom blink-cursor-interval 0.5
6cda144f 1493 "Length of cursor blink interval in seconds."
81b99826
GM
1494 :type 'number
1495 :group 'cursor)
1496
1497(defvar blink-cursor-idle-timer nil
ca693be8
GM
1498 "Timer started after `blink-cursor-delay' seconds of Emacs idle time.
1499The function `blink-cursor-start' is called when the timer fires.")
81b99826
GM
1500
1501(defvar blink-cursor-timer nil
ca693be8 1502 "Timer started from `blink-cursor-start'.
a795e09a
LT
1503This timer calls `blink-cursor-timer-function' every
1504`blink-cursor-interval' seconds.")
1505
81b99826 1506(defun blink-cursor-start ()
ca693be8
GM
1507 "Timer function called from the timer `blink-cursor-idle-timer'.
1508This starts the timer `blink-cursor-timer', which makes the cursor blink
1509if appropriate. It also arranges to cancel that timer when the next
1510command starts, by installing a pre-command hook."
81b99826 1511 (when (null blink-cursor-timer)
f9ac92c5
CY
1512 ;; Set up the timer first, so that if this signals an error,
1513 ;; blink-cursor-end is not added to pre-command-hook.
81b99826
GM
1514 (setq blink-cursor-timer
1515 (run-with-timer blink-cursor-interval blink-cursor-interval
f9ac92c5
CY
1516 'blink-cursor-timer-function))
1517 (add-hook 'pre-command-hook 'blink-cursor-end)
1518 (internal-show-cursor nil nil)))
0a5ebe4b
GM
1519
1520(defun blink-cursor-timer-function ()
1521 "Timer function of timer `blink-cursor-timer'."
1522 (internal-show-cursor nil (not (internal-show-cursor-p))))
81b99826
GM
1523
1524(defun blink-cursor-end ()
1525 "Stop cursor blinking.
ca693be8 1526This is installed as a pre-command hook by `blink-cursor-start'.
f39784dd 1527When run, it cancels the timer `blink-cursor-timer' and removes
ca693be8 1528itself as a pre-command hook."
81b99826 1529 (remove-hook 'pre-command-hook 'blink-cursor-end)
0a5ebe4b 1530 (internal-show-cursor nil t)
8ec94c16
SM
1531 (when blink-cursor-timer
1532 (cancel-timer blink-cursor-timer)
1533 (setq blink-cursor-timer nil)))
81b99826 1534
8ec94c16
SM
1535(define-minor-mode blink-cursor-mode
1536 "Toggle blinking cursor mode.
4837b516
GM
1537With a numeric argument, turn blinking cursor mode on if ARG is positive,
1538otherwise turn it off. When blinking cursor mode is enabled, the
1539cursor of the selected window blinks.
81b99826 1540
8ec94c16
SM
1541Note that this command is effective only when Emacs
1542displays through a window system, because then Emacs does its own
1543cursor display. On a text-only terminal, this is not implemented."
1544 :init-value (not (or noninteractive
1545 no-blinking-cursor
1546 (eq system-type 'ms-dos)
0afb6242 1547 (not (memq window-system '(x w32 ns)))))
adba8116 1548 :initialize 'custom-initialize-delay
8ec94c16
SM
1549 :group 'cursor
1550 :global t
1551 (if blink-cursor-idle-timer (cancel-timer blink-cursor-idle-timer))
1552 (setq blink-cursor-idle-timer nil)
1553 (blink-cursor-end)
1554 (when blink-cursor-mode
1555 ;; Hide the cursor.
1556 ;;(internal-show-cursor nil nil)
1557 (setq blink-cursor-idle-timer
1558 (run-with-idle-timer blink-cursor-delay
1559 blink-cursor-delay
1560 'blink-cursor-start))))
81b99826 1561
8ec94c16 1562(define-obsolete-variable-alias 'blink-cursor 'blink-cursor-mode "22.1")
f39784dd 1563
81b99826 1564\f
64c669bc 1565;;;; Key bindings
64c669bc 1566
6238bfaf 1567(define-key ctl-x-5-map "2" 'make-frame-command)
154a757e 1568(define-key ctl-x-5-map "1" 'delete-other-frames)
dc6d9681 1569(define-key ctl-x-5-map "0" 'delete-frame)
ceab6935 1570(define-key ctl-x-5-map "o" 'other-frame)
49116ac0 1571
dc6d9681 1572(provide 'frame)
c88ab9ce 1573
dc6d9681 1574;;; frame.el ends here