annotate lisp/prim/frame.el @ 136:b980b6286996 r20-2b2

Import from CVS: tag r20-2b2
author cvs
date Mon, 13 Aug 2007 09:31:12 +0200
parents cca96a509cfe
children 59463afc5666
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; frame.el --- multi-frame management independent of window systems.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;;;; Copyright (C) 1993, 1994 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;;;; Copyright (C) 1995, 1996 Ben Wing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Maintainer: FSF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Keywords: internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
22 ;; along with XEmacs; see the file COPYING. If not, write to the
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
23 ;; Free Software Foundation, 59 Temple Place - Suite 330,
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
24 ;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; Synched up with: FSF 19.30.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ; No need for `frame-creation-function'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;; The initial value given here for this must ask for a minibuffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;; There must always exist a frame with a minibuffer, and after we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;; delete the terminal frame, this will be the only frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (defvar initial-frame-plist '(minibuffer t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 "Plist of frame properties for creating the initial X window frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 You can set this in your `.emacs' file; for example,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (setq initial-frame-plist '(top 1 left 1 width 80 height 55))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 Properties specified here supersede the values given in `default-frame-plist'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 The format of this can also be an alist for backward compatibility.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 If the value calls for a frame without a minibuffer, and you have not created
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 a minibuffer frame on your own, one is created according to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 `minibuffer-frame-plist'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 You can specify geometry-related options for just the initial frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 by setting this variable in your `.emacs' file; however, they won't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 take effect until Emacs reads `.emacs', which happens after first creating
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 the frame. If you want the frame to have the proper geometry as soon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 as it appears, you need to use this three-step process:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 * Specify X resources to give the geometry you want.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 * Set `default-frame-plist' to override these options so that they
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 don't affect subsequent frames.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 * Set `initial-frame-plist' in a way that matches the X resources,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 to override what you put in `default-frame-plist'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (defvar minibuffer-frame-plist '(width 80 height 2 menubar-visible-p nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 default-toolbar-visible-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 "Plist of frame properties for initially creating a minibuffer frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 You can set this in your `.emacs' file; for example,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (setq minibuffer-frame-plist '(top 1 left 1 width 80 height 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 Properties specified here supersede the values given in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 `default-frame-plist'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 The format of this can also be an alist for backward compatibility.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (defvar pop-up-frame-plist nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 "Plist of frame properties used when creating pop-up frames.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 Pop-up frames are used for completions, help, and the like.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 This variable can be set in your init file, like this:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (setq pop-up-frame-plist '(width 80 height 20))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 These supersede the values given in `default-frame-plist'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 The format of this can also be an alist for backward compatibility.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (setq pop-up-frame-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (function (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (make-frame pop-up-frame-plist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (defvar special-display-frame-plist '(height 14 width 80 unsplittable t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 "*Plist of frame properties used when creating special frames.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 Special frames are used for buffers whose names are in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 `special-display-buffer-names' and for buffers whose names match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 one of the regular expressions in `special-display-regexps'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 This variable can be set in your init file, like this:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (setq special-display-frame-plist '(width 80 height 20))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 These supersede the values given in `default-frame-plist'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 The format of this can also be an alist for backward compatibility.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (defun safe-alist-to-plist (cruftiness)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (if (consp (car cruftiness))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (alist-to-plist cruftiness)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 cruftiness))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;; Display BUFFER in its own frame, reusing an existing window if any.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;; Return the window chosen.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;; Currently we do not insist on selecting the window within its frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;; If ARGS is a plist, use it as a list of frame property specs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;; #### Change, not compatible with FSF: This stuff is all so incredibly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;; junky anyway that I doubt it makes any difference.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;; If ARGS is a list whose car is t,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;; use (cadr ARGS) as a function to do the work.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ;; Pass it BUFFER as first arg, and (cddr ARGS) gives the rest of the args.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (defun special-display-popup-frame (buffer &optional args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;; if we can't display simultaneous multiple frames, just return
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;; nil and let the normal behavior take over.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (and (device-on-window-system-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (if (and args (eq t (car args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (apply (cadr args) buffer (cddr args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (let ((window (get-buffer-window buffer t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (if window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ;; If we have a window already, make it visible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (let ((frame (window-frame window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (make-frame-visible frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (raise-frame frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ;; If no window yet, make one in a new frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (let ((frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (make-frame (append (safe-alist-to-plist args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (safe-alist-to-plist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 special-display-frame-plist)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (set-window-buffer (frame-selected-window frame) buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (set-window-dedicated-p (frame-selected-window frame) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (frame-selected-window frame)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (setq special-display-function 'special-display-popup-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ;;; Handle delete-frame events from the X server.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ;(defun handle-delete-frame (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ; (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ; (let ((frame (posn-window (event-start event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ; (i 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ; (tail (frame-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ; (while tail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 ; (and (frame-visible-p (car tail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 ; (not (eq (car tail) frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ; (setq i (1+ i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ; (setq tail (cdr tail)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ; (if (> i 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ; (delete-frame frame t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ; (kill-emacs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ;;;; Arrangement of frames at startup
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ;;; 1) Load the window system startup file from the lisp library and read the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ;;; high-priority arguments (-q and the like). The window system startup
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ;;; file should create any frames specified in the window system defaults.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 ;;; 2) If no frames have been opened, we open an initial text frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 ;;; 3) Once the init file is done, we apply any newly set properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 ;;; in initial-frame-plist to the frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 ;; These are now called explicitly at the proper times,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 ;; since that is easier to understand.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ;; Actually using hooks within Emacs is bad for future maintenance. --rms.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ;; (add-hook 'before-init-hook 'frame-initialize)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ;; (add-hook 'window-setup-hook 'frame-notice-user-settings)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ;;; If we create the initial frame, this is it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (defvar frame-initial-frame nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 ;; Record the properties used in frame-initialize to make the initial frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (defvar frame-initial-frame-plist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (defvar frame-initial-geometry-arguments nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (defun canonicalize-frame-plists ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (setq initial-frame-plist (safe-alist-to-plist initial-frame-plist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (setq default-frame-plist (safe-alist-to-plist default-frame-plist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 ;;; startup.el calls this function before loading the user's init
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 ;;; file - if there is no frame with a minibuffer open now, create
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 ;;; one to display messages while loading the init file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (defun frame-initialize ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 ;; In batch mode, we actually use the initial terminal device for output.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (canonicalize-frame-plists)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (if (not (noninteractive))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ;; Don't call select-frame here - focus is a matter of WM policy.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ;; If there is no frame with a minibuffer besides the terminal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ;; frame, then we need to create the opening frame. Make sure
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ;; it has a minibuffer, but let initial-frame-plist omit the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ;; minibuffer spec.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (or (delq terminal-frame (minibuffer-frame-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (setq frame-initial-frame-plist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (append initial-frame-plist default-frame-plist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 ;; FSFmacs has scroll-bar junk here that we don't need.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (setq default-minibuffer-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (setq frame-initial-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (make-frame initial-frame-plist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (car (delq terminal-device
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (device-list))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 ;; Delete any specifications for window geometry properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 ;; so that we won't reapply them in frame-notice-user-settings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 ;; It would be wrong to reapply them then,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 ;; because that would override explicit user resizing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (setq initial-frame-plist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (frame-remove-geometry-props initial-frame-plist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 ;; At this point, we know that we have a frame open, so we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 ;; can delete the terminal device.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (delete-device terminal-device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (setq terminal-frame nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 ;; FSFmacs sets frame-creation-function here, but no need.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ;;; startup.el calls this function after loading the user's init
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 ;;; file. Now default-frame-plist and initial-frame-plist contain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 ;;; information to which we must react; do what needs to be done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (defun frame-notice-user-settings ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 ;; FSFmacs has menu-bar junk here that we don't need.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (canonicalize-frame-plists)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 ;; Creating and deleting frames may shift the selected frame around,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 ;; and thus the current buffer. Protect against that. We don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 ;; want to use save-excursion here, because that may also try to set
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 ;; the buffer of the selected window, which fails when the selected
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 ;; window is the minibuffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (let ((old-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 ;; If the initial frame is still around, apply initial-frame-plist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 ;; and default-frame-plist to it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (if (frame-live-p frame-initial-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 ;; The initial frame we create above always has a minibuffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 ;; If the user wants to remove it, or make it a minibuffer-only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 ;; frame, then we'll have to delete the current frame and make a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 ;; new one; you can't remove or add a root window to/from an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 ;; existing frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 ;; NOTE: default-frame-plist was nil when we created the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 ;; existing frame. We need to explicitly include
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 ;; default-frame-plist in the properties of the screen we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 ;; create here, so that its new value, gleaned from the user's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 ;; .emacs file, will be applied to the existing screen.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (if (not (eq (car
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (or (and (lax-plist-member
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 initial-frame-plist 'minibuffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (list (lax-plist-get initial-frame-plist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 'minibuffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (and (lax-plist-member default-frame-plist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 'minibuffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (list (lax-plist-get default-frame-plist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 'minibuffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 '(t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 ;; Create the new frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (let (props
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 ;; If the frame isn't visible yet, wait till it is.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 ;; If the user has to position the window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 ;; Emacs doesn't know its real position until
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 ;; the frame is seen to be visible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (if (frame-property frame-initial-frame 'initially-unmapped)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (while (not (frame-visible-p frame-initial-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (sleep-for 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (setq props (frame-properties frame-initial-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 ;; Get rid of `name' unless it was specified explicitly before.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (or (lax-plist-member frame-initial-frame-plist 'name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (setq props (lax-plist-remprop props 'name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (setq props (append initial-frame-plist default-frame-plist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 props
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 ;; Get rid of `reverse', because that was handled
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 ;; when we first made the frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (laxputf props 'reverse nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 ;; Get rid of `window-id', otherwise make-frame will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 ;; think we're trying to setup an external widget.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (laxremf props 'window-id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (if (lax-plist-member frame-initial-geometry-arguments 'height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (laxremf props 'height))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (if (lax-plist-member frame-initial-geometry-arguments 'width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (laxremf props 'width))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (if (lax-plist-member frame-initial-geometry-arguments 'left)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (laxremf props 'left))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (if (lax-plist-member frame-initial-geometry-arguments 'top)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (laxremf props 'top))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 ;; Now create the replacement initial frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (make-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 ;; Use the geometry args that created the existing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 ;; frame, rather than the props we get for it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (append '(user-size t user-position t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 frame-initial-geometry-arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 props))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 ;; The initial frame, which we are about to delete, may be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 ;; the only frame with a minibuffer. If it is, create a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 ;; new one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (or (delq frame-initial-frame (minibuffer-frame-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (make-initial-minibuffer-frame nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 ;; If the initial frame is serving as a surrogate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 ;; minibuffer frame for any frames, we need to wean them
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 ;; onto a new frame. The default-minibuffer-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 ;; variable must be handled similarly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (let ((users-of-initial
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (filtered-frame-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 #'(lambda (frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (and (not (eq frame frame-initial-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (eq (window-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (minibuffer-window frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 frame-initial-frame))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (if (or users-of-initial
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (eq default-minibuffer-frame frame-initial-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 ;; Choose an appropriate frame. Prefer frames which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 ;; are only minibuffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (let* ((new-surrogate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (car
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (or (filtered-frame-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 #'(lambda (frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (eq 'only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (frame-property frame 'minibuffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (minibuffer-frame-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (new-minibuffer (minibuffer-window new-surrogate)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (if (eq default-minibuffer-frame frame-initial-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (setq default-minibuffer-frame new-surrogate))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 ;; Wean the frames using frame-initial-frame as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 ;; their minibuffer frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 #'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (lambda (frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (set-frame-property frame 'minibuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 new-minibuffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 users-of-initial))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 ;; Redirect events enqueued at this frame to the new frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 ;; Is this a good idea?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 ;; Probably not, since this whole redirect-frame-focus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 ;; stuff is a load of trash, and so is this function we're in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 ;; --ben
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 ;(redirect-frame-focus frame-initial-frame new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 ;; Finally, get rid of the old frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (delete-frame frame-initial-frame t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 ;; Otherwise, we don't need all that rigamarole; just apply
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 ;; the new properties.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (let (newprops allprops tail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (setq allprops (append initial-frame-plist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 default-frame-plist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (if (lax-plist-member frame-initial-geometry-arguments 'height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (laxremf allprops 'height))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (if (lax-plist-member frame-initial-geometry-arguments 'width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (remf allprops 'width))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (if (lax-plist-member frame-initial-geometry-arguments 'left)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (laxremf allprops 'left))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (if (lax-plist-member frame-initial-geometry-arguments 'top)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (laxremf allprops 'top))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (setq tail allprops)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 ;; Find just the props that have changed since we first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 ;; made this frame. Those are the ones actually set by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 ;; the init file. For those props whose values we already knew
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 ;; (such as those spec'd by command line options)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 ;; it is undesirable to specify the parm again
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 ;; once the user has seen the frame and been able to alter it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 ;; manually.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (while tail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (let (newval oldval)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (setq oldval (lax-plist-get frame-initial-frame-plist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (car tail)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (setq newval (lax-plist-get allprops (car tail)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (or (eq oldval newval)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (laxputf newprops (car tail) newval)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (setq tail (cddr tail)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (set-frame-properties frame-initial-frame newprops)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 ;silly FSFmacs junk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 ;if (lax-plist-member newprops 'font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 ; (frame-update-faces frame-initial-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 ;; Restore the original buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (set-buffer old-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 ;; Make sure the initial frame can be GC'd if it is ever deleted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 ;; Make sure frame-notice-user-settings does nothing if called twice.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (setq frame-initial-frame nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (defun make-initial-minibuffer-frame (device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (let ((props (append '(minibuffer only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (safe-alist-to-plist minibuffer-frame-plist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (make-frame props device)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 ;;;; Creation of additional frames, and other frame miscellanea
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (defun get-other-frame ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 "Return some frame other than the current frame, creating one if necessary."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (let* ((this (selected-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 ;; search visible frames first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (next (next-frame this 'visible-nomini)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 ;; then search iconified frames
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (if (eq this next)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (setq next (next-frame 'visible-iconic-nomini)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (if (eq this next)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 ;; otherwise, make a new frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (make-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 next)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (defun next-multiframe-window ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 "Select the next window, regardless of which frame it is on."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (select-window (next-window (selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (> (minibuffer-depth) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (defun previous-multiframe-window ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 "Select the previous window, regardless of which frame it is on."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (select-window (previous-window (selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (> (minibuffer-depth) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (defun make-frame-on-device (type connection &optional props)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 "Create a frame of type TYPE on CONNECTION.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 TYPE should be a symbol naming the device type, i.e. one of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 x An X display. CONNECTION should be a standard display string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 such as \"unix:0\", or nil for the display specified on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 command line or in the DISPLAY environment variable. Only if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 support for X was compiled into XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 tty A standard TTY connection or terminal. CONNECTION should be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 a TTY device name such as \"/dev/ttyp2\" (as determined by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 the Unix command `tty') or nil for XEmacs' standard input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 and output (usually the TTY in which XEmacs started). Only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 if support for TTY's was compiled into XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 ns A connection to a machine running the NeXTstep windowing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 system. Not currently implemented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 win32 A connection to a machine running Microsoft Windows NT or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 Windows 95. Not currently implemented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 pc A direct-write MS-DOS frame. Not currently implemented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
442 PROPS should be a plist of properties, as in the call to `make-frame'.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 If a connection to CONNECTION already exists, it is reused; otherwise,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 a new connection is opened."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (make-frame props (make-device type connection props)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 ;; Alias, kept temporarily.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (defalias 'new-frame 'make-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 ; FSFmacs has make-frame here. We have it in C, so no need for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 ; frame-creation-function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (defun filtered-frame-list (predicate &optional device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 "Return a list of all live frames which satisfy PREDICATE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 If optional second arg DEVICE is non-nil, restrict the frames
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 returned to that device."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (let ((frames (if device (device-frame-list device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (frame-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 good-frames)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (while (consp frames)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (if (funcall predicate (car frames))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (setq good-frames (cons (car frames) good-frames)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (setq frames (cdr frames)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 good-frames))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (defun minibuffer-frame-list (&optional device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 "Return a list of all frames with their own minibuffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 If optional second arg DEVICE is non-nil, restrict the frames
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 returned to that device."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (filtered-frame-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 #'(lambda (frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (eq frame (window-frame (minibuffer-window frame))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 device))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (defun frame-minibuffer-only-p (frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 "Return non-nil if FRAME is a minibuffer-only frame."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (eq (frame-root-window frame) (minibuffer-window frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (defun frame-remove-geometry-props (plist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 "Return the property list PLIST, but with geometry specs removed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 This deletes all bindings in PLIST for `top', `left', `width',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 `height', `user-size' and `user-position' properties.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 Emacs uses this to avoid overriding explicit moves and resizings from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 the user during startup."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (setq plist (canonicalize-lax-plist (copy-sequence plist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (mapcar #'(lambda (propname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (if (lax-plist-member plist propname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (setq frame-initial-geometry-arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (cons propname
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (cons (lax-plist-get plist propname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 frame-initial-geometry-arguments)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (setq plist (lax-plist-remprop plist propname)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 '(height width top left user-size user-position))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 plist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (defun other-frame (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 "Select the ARG'th different visible frame, and raise it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 All frames are arranged in a cyclic order.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 This command selects the frame ARG steps away in that order.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 A negative ARG moves in the opposite order."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (let ((frame (selected-frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (while (> arg 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (setq frame (next-frame frame 'visible-nomini))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (setq arg (1- arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (while (< arg 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (setq frame (previous-frame frame 'visible-nomini))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (setq arg (1+ arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (raise-frame frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (select-frame frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 ;this is a bad idea; you should in general never warp the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 ;pointer unless the user asks for this. Furthermore,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 ;our version of `set-mouse-position' takes a window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 ;not a frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 ;(set-mouse-position (selected-frame) (1- (frame-width)) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 ;some weird FSFmacs randomness
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 ;(if (fboundp 'unfocus-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 ; (unfocus-frame))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 ;; XEmacs-added utility functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 ; this is in C in FSFmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (defun frame-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 "Return a list of all frames on all devices/consoles."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (apply 'append (mapcar 'device-frame-list (device-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (defun frame-type (&optional frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 "Return the type of the specified frame (e.g. `x' or `tty').
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 This is equivalent to the type of the frame's device.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 Value is `tty' for a tty frame (a character-only terminal),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 `x' for a frame that is an X window,
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
535 `ns' for a frame that is a NeXTstep window (not yet implemented),
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 `win32' for a frame that is a Windows or Windows NT window (not yet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 implemented),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 `pc' for a frame that is a direct-write MS-DOS frame (not yet implemented),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 `stream' for a stream frame (which acts like a stdio stream), and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 `dead' for a deleted frame."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (or frame (setq frame (selected-frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (if (not (frame-live-p frame)) 'dead
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (device-type (frame-device frame))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (defun device-or-frame-p (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 "Return non-nil if OBJECT is a device or frame."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (or (devicep object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (framep object)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (defun device-or-frame-type (device-or-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 "Return the type (e.g. `x' or `tty') of DEVICE-OR-FRAME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 DEVICE-OR-FRAME should be a device or a frame object. See `device-type'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 for a description of the possible types."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (if (devicep device-or-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (device-type device-or-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (frame-type device-or-frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (defun fw-frame (obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 "Given a frame or window, return the associated frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 Return nil otherwise."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (cond ((windowp obj) (window-frame obj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 ((framep obj) obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (t nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 ;;;; Frame configurations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (defun current-frame-configuration ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 "Return a list describing the positions and states of all frames.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 Its car is `frame-configuration'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 Each element of the cdr is a list of the form (FRAME PLIST WINDOW-CONFIG),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 where
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 FRAME is a frame object,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 PLIST is a property list specifying some of FRAME's properties, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 WINDOW-CONFIG is a window configuration object for FRAME."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (cons 'frame-configuration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (lambda (frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (list frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (frame-properties frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (current-window-configuration frame))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (frame-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (defun set-frame-configuration (configuration &optional nodelete)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 "Restore the frames to the state described by CONFIGURATION.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 Each frame listed in CONFIGURATION has its position, size, window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 configuration, and other properties set as specified in CONFIGURATION.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 Ordinarily, this function deletes all existing frames not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 listed in CONFIGURATION. But if optional second argument NODELETE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 is given and non-nil, the unwanted frames are iconified instead."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (or (frame-configuration-p configuration)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (signal 'wrong-type-argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (list 'frame-configuration-p configuration)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (let ((config-plist (cdr configuration))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 frames-to-delete)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (lambda (frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (let ((properties (assq frame config-plist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (if properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (set-frame-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 ;; Since we can't set a frame's minibuffer status,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 ;; we might as well omit the parameter altogether.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (lax-plist-remprop (nth 1 properties) 'minibuffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (set-window-configuration (nth 2 properties)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (setq frames-to-delete (cons frame frames-to-delete))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (frame-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (if nodelete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 ;; Note: making frames invisible here was tried
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 ;; but led to some strange behavior--each time the frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 ;; was made visible again, the window manager asked afresh
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 ;; for where to put it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (mapcar 'iconify-frame frames-to-delete)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (mapcar 'delete-frame frames-to-delete))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 ; this function is in subr.el in FSFmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 ; that's because they don't always include frame.el, while we do.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (defun frame-configuration-p (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 "Return non-nil if OBJECT seems to be a frame configuration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 Any list whose car is `frame-configuration' is assumed to be a frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 configuration."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (and (consp object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (eq (car object) 'frame-configuration)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 ;; FSFmacs has functions `frame-width', `frame-height' here.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 ;; We have them in C.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 ;; FSFmacs has weird functions `set-default-font', `set-background-color',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 ;; `set-foreground-color' here. They don't do sensible things like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 ;; set faces; instead they set frame properties (??!!) and call
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 ;; useless functions such as `frame-update-faces' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 ;; `frame-update-face-colors'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 ;; FSFmacs has functions `set-cursor-color', `set-mouse-color', and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 ;; `set-border-color', which refer to frame properties.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 ;; #### We need to use specifiers here.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 ;(defun auto-raise-mode (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 ; "Toggle whether or not the selected frame should auto-raise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 ;With arg, turn auto-raise mode on if and only if arg is positive.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 ;Note that this controls Emacs's own auto-raise feature.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 ;Some window managers allow you to enable auto-raise for certain windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 ;You can use that for Emacs windows if you wish, but if you do,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 ;that is beyond the control of Emacs and this command has no effect on it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 ; (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 ; (if (null arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 ; (setq arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 ; (if (frame-property (selected-frame) 'auto-raise)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 ; -1 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 ; (set-frame-property (selected-frame) 'auto-raise (> arg 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 ;(defun auto-lower-mode (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 ; "Toggle whether or not the selected frame should auto-lower.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 ;With arg, turn auto-lower mode on if and only if arg is positive.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 ;Note that this controls Emacs's own auto-lower feature.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 ;Some window managers allow you to enable auto-lower for certain windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 ;You can use that for Emacs windows if you wish, but if you do,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 ;that is beyond the control of Emacs and this command has no effect on it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 ; (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 ; (if (null arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 ; (setq arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 ; (if (frame-property (selected-frame) 'auto-lower)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 ; -1 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 ; (set-frame-property (selected-frame) 'auto-lower (> arg 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 ;; FSFmacs has silly functions `toggle-scroll-bar',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 ;; `toggle-horizontal-scrollbar'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 ;;; Iconifying emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 ;;; The function iconify-emacs replaces every non-iconified emacs window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 ;;; with a *single* icon. Iconified emacs windows are left alone. When
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 ;;; emacs is in this globally-iconified state, de-iconifying any emacs icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 ;;; will uniconify all frames that were visible, and iconify all frames
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 ;;; that were not. This is done by temporarily changing the value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 ;;; `map-frame-hook' to `deiconify-emacs' (which should never be called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 ;;; except from the map-frame-hook while emacs is iconified).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 ;;; The title of the icon representing all emacs frames is controlled by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 ;;; the variable `icon-name'. This is done by temporarily changing the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 ;;; value of `frame-icon-title-format'. Unfortunately, this changes the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 ;;; titles of all emacs icons, not just the "big" icon.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 ;;; It would be nice if existing icons were removed and restored by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 ;;; iconifying the emacs process, but I couldn't make that work yet.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 (defvar icon-name nil) ; set this at run time, not load time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 (defvar iconification-data nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 (defun iconify-emacs ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 "Replace every non-iconified FRAME with a *single* icon.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 Iconified frames are left alone. When XEmacs is in this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 globally-iconified state, de-iconifying any emacs icon will uniconify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 all frames that were visible, and iconify all frames that were not."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 (if iconification-data (error "already iconified?"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 (let* ((frames (frame-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 (rest frames)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (me (selected-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 (while rest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 (setq frame (car rest))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 (setcar rest (cons frame (frame-visible-p frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 ; (if (memq (cdr (car rest)) '(icon nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 ; (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 ; (make-frame-visible frame) ; deiconify, and process the X event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 ; (sleep-for 500 t) ; process X events; I really want to XSync() here
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 ; ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 (or (eq frame me) (make-frame-invisible frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (setq rest (cdr rest)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (or (boundp 'map-frame-hook) (setq map-frame-hook nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (or icon-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (setq icon-name (concat invocation-name " @ " (system-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (setq iconification-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 (list frame-icon-title-format map-frame-hook frames)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 frame-icon-title-format icon-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 map-frame-hook 'deiconify-emacs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (iconify-frame me)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 120
diff changeset
724
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 (defun deiconify-emacs (&optional ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 (or iconification-data (error "not iconified?"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (setq frame-icon-title-format (car iconification-data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 map-frame-hook (car (cdr iconification-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 iconification-data (car (cdr (cdr iconification-data))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 (while iconification-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (let ((visibility (cdr (car iconification-data))))
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 120
diff changeset
732 (cond (visibility ;; JV (Note non-nil means visible in XEmacs)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (make-frame-visible (car (car iconification-data))))
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 120
diff changeset
734 ; (t ;; (eq visibility 'icon) ;; JV Not in XEmacs!!!
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 ; (make-frame-visible (car (car iconification-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 ; (sleep-for 500 t) ; process X events; I really want to XSync() here
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 ; (iconify-frame (car (car iconification-data))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 ;; (t nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 (setq iconification-data (cdr iconification-data))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 (defun suspend-or-iconify-emacs ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 "Calls iconify-emacs if frame is an X frame, otherwise calls suspend-emacs"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 (interactive)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
745 (cond
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 120
diff changeset
746 ((eq (frame-type) 'x)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 120
diff changeset
747 (iconify-emacs))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 120
diff changeset
748 ((and (eq (frame-type) 'tty)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
749 (console-tty-controlling-process (selected-console)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
750 (suspend-console (selected-console)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
751 (t
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
752 (suspend-emacs))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 120
diff changeset
754 ;; This is quite a mouthful, but it should be descriptive, as it's
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 120
diff changeset
755 ;; bound to C-z
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 120
diff changeset
756 (defun suspend-emacs-or-iconify-frame ()
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 120
diff changeset
757 "Iconify current frame if it is an X frame, otherwise suspend Emacs."
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 120
diff changeset
758 (interactive)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 120
diff changeset
759 (cond ((eq (frame-type) 'x)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 120
diff changeset
760 (iconify-frame))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 120
diff changeset
761 ((and (eq (frame-type) 'tty)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 120
diff changeset
762 (console-tty-controlling-process (selected-console)))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 120
diff changeset
763 (suspend-console (selected-console)))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 120
diff changeset
764 (t
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 120
diff changeset
765 (suspend-emacs))))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 120
diff changeset
766
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 ;;; auto-raise and auto-lower
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 (defvar auto-raise-frame nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 "*If true, frames will be raised to the top when selected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 Under X, most ICCCM-compliant window managers will have an option to do this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 for you, but this variable is provided in case you're using a broken WM.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 (defvar auto-lower-frame nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 "*If true, frames will be lowered to the bottom when no longer selected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 Under X, most ICCCM-compliant window managers will have an option to do this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 for you, but this variable is provided in case you're using a broken WM.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 (defun default-select-frame-hook ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 "Implements the `auto-raise-frame' variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 For use as the value of `select-frame-hook'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 (if auto-raise-frame (raise-frame (selected-frame))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 (defun default-deselect-frame-hook ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 "Implements the `auto-lower-frame' variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 For use as the value of `deselect-frame-hook'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (if auto-lower-frame (lower-frame (selected-frame))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 (or select-frame-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 (add-hook 'select-frame-hook 'default-select-frame-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 (or deselect-frame-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (add-hook 'deselect-frame-hook 'default-deselect-frame-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
796 (defun default-drag-and-drop-functions (frame filepath &optional data)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 "Implements the `drag-and-drop-functions' variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 For use as the value of `drag-and-drop-functions'.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
799 This default simply pops up the file in the selected frame or,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
800 if the dragged object is a buffer, inserts it at point."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
801 (if data
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
802 (insert data)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
803 (let ((x pop-up-windows))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
804 (setq pop-up-windows nil)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
805 (pop-to-buffer (find-file-noselect filepath) nil frame)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
806 (make-frame-visible frame)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
807 (setq pop-up-windows x))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 (and (boundp 'drag-and-drop-functions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 (or drag-and-drop-functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 (add-hook 'drag-and-drop-functions 'default-drag-and-drop-functions)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
813 (defun cde-start-drag (begin end)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
814 "Implements the CDE drag operation.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
815 Calls the internal function cde-start-drag-internal to do the actual work."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
816 (interactive "_r")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
817 (if (featurep 'cde)
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 76
diff changeset
818 ;; Avoid build-time doc string warning by calling the function
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 76
diff changeset
819 ;; in the following roundabout way:
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 76
diff changeset
820 (funcall (intern "cde-start-drag-internal")
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 76
diff changeset
821 (buffer-substring-no-properties begin end))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
822 (error "CDE functionality not compiled in.")))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
823
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
824
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 ;;; Application-specific frame-management
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (defvar get-frame-for-buffer-default-frame-name nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 "The default frame to select; see doc of `get-frame-for-buffer'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (defvar get-frame-for-buffer-default-instance-limit nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 (defun get-frame-name-for-buffer (buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 (let ((mode (and (get-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 (save-excursion (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 major-mode))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 (or (get mode 'frame-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 get-frame-for-buffer-default-frame-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
840
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
841 (defun get-frame-for-buffer-make-new-frame (buffer &optional frame-name)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
842 (let* ((fr (make-frame (and frame-name (list (cons 'name frame-name)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (w (frame-root-window fr)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 ;; Make the one buffer being displayed in this newly created
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 ;; frame be the buffer of interest, instead of something
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 ;; random, so that it won't be shown in two-window mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 ;; Avoid calling switch-to-buffer here, since that's something
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 ;; people might want to call this routine from.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 ;; (If the root window doesn't have a buffer, then that means
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 ;; there is more than one window on the frame, which can only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 ;; happen if the user has done something funny on the frame-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 ;; creation-hook. If that's the case, leave it alone.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 (if (window-buffer w)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 (set-window-buffer w buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 fr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 (defun get-frame-for-buffer-noselect (buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 &optional not-this-window-p on-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 "Return a frame in which to display BUFFER.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 This is a subroutine of `get-frame-for-buffer' (which see)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 (let (name limit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 ((or on-frame (eq (selected-window) (minibuffer-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 ;; don't switch frames if a frame was specified, or to list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 ;; completions from the minibuffer, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 ((setq name (get-frame-name-for-buffer buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 ;; This buffer's mode expressed a preference for a frame of a particular
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 ;; name. That always takes priority.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 (let ((limit (get name 'instance-limit))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 (matching-frames '())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 frames frame already-visible)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 ;; Sort the list so that iconic frames will be found last. They
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 ;; will be used too, but mapped frames take precedence. And
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 ;; fully visible frames come before occluded frames.
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
882 ;; Hidden frames come after really visible ones
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 (setq frames
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 (sort (frame-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 #'(lambda (s1 s2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 (cond ((frame-totally-visible-p s2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 ((not (frame-visible-p s2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 (frame-visible-p s1))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
890 ((eq (frame-visible-p s2) 'hidden)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
891 (eq (frame-visible-p s1) t ))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 ((not (frame-totally-visible-p s2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 (and (frame-visible-p s1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 (frame-totally-visible-p s1)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 ;; but the selected frame should come first, even if it's occluded,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 ;; to minimize thrashing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 (setq frames (cons (selected-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 (delq (selected-frame) frames)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 (setq name (symbol-name name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 (while frames
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 (setq frame (car frames))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 (if (equal name (frame-name frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 (if (get-buffer-window buffer frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 (setq already-visible frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 frames nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 (setq matching-frames (cons frame matching-frames))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 (setq frames (cdr frames)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 (cond (already-visible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 already-visible)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 ((or (null matching-frames)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 (eq limit 0) ; means create with reckless abandon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 (and limit (< (length matching-frames) limit)))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
914 (get-frame-for-buffer-make-new-frame buffer name))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 ;; do not switch any of the window/buffer associations in an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 ;; existing frame; this function only picks a frame; the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 ;; determination of which windows on it get reused is up to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 ;; display-buffer itself.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 ;; (or (window-dedicated-p (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 ;; (switch-to-buffer buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 (car matching-frames)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 ((setq limit get-frame-for-buffer-default-instance-limit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 ;; This buffer's mode did not express a preference for a frame of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 ;; particular name, but the user wants a new frame rather than
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 ;; reusing the existing one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 (let* ((defname
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 (or (plist-get default-frame-plist 'name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 default-frame-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 (frames
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 (sort (filtered-frame-list #'(lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 (or (frame-visible-p x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 (frame-iconified-p x))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 #'(lambda (s1 s2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 (cond ((and (frame-visible-p s1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 (not (frame-visible-p s2))))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
939 ((and (eq (frame-visible-p s1) t)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
940 (eq (frame-visible-p s2) 'hidden)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 ((and (frame-visible-p s2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 (not (frame-visible-p s1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 ((and (equal (frame-name s1) defname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 (not (equal (frame-name s2) defname))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 ((and (equal (frame-name s2) defname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 (not (equal (frame-name s1) defname)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 ((frame-totally-visible-p s2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 (t))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 ;; put the selected frame last. The user wants a new frame,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 ;; so don't reuse the existing one unless forced to.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 (setq frames (append (delq (selected-frame) frames) (list frames)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 (if (or (eq limit 0) ; means create with reckless abandon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 (< (length frames) limit))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 (get-frame-for-buffer-make-new-frame buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 (car frames))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 ;; This buffer's mode did not express a preference for a frame of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 ;; particular name. So try to find a frame already displaying this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 ;; buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 (let ((w (or (get-buffer-window buffer 'visible) ; check visible first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 (get-buffer-window buffer 0)))) ; then iconic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 (cond ((null w)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 ;; It's not in any window - return nil, meaning no frame has
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 ;; preference.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 ((and not-this-window-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 (eq (selected-frame) (window-frame w)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 ;; It's in a window, but on this frame, and we have been
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 ;; asked to pick another window. Return nil, meaning no
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 ;; frame has preference.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 ;; Otherwise, return the frame of the buffer's window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 (window-frame w))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 ;; The pre-display-buffer-function is called for effect, so this needs to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 ;; actually select the frame it wants. Fdisplay_buffer() takes notice of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 ;; changes to the selected frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 (defun get-frame-for-buffer (buffer &optional not-this-window-p on-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 "Select and return a frame in which to display BUFFER.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 Normally, the buffer will simply be displayed in the current frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 But if the symbol naming the major-mode of the buffer has a 'frame-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 property (which should be a symbol), then the buffer will be displayed in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 a frame of that name. If there is no frame of that name, then one is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 created.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 If the major-mode doesn't have a 'frame-name property, then the frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 named by `get-frame-for-buffer-default-frame-name' will be used. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 that is nil (the default) then the currently selected frame will used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 If the frame-name symbol has an 'instance-limit property (an integer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 then each time a buffer of the mode in question is displayed, a new frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 with that name will be created, until there are `instance-limit' of them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 If instance-limit is 0, then a new frame will be created each time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 If a buffer is already displayed in a frame, then `instance-limit' is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 ignored, and that frame is used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 If the frame-name symbol has a 'frame-defaults property, then that is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 prepended to the `default-frame-plist' when creating a frame for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 first time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 This function may be used as the value of `pre-display-buffer-function',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 to cause the display-buffer function and its callers to exhibit the above
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 behavior."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 (let ((frame (get-frame-for-buffer-noselect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 buffer not-this-window-p on-frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 (if (not (eq frame (selected-frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 (select-frame frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 (or (frame-visible-p frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 ;; If the frame was already visible, just focus on it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 ;; If it wasn't visible (it was just created, or it used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 ;; to be iconified) then uniconify, raise, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 (make-frame-visible frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 (defun frames-of-buffer (&optional buffer visible-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 "Return list of frames that BUFFER is currently being displayed on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 If the buffer is being displayed on the currently selected frame, that frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 is first in the list. VISIBLE-ONLY will only list non-iconified frames."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 (let ((list (windows-of-buffer buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 (cur-frame (selected-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 next-frame frames save-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 (while list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 (if (memq (setq next-frame (window-frame (car list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 frames)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 (if (eq cur-frame next-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 (setq save-frame next-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 (or (not visible-only)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
1041 (frame-visible-p next-frame))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 (setq frames (append frames (list next-frame))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 (setq list (cdr list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 (if save-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 (append (list save-frame) frames)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 frames)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 116
diff changeset
1049 (defvar temp-buffer-shrink-to-fit nil
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 80
diff changeset
1050 "*When non-nil resize temporary output buffers to minimize blank lines.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 80
diff changeset
1051
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 108
diff changeset
1052 (defvar temp-buffer-max-height .5
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 108
diff changeset
1053 "*Proportion of frame to use for temp windows.")
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 108
diff changeset
1054
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 (defun show-temp-buffer-in-current-frame (buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 "For use as the value of temp-buffer-show-function:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 always displays the buffer in the current frame, regardless of the behavior
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 that would otherwise be introduced by the `pre-display-buffer-function', which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 is normally set to `get-frame-for-buffer' (which see)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 (let ((pre-display-buffer-function nil)) ; turn it off, whatever it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 (let ((window (display-buffer buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 (if (not (eq (last-nonminibuf-frame) (window-frame window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 ;; only the pre-display-buffer-function should ever do this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 (error "display-buffer switched frames on its own!!"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 (setq minibuffer-scroll-window window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 (set-window-start window 1) ; obeys narrowing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 (set-window-point window 1)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 80
diff changeset
1068 (when temp-buffer-shrink-to-fit
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 108
diff changeset
1069 (let* ((temp-window-size (round (* temp-buffer-max-height
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 108
diff changeset
1070 (frame-height (window-frame window)))))
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 108
diff changeset
1071 (size (window-displayed-height window)))
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 108
diff changeset
1072 (when (< size temp-window-size)
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 108
diff changeset
1073 (enlarge-window (- temp-window-size size) nil window)))
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 108
diff changeset
1074 (shrink-window-if-larger-than-buffer window))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 (setq pre-display-buffer-function 'get-frame-for-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 (setq temp-buffer-show-function 'show-temp-buffer-in-current-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 ;; from Bob Weiner <bweiner@pts.mot.com>, modified by Ben Wing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 (defun delete-other-frames (&optional frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 "Delete all but FRAME (or the selected frame)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 (mapcar 'delete-frame (delq (or frame (selected-frame)) (frame-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 ;; By adding primitives to directly access the window hierarchy,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 ;; we can move many functions into Lisp. We do it this way
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 ;; because the implementations are simpler in Lisp, and because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 ;; new functions like this can be added without requiring C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 ;; additions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 (defun frame-utmost-window-2 (window position left-right-p major-end-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 minor-end-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 ;; LEFT-RIGHT-P means we're looking for the leftmost or rightmost
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 ;; window, instead of the highest or lowest. In this case, we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 ;; say that the "major axis" goes left-to-right instead of top-to-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 ;; bottom. The "minor axis" always goes perpendicularly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 ;; If MAJOR-END-P is t, we're looking for a windows that abut the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 ;; end (i.e. right or bottom) of the major axis, instead of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 ;; start.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 ;; If MINOR-END-P is t, then we want to start counting from the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 ;; end of the minor axis instead of the beginning.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 ;; Here's the general idea: Imagine we're trying to count the number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 ;; of windows that abut the top; call this function foo(). So, we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 ;; start with the root window. If this is a vertical combination
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 ;; window, then foo() applied to the root window is the same as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 ;; foo() applied to the first child. If the root is a horizontal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 ;; combination window, then foo() applied to the root is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 ;; same as the sum of foo() applied to each of the children.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 ;; Otherwise, the root window is a leaf window, and foo() is 1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 ;; Now it's clear that, each time foo() encounters a leaf window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 ;; it's encountering a different window that abuts the top.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 ;; With a little examining, you can see that foo encounters the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 ;; top-abutting windows in order from left to right. We can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 ;; modify foo() to return the nth top-abutting window by simply
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 ;; keeping a global variable that is decremented each time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 ;; foo() encounters a leaf window and would return 1. If the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 ;; global counter gets to zero, we've encountered the window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 ;; we were looking for, so we exit right away using a `throw'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 ;; Otherwise, we make sure that all normal paths return nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 (let (child)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 (cond ((setq child (if left-right-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 (window-first-hchild window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 (window-first-vchild window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 (if major-end-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 (while (window-next-child child)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 (setq child (window-next-child child))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 (frame-utmost-window-2 child position left-right-p major-end-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 minor-end-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 ((setq child (if left-right-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 (window-first-vchild window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 (window-first-hchild window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 (if minor-end-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 (while (window-next-child child)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 (setq child (window-next-child child))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 (while child
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 (frame-utmost-window-2 child position left-right-p major-end-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 minor-end-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 (setq child (if minor-end-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 (window-previous-child child)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 (window-next-child child))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 (setcar position (1- (car position)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 (if (= (car position) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 (throw 'fhw-exit window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 (defun frame-utmost-window-1 (frame position left-right-p major-end-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 (let (minor-end-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 (or frame (setq frame (selected-frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 (or position (setq position 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 (if (>= position 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 (setq position (1+ position))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 (setq minor-end-p t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 (setq position (- position)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 (catch 'fhw-exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 ;; we use a cons here as a simple form of call-by-reference.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 ;; scheme has "boxes" for the same purpose.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 (frame-utmost-window-2 (frame-root-window frame) (list position)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 left-right-p major-end-p minor-end-p))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 (defun frame-highest-window (&optional frame position)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 "Return the highest window on FRAME which is at POSITION.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 If omitted, FRAME defaults to the currently selected frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 POSITION is used to distinguish between multiple windows that abut
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 the top of the frame: 0 means the leftmost window abutting the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 top of the frame, 1 the next-leftmost, etc. POSITION can also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 be less than zero: -1 means the rightmost window abutting the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 top of the frame, -2 the next-rightmost, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 If omitted, POSITION defaults to 0, i.e. the leftmost highest window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 If there is no window at the given POSITION, return nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 (frame-utmost-window-1 frame position nil nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 (defun frame-lowest-window (&optional frame position)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 "Return the lowest window on FRAME which is at POSITION.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 If omitted, FRAME defaults to the currently selected frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 POSITION is used to distinguish between multiple windows that abut
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 the bottom of the frame: 0 means the leftmost window abutting the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 bottom of the frame, 1 the next-leftmost, etc. POSITION can also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 be less than zero: -1 means the rightmost window abutting the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 bottom of the frame, -2 the next-rightmost, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 If omitted, POSITION defaults to 0, i.e. the leftmost lowest window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 If there is no window at the given POSITION, return nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 (frame-utmost-window-1 frame position nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 (defun frame-leftmost-window (&optional frame position)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 "Return the leftmost window on FRAME which is at POSITION.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 If omitted, FRAME defaults to the currently selected frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 POSITION is used to distinguish between multiple windows that abut
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 the left edge of the frame: 0 means the highest window abutting the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 left edge of the frame, 1 the next-highest, etc. POSITION can also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 be less than zero: -1 means the lowest window abutting the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 left edge of the frame, -2 the next-lowest, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 If omitted, POSITION defaults to 0, i.e. the highest leftmost window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 If there is no window at the given POSITION, return nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 (frame-utmost-window-1 frame position t nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 (defun frame-rightmost-window (&optional frame position)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 "Return the rightmost window on FRAME which is at POSITION.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 If omitted, FRAME defaults to the currently selected frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208 POSITION is used to distinguish between multiple windows that abut
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 the right edge of the frame: 0 means the highest window abutting the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 right edge of the frame, 1 the next-highest, etc. POSITION can also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 be less than zero: -1 means the lowest window abutting the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 right edge of the frame, -2 the next-lowest, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 If omitted, POSITION defaults to 0, i.e. the highest rightmost window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 If there is no window at the given POSITION, return nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 (frame-utmost-window-1 frame position t t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 ;; frame properties.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 (defun set-frame-property (frame prop val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 "Set property PROP of FRAME to VAL. See `set-frame-properties'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 (set-frame-properties frame (list prop val)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 (defun frame-height (&optional frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 "Return number of lines available for display on FRAME."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 (frame-property frame 'height))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 (defun frame-width (&optional frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 "Return number of columns available for display on FRAME."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 (frame-property frame 'width))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 (put 'cursor-color 'frame-property-alias [text-cursor background])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 (put 'modeline 'frame-property-alias 'has-modeline-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 (provide 'frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 ;;; frame.el ends here