annotate lisp/frame.el @ 930:1dac458b5117

*** empty log message ***
author Eric S. Raymond <esr@snark.thyrsus.com>
date Tue, 04 Aug 1992 17:18:16 +0000
parents 336ffe2bd537
children 79204001d346
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
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
846
20674ae6bf52 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 827
diff changeset
3 ;;;; Copyright (C) 1990, 1992 Free Software Foundation, Inc.
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
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
8 ;;; This file is part of GNU Emacs.
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9 ;;;
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10 ;;; GNU Emacs is free software; you can redistribute it and/or modify
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 ;;; it under the terms of the GNU General Public License as published by
806
d42e1151eed8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 793
diff changeset
12 ;;; the Free Software Foundation; either version 2, or (at your option)
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 ;;; any later version.
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 ;;;
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15 ;;; GNU Emacs is distributed in the hope that it will be useful,
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 ;;; GNU General Public License for more details.
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19 ;;;
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20 ;;; You should have received a copy of the GNU General Public License
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21 ;;; along with GNU Emacs; see the file COPYING. If not, write to
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
26 (defvar frame-creation-function nil
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
27 "Window-system dependent function to call to create a new frame.
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
28 The window system startup file should set this to its frame creation
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29 function, which should take an alist of parameters as its argument.")
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31 ;;; The default value for this must ask for a minibuffer. There must
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
32 ;;; always exist a frame with a minibuffer, and after we delete the
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
33 ;;; terminal frame, this will be the only frame.
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
34 (defvar initial-frame-alist '((minibuffer . nil))
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
35 "Alist of values used when creating the initial emacs text frame.
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36 These may be set in your init file, like this:
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
37 (setq initial-frame-alist '((top . 1) (left . 1) (width . 80) (height . 55)))
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
38 These supercede the values given in frame-default-alist.")
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
40 (defvar minibuffer-frame-alist nil
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
41 "Alist of values to apply to a minibuffer frame.
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 These may be set in your init file, like this:
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
43 (setq minibuffer-frame-alist
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44 '((top . 1) (left . 1) (width . 80) (height . 1)))
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
45 These supercede the values given in default-frame-alist.")
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
47 (defvar pop-up-frame-alist nil
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
48 "Alist of values used when creating pop-up frames.
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
49 Pop-up frames are used for completions, help, and the like.
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 This variable can be set in your init file, like this:
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
51 (setq pop-up-frame-alist '((width . 80) (height . 20)))
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
52 These supercede the values given in default-frame-alist.")
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
54 (setq pop-up-frame-function
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55 (function (lambda ()
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
56 (new-frame pop-up-frame-alist))))
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
58
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
59 ;;;; Arrangement of frames at startup
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 ;;; 1) Load the window system startup file from the lisp library and read the
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62 ;;; high-priority arguments (-q and the like). The window system startup
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
63 ;;; file should create any frames specified in the window system defaults.
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64 ;;;
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
65 ;;; 2) If no frames have been opened, we open an initial text frame.
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66 ;;;
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67 ;;; 3) Once the init file is done, we apply any newly set parameters
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
68 ;;; in initial-frame-alist to the frame.
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
70 (add-hook 'before-init-hook 'frame-initialize)
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
71 (add-hook 'window-setup-hook 'frame-notice-user-settings)
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
73 ;;; If we create the initial frame, this is it.
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
74 (defvar frame-initial-frame nil)
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76 ;;; startup.el calls this function before loading the user's init
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
77 ;;; file - if there is no frame with a minibuffer open now, create
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
78 ;;; one to display messages while loading the init file.
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
79 (defun frame-initialize ()
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81 ;; Are we actually running under a window system at all?
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82 (if (and window-system (not noninteractive))
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
83 (let ((frames (frame-list)))
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
85 ;; Look for a frame that has a minibuffer.
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
86 (while (and frames
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
87 (or (eq (car frames) terminal-frame)
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88 (not (cdr (assq 'minibuffer
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
89 (frame-parameters
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
90 (car frames)))))))
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
91 (setq frames (cdr frames)))
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
93 ;; If there was none, then we need to create the opening frame.
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
94 (or frames
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
95 (setq default-minibuffer-frame
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
96 (setq frame-initial-frame
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
97 (new-frame initial-frame-alist))))
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
99 ;; At this point, we know that we have a frame open, so we
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
100 ;; can delete the terminal frame.
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
101 (delete-frame terminal-frame)
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
102 (setq terminal-frame nil))
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 ;; No, we're not running a window system. Arrange to cause errors.
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
105 (setq frame-creation-function
404
f6c751f07c4a *** empty log message ***
Michael I. Bushnell <mib@gnu.org>
parents: 394
diff changeset
106 (function
f6c751f07c4a *** empty log message ***
Michael I. Bushnell <mib@gnu.org>
parents: 394
diff changeset
107 (lambda (parameters)
f6c751f07c4a *** empty log message ***
Michael I. Bushnell <mib@gnu.org>
parents: 394
diff changeset
108 (error
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
109 "Can't create multiple frames without a window system."))))))
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111 ;;; startup.el calls this function after loading the user's init file.
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112 ;;; If we created a minibuffer before knowing if we had permission, we
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
113 ;;; need to see if it should go away or change. Create a text frame
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114 ;;; here.
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
115 (defun frame-notice-user-settings ()
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
116 (if frame-initial-frame
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117 (progn
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
118
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
119 ;; If the user wants a minibuffer-only frame, we'll have to
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
120 ;; make a new one; you can't remove or add a root window to/from
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
121 ;; an existing frame.
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
122 (if (eq (cdr (or (assq 'minibuffer initial-frame-alist)
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
123 '(minibuffer . t)))
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
124 'only)
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
125 (progn
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
126 (setq default-minibuffer-frame
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
127 (new-frame
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
128 (append initial-frame-alist
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
129 (frame-parameters frame-initial-frame))))
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
130 (delete-frame frame-initial-frame))
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
131 (modify-frame-parameters frame-initial-frame
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
132 initial-frame-alist))))
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
134 ;; Make sure the initial frame can be GC'd if it is ever deleted.
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
135 (makunbound 'frame-initial-frame))
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
137
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
138 ;;;; Creation of additional frames
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
140 ;;; Return some frame other than the current frame,
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
141 ;;; creating one if neccessary. Note that the minibuffer frame, if
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
142 ;;; separate, is not considered (see next-frame).
827
731cb9bcbad0 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 826
diff changeset
143 (defun get-other-frame ()
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
144 (let ((s (if (equal (next-frame (selected-frame)) (selected-frame))
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
145 (new-frame)
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
146 (next-frame (selected-frame)))))
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
147 s))
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
149 (defun next-multiframe-window ()
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
150 "Select the next window, regardless of which frame it is on."
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
151 (interactive)
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152 (select-window (next-window (selected-window)
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153 (> (minibuffer-depth) 0)
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154 t)))
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
156 (defun previous-multiframe-window ()
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
157 "Select the previous window, regardless of which frame it is on."
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158 (interactive)
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
159 (select-window (previous-window (selected-window)
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
160 (> (minibuffer-depth) 0)
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
161 t)))
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
162
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
163 (defun new-frame (&optional parameters)
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
164 "Create a new frame, displaying the current buffer.
539
b99d4eb7ed93 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 428
diff changeset
165
542
119ba212b686 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 539
diff changeset
166 Optional argument PARAMETERS is an alist of parameters for the new
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
167 frame. Specifically, PARAMETERS is a list of pairs, each having one
542
119ba212b686 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 539
diff changeset
168 of the following forms:
119ba212b686 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 539
diff changeset
169
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
170 (name . STRING) - The frame should be named STRING.
542
119ba212b686 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 539
diff changeset
171
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
172 (height . NUMBER) - The frame should be NUMBER text lines high. If
542
119ba212b686 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 539
diff changeset
173 this parameter is present, the width parameter must also be
119ba212b686 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 539
diff changeset
174 given.
119ba212b686 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 539
diff changeset
175
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
176 (width . NUMBER) - The frame should be NUMBER characters in width.
542
119ba212b686 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 539
diff changeset
177 If this parameter is present, the height parameter must also
119ba212b686 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 539
diff changeset
178 be given.
119ba212b686 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 539
diff changeset
179
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
180 (minibuffer . t) - the frame should have a minibuffer
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
181 (minibuffer . none) - the frame should have no minibuffer
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
182 (minibuffer . only) - the frame should contain only a minibuffer
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
183 (minibuffer . WINDOW) - the frame should use WINDOW as its minibuffer window.
542
119ba212b686 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 539
diff changeset
184
119ba212b686 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 539
diff changeset
185 (NAME . VALUE), specifying the parameter and the value it should have.
119ba212b686 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 539
diff changeset
186 NAME should be one of the following symbols:
119ba212b686 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 539
diff changeset
187 name VALUE
119ba212b686 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 539
diff changeset
188
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
189 The documentation for the function x-create-frame describes
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
190 additional frame parameters that Emacs will recognize when running
542
119ba212b686 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 539
diff changeset
191 under the X Window System."
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
192 (interactive)
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
193 (funcall frame-creation-function parameters))
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
194
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
195
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
196 ;;;; Frame configurations
756
0276f8eb306f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
197
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
198 (defun current-frame-configuration ()
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
199 "Return a list describing the positions and states of all frames.
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
200 Each element is a list of the form (FRAME ALIST WINDOW-CONFIG), where
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
201 FRAME is a frame object, ALIST is an association list specifying
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
202 some of FRAME's parameters, and WINDOW-CONFIG is a window
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
203 configuration object for FRAME."
756
0276f8eb306f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
204 (mapcar (function
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
205 (lambda (frame)
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
206 (list frame
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
207 (frame-parameters frame)
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
208 (current-window-configuration frame))))
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
209 (frame-list)))
756
0276f8eb306f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
210
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
211 (defun set-frame-configuration (configuration)
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
212 "Restore the frames to the state described by CONFIGURATION.
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
213 Each frame listed in CONFIGURATION has its position, size, window
756
0276f8eb306f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
214 configuration, and other parameters set as specified in CONFIGURATION."
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
215 (let (frames-to-delete)
756
0276f8eb306f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
216 (mapcar (function
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
217 (lambda (frame)
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
218 (let ((parameters (assq frame configuration)))
756
0276f8eb306f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
219 (if parameters
0276f8eb306f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
220 (progn
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
221 (modify-frame-parameters frame (nth 1 parameters))
756
0276f8eb306f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
222 (set-window-configuration (nth 2 parameters)))
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
223 (setq frames-to-delete (cons frame frames-to-delete))))))
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
224 (frame-list))
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
225 (mapcar 'delete-frame frames-to-delete)))
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
226
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
228 ;;;; Convenience functions for accessing and interactively changing
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
229 ;;;; frame parameters.
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230
826
e9b9a1cff2c9 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 811
diff changeset
231 (defun frame-height (&optional frame)
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
232 "Return number of lines available for display on FRAME.
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
233 If FRAME is omitted, describe the currently selected frame."
826
e9b9a1cff2c9 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 811
diff changeset
234 (cdr (assq 'height (frame-parameters frame))))
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
235
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
236 (defun frame-width (&optional frame)
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
237 "Return number of columns available for display on FRAME.
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
238 If FRAME is omitted, describe the currently selected frame."
826
e9b9a1cff2c9 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 811
diff changeset
239 (cdr (assq 'width (frame-parameters frame))))
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
240
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
241 (defun set-frame-height (h)
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
242 (interactive "NHeight: ")
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
243 (let* ((frame (selected-frame))
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
244 (width (cdr (assoc 'width (frame-parameters (selected-frame))))))
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
245 (set-frame-size (selected-frame) width h)))
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
246
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
247 (defun set-frame-width (w)
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
248 (interactive "NWidth: ")
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
249 (let* ((frame (selected-frame))
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
250 (height (cdr (assoc 'height (frame-parameters (selected-frame))))))
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
251 (set-frame-size (selected-frame) w height)))
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
252
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
253 (defun set-default-font (font-name)
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
254 (interactive "sFont name: ")
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
255 (modify-frame-parameters (selected-frame)
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
256 (list (cons 'font font-name))))
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
257
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
258 (defun set-frame-background (color-name)
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
259 (interactive "sColor: ")
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
260 (modify-frame-parameters (selected-frame)
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
261 (list (cons 'background-color color-name))))
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
262
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
263 (defun set-frame-foreground (color-name)
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
264 (interactive "sColor: ")
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
265 (modify-frame-parameters (selected-frame)
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
266 (list (cons 'foreground-color color-name))))
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
267
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
268 (defun set-cursor-color (color-name)
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
269 (interactive "sColor: ")
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
270 (modify-frame-parameters (selected-frame)
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
271 (list (cons 'cursor-color color-name))))
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
272
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
273 (defun set-pointer-color (color-name)
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
274 (interactive "sColor: ")
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
275 (modify-frame-parameters (selected-frame)
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
276 (list (cons 'mouse-color color-name))))
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
277
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
278 (defun set-auto-raise (toggle)
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
279 (interactive "xt or nil? ")
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
280 (modify-frame-parameters (selected-frame)
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
281 (list (cons 'auto-raise toggle))))
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
282
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
283 (defun set-auto-lower (toggle)
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
284 (interactive "xt or nil? ")
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
285 (modify-frame-parameters (selected-frame)
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
286 (list (cons 'auto-lower toggle))))
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
287
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
288 (defun set-vertical-bar (toggle)
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
289 (interactive "xt or nil? ")
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
290 (modify-frame-parameters (selected-frame)
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
291 (list (cons 'vertical-scroll-bar toggle))))
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
292
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
293 (defun set-horizontal-bar (toggle)
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
294 (interactive "xt or nil? ")
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
295 (modify-frame-parameters (selected-frame)
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
296 (list (cons 'horizontal-scroll-bar toggle))))
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
297
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
298 ;;;; Aliases for backward compatibility with Emacs 18.
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
299 (fset 'screen-height 'frame-height)
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
300 (fset 'screen-width 'frame-width)
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
301 (fset 'set-screen-width 'set-frame-width)
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
302 (fset 'set-screen-height 'set-frame-height)
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
303
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
304
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
305 ;;;; Key bindings
727
540b047ece4d *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
306 (defvar ctl-x-5-map (make-sparse-keymap)
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
307 "Keymap for frame commands.")
727
540b047ece4d *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
308 (fset 'ctl-x-5-prefix ctl-x-5-map)
540b047ece4d *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
309 (define-key ctl-x-map "5" 'ctl-x-5-prefix)
394
5bd386d1a1cc Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
310
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
311 (define-key ctl-x-5-map "2" 'new-frame)
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
312 (define-key ctl-x-5-map "0" 'delete-frame)
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 542
diff changeset
313
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
314 (provide 'frame)
658
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
315
777
c99faf9381bb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 756
diff changeset
316 ;;; frame.el ends here