annotate lisp/frame.el @ 284:558f606b08ae r21-0b40

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