Mercurial > emacs
annotate lisp/frame.el @ 1863:6f55c76b5789
* frame.el: Clean up initialization code.
(initial-frame-alist): Doc fix.
(minibuffer-frame-alist): New default value, with a reasonable height.
(filtered-frame-list, minibuffer-frame-list): New functions.
(frame-initialize): Use minibuffer-frame-list, instead of writing
it out.
(frame-notice-user-settings): Thoroughly rearranged.
Notice changes to default-frame-alist as well as initial-frame-alist.
Properly handle requests to make the initial frame into a
minibufferless or minibuffer-only frame.
Create a minibuffer-only frame if the initial frame should lack a
minibuffer and there are no other minibuffer frames created by the
user's initialization file.
Fix any frames using the initial frame as a surrogate minibuffer
frame.
Restore the current buffer after creating and deleting all these
frames.
* frame.el (set-default-font, set-frame-background,
set-frame-foreground, set-cursor-color, set-pointer-color,
set-auto-raise, set-auto-lower, set-vertical-bar,
set-horizontal-bar): Give these docstrings.
(set-auto-raise, set-auto-lower, set-vertical-bar,
set-horizontal-bar): Make these toggle or look at the prefix
argument, like minor modes.
* frame.el (set-vertical-bar): Use the proper parameter symbol.
(set-horizontal-bar): Signal an error indicating that horizontal
scrollbars are not implemented.
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Sun, 14 Feb 1993 14:29:30 +0000 |
parents | 04fb1d3d6992 |
children | 436edc3e74f6 |
rev | line source |
---|---|
777 | 1 ;;; frame.el --- multi-frame management independent of window systems. |
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
2 |
1769
c77a852fda5f
* frame.el (frame-notice-user-settings): Don't try to delete the
Jim Blandy <jimb@redhat.com>
parents:
1475
diff
changeset
|
3 ;;;; Copyright (C) 1990, 1992, 1993 Free Software Foundation, Inc. |
846
20674ae6bf52
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
827
diff
changeset
|
4 |
793
6fb68a1460a6
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
777
diff
changeset
|
5 ;; Maintainer: FSF |
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
6 ;; Keywords: internal |
793
6fb68a1460a6
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
777
diff
changeset
|
7 |
394 | 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 | |
806 | 12 ;;; the Free Software Foundation; either version 2, or (at your option) |
394 | 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 | |
793
6fb68a1460a6
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
777
diff
changeset
|
24 ;;; Code: |
6fb68a1460a6
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
777
diff
changeset
|
25 |
777 | 26 (defvar frame-creation-function nil |
27 "Window-system dependent function to call to create a new frame. | |
28 The window system startup file should set this to its frame creation | |
394 | 29 function, which should take an alist of parameters as its argument.") |
30 | |
1863
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
31 ;;; The initial value given here for this must ask for a minibuffer. |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
32 ;;; There must always exist a frame with a minibuffer, and after we |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
33 ;;; delete the terminal frame, this will be the only frame. |
958 | 34 (defvar initial-frame-alist '((minibuffer . t)) |
777 | 35 "Alist of values used when creating the initial emacs text frame. |
394 | 36 These may be set in your init file, like this: |
777 | 37 (setq initial-frame-alist '((top . 1) (left . 1) (width . 80) (height . 55))) |
1863
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
38 If this requests a frame without a minibuffer, and you do not create a |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
39 minibuffer frame on your own, one will be created, according to |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
40 `minibuffer-frame-alist'. |
777 | 41 These supercede the values given in frame-default-alist.") |
394 | 42 |
1863
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
43 (defvar minibuffer-frame-alist '((width . 80) (height . 2)) |
777 | 44 "Alist of values to apply to a minibuffer frame. |
394 | 45 These may be set in your init file, like this: |
777 | 46 (setq minibuffer-frame-alist |
1863
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
47 '((top . 1) (left . 1) (width . 80) (height . 2))) |
777 | 48 These supercede the values given in default-frame-alist.") |
394 | 49 |
777 | 50 (defvar pop-up-frame-alist nil |
51 "Alist of values used when creating pop-up frames. | |
52 Pop-up frames are used for completions, help, and the like. | |
394 | 53 This variable can be set in your init file, like this: |
777 | 54 (setq pop-up-frame-alist '((width . 80) (height . 20))) |
55 These supercede the values given in default-frame-alist.") | |
394 | 56 |
777 | 57 (setq pop-up-frame-function |
394 | 58 (function (lambda () |
777 | 59 (new-frame pop-up-frame-alist)))) |
394 | 60 |
61 | |
777 | 62 ;;;; Arrangement of frames at startup |
394 | 63 |
64 ;;; 1) Load the window system startup file from the lisp library and read the | |
65 ;;; high-priority arguments (-q and the like). The window system startup | |
777 | 66 ;;; file should create any frames specified in the window system defaults. |
394 | 67 ;;; |
777 | 68 ;;; 2) If no frames have been opened, we open an initial text frame. |
394 | 69 ;;; |
70 ;;; 3) Once the init file is done, we apply any newly set parameters | |
777 | 71 ;;; in initial-frame-alist to the frame. |
394 | 72 |
777 | 73 (add-hook 'before-init-hook 'frame-initialize) |
74 (add-hook 'window-setup-hook 'frame-notice-user-settings) | |
394 | 75 |
777 | 76 ;;; If we create the initial frame, this is it. |
77 (defvar frame-initial-frame nil) | |
394 | 78 |
79 ;;; startup.el calls this function before loading the user's init | |
777 | 80 ;;; file - if there is no frame with a minibuffer open now, create |
394 | 81 ;;; one to display messages while loading the init file. |
777 | 82 (defun frame-initialize () |
394 | 83 |
84 ;; Are we actually running under a window system at all? | |
85 (if (and window-system (not noninteractive)) | |
1863
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
86 (progn |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
87 ;; If there is no frame with a minibuffer besides the terminal |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
88 ;; frame, then we need to create the opening frame. Make sure |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
89 ;; it has a minibuffer, but let initial-frame-alist omit the |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
90 ;; minibuffer spec. |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
91 (or (delq terminal-frame (minibuffer-frame-list)) |
777 | 92 (setq default-minibuffer-frame |
93 (setq frame-initial-frame | |
94 (new-frame initial-frame-alist)))) | |
1863
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
95 |
777 | 96 ;; At this point, we know that we have a frame open, so we |
97 ;; can delete the terminal frame. | |
98 (delete-frame terminal-frame) | |
99 (setq terminal-frame nil)) | |
394 | 100 |
101 ;; No, we're not running a window system. Arrange to cause errors. | |
777 | 102 (setq frame-creation-function |
404
f6c751f07c4a
*** empty log message ***
Michael I. Bushnell <mib@gnu.org>
parents:
394
diff
changeset
|
103 (function |
f6c751f07c4a
*** empty log message ***
Michael I. Bushnell <mib@gnu.org>
parents:
394
diff
changeset
|
104 (lambda (parameters) |
f6c751f07c4a
*** empty log message ***
Michael I. Bushnell <mib@gnu.org>
parents:
394
diff
changeset
|
105 (error |
777 | 106 "Can't create multiple frames without a window system.")))))) |
394 | 107 |
1863
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
108 ;;; startup.el calls this function after loading the user's init |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
109 ;;; file. Now default-frame-alist and initial-frame-alist contain |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
110 ;;; information to which we must react; do what needs to be done. |
777 | 111 (defun frame-notice-user-settings () |
1863
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
112 |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
113 ;; Creating and deleting frames may shift the selected frame around, |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
114 ;; and thus the current buffer. Protect against that. We don't |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
115 ;; want to use save-excursion here, because that may also try to set |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
116 ;; the buffer of the selected window, which fails when the selected |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
117 ;; window is the minibuffer. |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
118 (let ((old-buffer (current-buffer))) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
119 |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
120 ;; If the initial frame is still around, apply initial-frame-alist |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
121 ;; and default-frame-alist to it. |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
122 (if (frame-live-p frame-initial-frame) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
123 |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
124 ;; The initial frame we create above always has a minibuffer. |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
125 ;; If the user wants to remove it, or make it a minibuffer-only |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
126 ;; frame, then we'll have to delete the current frame and make a |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
127 ;; new one; you can't remove or add a root window to/from an |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
128 ;; existing frame. |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
129 ;; |
1113 | 130 ;; NOTE: default-frame-alist was nil when we created the |
131 ;; existing frame. We need to explicitly include | |
132 ;; default-frame-alist in the parameters of the screen we | |
133 ;; create here, so that its new value, gleaned from the user's | |
134 ;; .emacs file, will be applied to the existing screen. | |
1863
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
135 (if (not (eq (cdr (or (assq 'minibuffer initial-frame-alist) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
136 (assq 'minibuffer default-frame-alist) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
137 '(minibuffer . t))) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
138 t)) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
139 ;; Create the new frame. |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
140 (let ((new |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
141 (new-frame |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
142 (append initial-frame-alist |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
143 default-frame-alist |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
144 (frame-parameters frame-initial-frame))))) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
145 |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
146 ;; The initial frame, which we are about to delete, may be |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
147 ;; the only frame with a minibuffer. If it is, create a |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
148 ;; new one. |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
149 (or (delq frame-initial-frame (minibuffer-frame-list)) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
150 (new-frame (append minibuffer-frame-alist |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
151 '((minibuffer . only))))) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
152 |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
153 ;; If the initial frame is serving as a surrogate |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
154 ;; minibuffer frame for any frames, we need to wean them |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
155 ;; onto a new frame. The default-minibuffer-frame |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
156 ;; variable must be handled similarly. |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
157 (let ((users-of-initial |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
158 (filtered-frame-list |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
159 (function (lambda (frame) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
160 (and (not (eq frame frame-initial-frame)) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
161 (eq (window-frame |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
162 (minibuffer-window frame)) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
163 frame-initial-frame))))))) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
164 (if (or users-of-initial |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
165 (eq default-minibuffer-frame frame-initial-frame)) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
166 |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
167 ;; Choose an appropriate frame. Prefer frames which |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
168 ;; are only minibuffers. |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
169 (let* ((new-surrogate |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
170 (car |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
171 (or (filtered-frame-list |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
172 (function |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
173 (lambda (frame) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
174 (eq (cdr (assq 'minibuffer |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
175 (frame-parameters frame))) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
176 'only)))) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
177 (minibuffer-frame-list)))) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
178 (new-minibuffer (minibuffer-window new-surrogate))) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
179 |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
180 (if (eq default-minibuffer-frame frame-initial-frame) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
181 (setq default-minibuffer-frame new-surrogate)) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
182 |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
183 ;; Wean the frames using frame-initial-frame as |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
184 ;; their minibuffer frame. |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
185 (mapcar |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
186 (function |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
187 (lambda (frame) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
188 (modify-frame-parameters |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
189 frame (list (cons 'minibuffer new-minibuffer))))) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
190 users-of-initial)))) |
1113 | 191 |
192 ;; Redirect events enqueued at this frame to the new frame. | |
193 ;; Is this a good idea? | |
1863
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
194 (redirect-frame-focus frame-initial-frame new) |
1113 | 195 |
1863
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
196 ;; Finally, get rid of the old frame. |
777 | 197 (delete-frame frame-initial-frame)) |
1863
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
198 |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
199 ;; Otherwise, we don't need all that rigamarole; just apply |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
200 ;; the new parameters. |
777 | 201 (modify-frame-parameters frame-initial-frame |
1113 | 202 (append initial-frame-alist |
1863
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
203 default-frame-alist)))) |
394 | 204 |
1863
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
205 ;; Restore the original buffer. |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
206 (set-buffer old-buffer) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
207 |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
208 ;; Make sure the initial frame can be GC'd if it is ever deleted. |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
209 (makunbound 'frame-initial-frame))) |
394 | 210 |
211 | |
1863
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
212 ;;;; Creation of additional frames, and other frame miscellanea |
394 | 213 |
1863
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
214 ;;; Return some frame other than the current frame, creating one if |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
215 ;;; neccessary. Note that the minibuffer frame, if separate, is not |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
216 ;;; considered (see next-frame). |
827 | 217 (defun get-other-frame () |
777 | 218 (let ((s (if (equal (next-frame (selected-frame)) (selected-frame)) |
219 (new-frame) | |
220 (next-frame (selected-frame))))) | |
394 | 221 s)) |
222 | |
777 | 223 (defun next-multiframe-window () |
224 "Select the next window, regardless of which frame it is on." | |
394 | 225 (interactive) |
226 (select-window (next-window (selected-window) | |
227 (> (minibuffer-depth) 0) | |
228 t))) | |
229 | |
777 | 230 (defun previous-multiframe-window () |
231 "Select the previous window, regardless of which frame it is on." | |
394 | 232 (interactive) |
233 (select-window (previous-window (selected-window) | |
234 (> (minibuffer-depth) 0) | |
235 t))) | |
236 | |
777 | 237 (defun new-frame (&optional parameters) |
238 "Create a new frame, displaying the current buffer. | |
539 | 239 |
542 | 240 Optional argument PARAMETERS is an alist of parameters for the new |
777 | 241 frame. Specifically, PARAMETERS is a list of pairs, each having one |
542 | 242 of the following forms: |
243 | |
777 | 244 (name . STRING) - The frame should be named STRING. |
542 | 245 |
777 | 246 (height . NUMBER) - The frame should be NUMBER text lines high. If |
542 | 247 this parameter is present, the width parameter must also be |
248 given. | |
249 | |
777 | 250 (width . NUMBER) - The frame should be NUMBER characters in width. |
542 | 251 If this parameter is present, the height parameter must also |
252 be given. | |
253 | |
777 | 254 (minibuffer . t) - the frame should have a minibuffer |
255 (minibuffer . none) - the frame should have no minibuffer | |
256 (minibuffer . only) - the frame should contain only a minibuffer | |
257 (minibuffer . WINDOW) - the frame should use WINDOW as its minibuffer window. | |
542 | 258 |
259 (NAME . VALUE), specifying the parameter and the value it should have. | |
260 NAME should be one of the following symbols: | |
261 name VALUE | |
262 | |
777 | 263 The documentation for the function x-create-frame describes |
264 additional frame parameters that Emacs will recognize when running | |
542 | 265 under the X Window System." |
394 | 266 (interactive) |
777 | 267 (funcall frame-creation-function parameters)) |
394 | 268 |
1863
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
269 (defun filtered-frame-list (predicate) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
270 "Return a list of all live frames which satisfy PREDICATE." |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
271 (let ((frames (frame-list)) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
272 good-frames) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
273 (while (consp frames) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
274 (if (funcall predicate (car frames)) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
275 (setq good-frames (cons (car frames) good-frames))) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
276 (setq frames (cdr frames))) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
277 good-frames)) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
278 |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
279 (defun minibuffer-frame-list () |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
280 "Return a list of all frames with their own minibuffers." |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
281 (filtered-frame-list |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
282 (function (lambda (frame) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
283 (eq frame (window-frame (minibuffer-window frame))))))) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
284 |
394 | 285 |
777 | 286 ;;;; Frame configurations |
756 | 287 |
777 | 288 (defun current-frame-configuration () |
289 "Return a list describing the positions and states of all frames. | |
290 Each element is a list of the form (FRAME ALIST WINDOW-CONFIG), where | |
291 FRAME is a frame object, ALIST is an association list specifying | |
292 some of FRAME's parameters, and WINDOW-CONFIG is a window | |
293 configuration object for FRAME." | |
756 | 294 (mapcar (function |
777 | 295 (lambda (frame) |
296 (list frame | |
297 (frame-parameters frame) | |
298 (current-window-configuration frame)))) | |
299 (frame-list))) | |
756 | 300 |
777 | 301 (defun set-frame-configuration (configuration) |
302 "Restore the frames to the state described by CONFIGURATION. | |
303 Each frame listed in CONFIGURATION has its position, size, window | |
756 | 304 configuration, and other parameters set as specified in CONFIGURATION." |
777 | 305 (let (frames-to-delete) |
756 | 306 (mapcar (function |
777 | 307 (lambda (frame) |
308 (let ((parameters (assq frame configuration))) | |
756 | 309 (if parameters |
310 (progn | |
777 | 311 (modify-frame-parameters frame (nth 1 parameters)) |
756 | 312 (set-window-configuration (nth 2 parameters))) |
777 | 313 (setq frames-to-delete (cons frame frames-to-delete)))))) |
314 (frame-list)) | |
315 (mapcar 'delete-frame frames-to-delete))) | |
394 | 316 |
317 | |
777 | 318 ;;;; Convenience functions for accessing and interactively changing |
319 ;;;; frame parameters. | |
394 | 320 |
826 | 321 (defun frame-height (&optional frame) |
777 | 322 "Return number of lines available for display on FRAME. |
323 If FRAME is omitted, describe the currently selected frame." | |
826 | 324 (cdr (assq 'height (frame-parameters frame)))) |
777 | 325 |
326 (defun frame-width (&optional frame) | |
327 "Return number of columns available for display on FRAME. | |
328 If FRAME is omitted, describe the currently selected frame." | |
826 | 329 (cdr (assq 'width (frame-parameters frame)))) |
777 | 330 |
394 | 331 (defun set-default-font (font-name) |
1863
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
332 "Set the font of the selected frame to FONT. |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
333 When called interactively, prompt for the name of the font to use." |
394 | 334 (interactive "sFont name: ") |
777 | 335 (modify-frame-parameters (selected-frame) |
1863
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
336 (list (cons 'font font-name)))) |
394 | 337 |
777 | 338 (defun set-frame-background (color-name) |
1863
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
339 "Set the background color of the selected frame to COLOR. |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
340 When called interactively, prompt for the name of the color to use." |
394 | 341 (interactive "sColor: ") |
777 | 342 (modify-frame-parameters (selected-frame) |
1863
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
343 (list (cons 'background-color color-name)))) |
394 | 344 |
777 | 345 (defun set-frame-foreground (color-name) |
1863
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
346 "Set the foreground color of the selected frame to COLOR. |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
347 When called interactively, prompt for the name of the color to use." |
394 | 348 (interactive "sColor: ") |
777 | 349 (modify-frame-parameters (selected-frame) |
1863
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
350 (list (cons 'foreground-color color-name)))) |
394 | 351 |
352 (defun set-cursor-color (color-name) | |
1863
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
353 "Set the text cursor color of the selected frame to COLOR. |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
354 When called interactively, prompt for the name of the color to use." |
394 | 355 (interactive "sColor: ") |
777 | 356 (modify-frame-parameters (selected-frame) |
1863
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
357 (list (cons 'cursor-color color-name)))) |
394 | 358 |
359 (defun set-pointer-color (color-name) | |
1863
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
360 "Set the color of the mouse pointer of the selected frame to COLOR. |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
361 When called interactively, prompt for the name of the color to use." |
394 | 362 (interactive "sColor: ") |
777 | 363 (modify-frame-parameters (selected-frame) |
1863
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
364 (list (cons 'mouse-color color-name)))) |
394 | 365 |
1863
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
366 (defun set-auto-raise (arg) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
367 "Toggle whether or not the selected frame should auto-raise. |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
368 With arg, turn auto-raise mode on if and only if arg is positive." |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
369 (interactive "P") |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
370 (if (null arg) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
371 (setq arg |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
372 (if (cdr (assq 'auto-raise (frame-parameters (selected-frame)))) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
373 -1 1))) |
777 | 374 (modify-frame-parameters (selected-frame) |
1863
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
375 (list (cons 'auto-raise (> arg 0))))) |
394 | 376 |
1863
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
377 (defun set-auto-lower (arg) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
378 "Toggle whether or not the selected frame should auto-lower. |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
379 With arg, turn auto-lower mode on if and only if arg is positive." |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
380 (interactive "P") |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
381 (if (null arg) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
382 (setq arg |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
383 (if (cdr (assq 'auto-lower (frame-parameters (selected-frame)))) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
384 -1 1))) |
777 | 385 (modify-frame-parameters (selected-frame) |
1863
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
386 (list (cons 'auto-lower (> arg 0))))) |
394 | 387 |
1863
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
388 (defun set-vertical-bar (arg) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
389 "Toggle whether or not the selected frame has vertical scrollbars. |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
390 With arg, turn vertical scrollbars on if and only if arg is positive." |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
391 (interactive "P") |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
392 (if (null arg) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
393 (setq arg |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
394 (if (cdr (assq 'vertical-scrollbars |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
395 (frame-parameters (selected-frame)))) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
396 -1 1))) |
777 | 397 (modify-frame-parameters (selected-frame) |
1863
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
398 (list (cons 'vertical-scrollbars (> arg 0))))) |
394 | 399 |
1863
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
400 (defun set-horizontal-bar (arg) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
401 "Toggle whether or not the selected frame has horizontal scrollbars. |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
402 With arg, turn horizontal scrollbars on if and only if arg is positive. |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
403 Horizontal scrollbars aren't implemented yet." |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
404 (interactive "P") |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
405 (error "Horizontal scrollbars aren't implemented yet.")) |
6f55c76b5789
* frame.el: Clean up initialization code.
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
406 |
394 | 407 |
777 | 408 ;;;; Aliases for backward compatibility with Emacs 18. |
409 (fset 'screen-height 'frame-height) | |
410 (fset 'screen-width 'frame-width) | |
958 | 411 |
412 (defun set-screen-width (cols &optional pretend) | |
413 "Obsolete function to change the size of the screen to COLS columns.\n\ | |
414 Optional second arg non-nil means that redisplay should use COLS columns\n\ | |
415 but that the idea of the actual width of the frame should not be changed.\n\ | |
416 This function is provided only for compatibility with Emacs 18; new code\n\ | |
1475 | 417 should use `set-frame-width instead'." |
958 | 418 (set-frame-width (selected-frame) cols pretend)) |
419 | |
420 (defun set-screen-height (lines &optional pretend) | |
421 "Obsolete function to change the height of the screen to LINES lines.\n\ | |
422 Optional second arg non-nil means that redisplay should use LINES lines\n\ | |
423 but that the idea of the actual height of the screen should not be changed.\n\ | |
424 This function is provided only for compatibility with Emacs 18; new code\n\ | |
1475 | 425 should use `set-frame-width' instead." |
958 | 426 (set-frame-height (selected-frame) lines pretend)) |
427 | |
428 (make-obsolete 'screen-height 'frame-height) | |
429 (make-obsolete 'screen-width 'frame-width) | |
430 (make-obsolete 'set-screen-width 'set-frame-width) | |
431 (make-obsolete 'set-screen-height 'set-frame-height) | |
777 | 432 |
433 | |
394 | 434 ;;;; Key bindings |
727 | 435 (defvar ctl-x-5-map (make-sparse-keymap) |
777 | 436 "Keymap for frame commands.") |
727 | 437 (fset 'ctl-x-5-prefix ctl-x-5-map) |
438 (define-key ctl-x-map "5" 'ctl-x-5-prefix) | |
394 | 439 |
777 | 440 (define-key ctl-x-5-map "2" 'new-frame) |
441 (define-key ctl-x-5-map "0" 'delete-frame) | |
584 | 442 |
777 | 443 (provide 'frame) |
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
444 |
777 | 445 ;;; frame.el ends here |