Mercurial > hg > xemacs-beta
comparison lisp/frame.el @ 1942:da8cdcec6dff
[xemacs-hg @ 2004-03-08 15:22:44 by james]
frame.el synch with Emacs 21.3.
author | james |
---|---|
date | Mon, 08 Mar 2004 15:23:03 +0000 |
parents | 4a27df428c73 |
children | ecf1ebac70d8 |
comparison
equal
deleted
inserted
replaced
1941:0637d85c1dd1 | 1942:da8cdcec6dff |
---|---|
1 ;;; frame.el --- multi-frame management independent of window systems. | 1 ;;; frame.el --- multi-frame management independent of window systems. |
2 | 2 |
3 ;; Copyright (C) 1993-4, 1997 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1993, 1994, 1996, 1997, 2000, 2001, 2003 |
4 ;; Free Software Foundation, Inc. | |
4 ;; Copyright (C) 1995, 1996 Ben Wing. | 5 ;; Copyright (C) 1995, 1996 Ben Wing. |
5 | 6 |
6 ;; Maintainer: XEmacs Development Team | 7 ;; Maintainer: XEmacs Development Team |
7 ;; Keywords: internal, dumped | 8 ;; Keywords: internal, dumped |
8 | 9 |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
19 ;; General Public License for more details. | 20 ;; General Public License for more details. |
20 | 21 |
21 ;; You should have received a copy of the GNU General Public License | 22 ;; You should have received a copy of the GNU General Public License |
22 ;; along with XEmacs; see the file COPYING. If not, write to the | 23 ;; along with XEmacs; see the file COPYING. If not, write to the |
23 ;; Free Software Foundation, 59 Temple Place - Suite 330, | 24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
24 ;; Boston, MA 02111-1307, USA. | 25 ;; Boston, MA 02111-1307, USA. |
25 | 26 |
26 ;;; Synched up with: FSF 19.30. | 27 ;;; Synched up with: FSF 21.3. |
27 | 28 |
28 ;;; Commentary: | 29 ;;; Commentary: |
29 | 30 |
30 ;; This file is dumped with XEmacs. | 31 ;; This file is dumped with XEmacs. |
31 | 32 |
32 ;;; Code: | 33 ;;; Code: |
33 | 34 |
35 ;; XEmacs addition | |
34 (defgroup frames nil | 36 (defgroup frames nil |
35 "Support for Emacs frames and window systems." | 37 "Support for Emacs frames and window systems." |
36 :group 'environment) | 38 :group 'environment) |
37 | 39 |
38 ; No need for `frame-creation-function'. | 40 ;; XEmacs change: No need for `frame-creation-function'. |
39 | 41 |
42 ;; XEmacs change: Emacs no longer specifies the minibuffer property here. | |
40 ;;; The initial value given here for this must ask for a minibuffer. | 43 ;;; The initial value given here for this must ask for a minibuffer. |
41 ;;; There must always exist a frame with a minibuffer, and after we | 44 ;;; There must always exist a frame with a minibuffer, and after we |
42 ;;; delete the terminal frame, this will be the only frame. | 45 ;;; delete the terminal frame, this will be the only frame. |
43 (defcustom initial-frame-plist '(minibuffer t) | 46 (defcustom initial-frame-plist '(minibuffer t) |
44 "Plist of frame properties for creating the initial X window frame. | 47 "Plist of frame properties for creating the initial X window frame. |
63 to override what you put in `default-frame-plist'." | 66 to override what you put in `default-frame-plist'." |
64 :type 'plist | 67 :type 'plist |
65 :group 'frames) | 68 :group 'frames) |
66 | 69 |
67 (defcustom minibuffer-frame-plist '(width 80 height 2 menubar-visible-p nil | 70 (defcustom minibuffer-frame-plist '(width 80 height 2 menubar-visible-p nil |
68 default-toolbar-visible-p nil) | 71 default-toolbar-visible-p nil) |
69 "Plist of frame properties for initially creating a minibuffer frame. | 72 "Plist of frame properties for initially creating a minibuffer frame. |
70 You can set this in your `.emacs' file; for example, | 73 You can set this in your `.emacs' file; for example, |
71 (setq minibuffer-frame-plist '(top 1 left 1 width 80 height 2)) | 74 (setq minibuffer-frame-plist '(top 1 left 1 width 80 height 2)) |
72 Properties specified here supersede the values given in | 75 Properties specified here supersede the values given in |
73 `default-frame-plist'. | 76 `default-frame-plist'. |
78 (defcustom pop-up-frame-plist nil | 81 (defcustom pop-up-frame-plist nil |
79 "Plist of frame properties used when creating pop-up frames. | 82 "Plist of frame properties used when creating pop-up frames. |
80 Pop-up frames are used for completions, help, and the like. | 83 Pop-up frames are used for completions, help, and the like. |
81 This variable can be set in your init file, like this: | 84 This variable can be set in your init file, like this: |
82 (setq pop-up-frame-plist '(width 80 height 20)) | 85 (setq pop-up-frame-plist '(width 80 height 20)) |
83 These supersede the values given in `default-frame-plist'. | 86 These supersede the values given in `default-frame-plist', for pop-up frames. |
84 The format of this can also be an alist for backward compatibility." | 87 The format of this can also be an alist for backward compatibility." |
85 :type 'plist | 88 :type 'plist |
86 :group 'frames) | 89 :group 'frames) |
87 | 90 |
88 (setq pop-up-frame-function | 91 (setq pop-up-frame-function |
89 (function (lambda () | 92 #'(lambda () |
90 (make-frame pop-up-frame-plist)))) | 93 (make-frame pop-up-frame-plist))) |
91 | 94 |
92 (defcustom special-display-frame-plist '(height 14 width 80 unsplittable t) | 95 (defcustom special-display-frame-plist '(height 14 width 80 unsplittable t) |
93 "*Plist of frame properties used when creating special frames. | 96 "*Plist of frame properties used when creating special frames. |
94 Special frames are used for buffers whose names are in | 97 Special frames are used for buffers whose names are in |
95 `special-display-buffer-names' and for buffers whose names match | 98 `special-display-buffer-names' and for buffers whose names match |
99 These supersede the values given in `default-frame-plist'. | 102 These supersede the values given in `default-frame-plist'. |
100 The format of this can also be an alist for backward compatibility." | 103 The format of this can also be an alist for backward compatibility." |
101 :type 'plist | 104 :type 'plist |
102 :group 'frames) | 105 :group 'frames) |
103 | 106 |
107 ;; XEmacs addition | |
104 (defun safe-alist-to-plist (cruftiness) | 108 (defun safe-alist-to-plist (cruftiness) |
105 (if (consp (car cruftiness)) | 109 (if (consp (car cruftiness)) |
106 (alist-to-plist cruftiness) | 110 (alist-to-plist cruftiness) |
107 cruftiness)) | 111 cruftiness)) |
108 | 112 |
109 ;; Display BUFFER in its own frame, reusing an existing window if any. | 113 ;; XEmacs change: require args to be a plist instead of an alist. |
110 ;; Return the window chosen. | |
111 ;; Currently we do not insist on selecting the window within its frame. | |
112 ;; If ARGS is a plist, use it as a list of frame property specs. | |
113 ;; #### Change, not compatible with FSF: This stuff is all so incredibly | |
114 ;; junky anyway that I doubt it makes any difference. | |
115 ;; If ARGS is a list whose car is t, | |
116 ;; use (cadr ARGS) as a function to do the work. | |
117 ;; Pass it BUFFER as first arg, and (cddr ARGS) gives the rest of the args. | |
118 (defun special-display-popup-frame (buffer &optional args) | 114 (defun special-display-popup-frame (buffer &optional args) |
115 "Display BUFFER in its own frame, reusing an existing window if any. | |
116 Return the window chosen. | |
117 Currently we do not insist on selecting the window within its frame. | |
118 If ARGS is a plist, use it as a list of frame property specs. | |
119 If ARGS is a list whose car is t, | |
120 use (cadr ARGS) as a function to do the work. | |
121 Pass it BUFFER as first arg, and (cddr ARGS) gives the rest of the args." | |
119 ;; if we can't display simultaneous multiple frames, just return | 122 ;; if we can't display simultaneous multiple frames, just return |
120 ;; nil and let the normal behavior take over. | 123 ;; nil and let the normal behavior take over. |
121 (and (device-on-window-system-p) | 124 (and (device-on-window-system-p) |
122 (if (and args (eq t (car args))) | 125 (if (and args (eq t (car args))) |
123 (apply (cadr args) buffer (cddr args)) | 126 (apply (cadr args) buffer (cddr args)) |
124 (let ((window (get-buffer-window buffer t))) | 127 (let ((window (get-buffer-window buffer t))) |
125 (if window | 128 (setq args (safe-alist-to-plist args)) |
126 ;; If we have a window already, make it visible. | 129 (or |
127 (let ((frame (window-frame window))) | 130 ;; If we have a window already, make it visible. |
128 (make-frame-visible frame) | 131 (when window |
129 (raise-frame frame) | 132 (let ((frame (window-frame window))) |
130 window) | 133 (make-frame-visible frame) |
131 ;; If no window yet, make one in a new frame. | 134 (raise-frame frame) |
132 (let ((frame | 135 window)) |
133 (make-frame (append (safe-alist-to-plist args) | 136 ;; Reuse the current window if the user requested it. |
134 (safe-alist-to-plist | 137 (when (lax-plist-get args 'same-window) |
135 special-display-frame-plist))))) | 138 (condition-case nil |
136 (set-window-buffer (frame-selected-window frame) buffer) | 139 (progn (switch-to-buffer buffer) (selected-window)) |
137 (set-window-dedicated-p (frame-selected-window frame) t) | 140 (error nil))) |
138 (frame-selected-window frame))))))) | 141 ;; Stay on the same frame if requested. |
139 | 142 (when (or (lax-plist-get args 'same-frame) |
140 (setq special-display-function 'special-display-popup-frame) | 143 (lax-plist-get args 'same-window)) |
141 | 144 (let* ((pop-up-frames nil) (pop-up-windows t) |
142 ;;; Handle delete-frame events from the X server. | 145 special-display-regexps special-display-buffer-names |
146 (window (display-buffer buffer))) | |
147 ;; (set-window-dedicated-p window t) | |
148 window)) | |
149 ;; If no window yet, make one in a new frame. | |
150 (let ((frame (make-frame (append args | |
151 (safe-alist-to-plist | |
152 special-display-frame-plist))))) | |
153 (set-window-buffer (frame-selected-window frame) buffer) | |
154 (set-window-dedicated-p (frame-selected-window frame) t) | |
155 (frame-selected-window frame))))))) | |
156 | |
157 ;; XEmacs change: comment out | |
143 ;(defun handle-delete-frame (event) | 158 ;(defun handle-delete-frame (event) |
159 ; "Handle delete-frame events from the X server." | |
144 ; (interactive "e") | 160 ; (interactive "e") |
145 ; (let ((frame (posn-window (event-start event))) | 161 ; (let ((frame (posn-window (event-start event))) |
146 ; (i 0) | 162 ; (i 0) |
147 ; (tail (frame-list))) | 163 ; (tail (frame-list))) |
148 ; (while tail | 164 ; (while tail |
150 ; (not (eq (car tail) frame)) | 166 ; (not (eq (car tail) frame)) |
151 ; (setq i (1+ i))) | 167 ; (setq i (1+ i))) |
152 ; (setq tail (cdr tail))) | 168 ; (setq tail (cdr tail))) |
153 ; (if (> i 0) | 169 ; (if (> i 0) |
154 ; (delete-frame frame t) | 170 ; (delete-frame frame t) |
155 ; (kill-emacs)))) | 171 ; ;; Gildea@x.org says it is ok to ask questions before terminating. |
156 | 172 ; (save-buffers-kill-emacs)))) |
157 | 173 |
158 ;;;; Arrangement of frames at startup | 174 ;;;; Arrangement of frames at startup |
159 | 175 |
160 ;;; 1) Load the window system startup file from the lisp library and read the | 176 ;; 1) Load the window system startup file from the lisp library and read the |
161 ;;; high-priority arguments (-q and the like). The window system startup | 177 ;; high-priority arguments (-q and the like). The window system startup |
162 ;;; file should create any frames specified in the window system defaults. | 178 ;; file should create any frames specified in the window system defaults. |
163 ;;; | 179 ;; |
164 ;;; 2) If no frames have been opened, we open an initial text frame. | 180 ;; 2) If no frames have been opened, we open an initial text frame. |
165 ;;; | 181 ;; |
166 ;;; 3) Once the init file is done, we apply any newly set properties | 182 ;; 3) Once the init file is done, we apply any newly set properties |
167 ;;; in initial-frame-plist to the frame. | 183 ;; in initial-frame-plist to the frame. |
168 | 184 |
169 ;;; If we create the initial frame, this is it. | 185 ;; These are now called explicitly at the proper times, |
186 ;; since that is easier to understand. | |
187 ;; Actually using hooks within Emacs is bad for future maintenance. --rms. | |
188 ;; (add-hook 'before-init-hook 'frame-initialize) | |
189 ;; (add-hook 'window-setup-hook 'frame-notice-user-settings) | |
190 | |
191 ;; If we create the initial frame, this is it. | |
170 (defvar frame-initial-frame nil) | 192 (defvar frame-initial-frame nil) |
171 | 193 |
172 ;; Record the properties used in frame-initialize to make the initial frame. | 194 ;; Record the properties used in frame-initialize to make the initial frame. |
173 (defvar frame-initial-frame-plist) | 195 (defvar frame-initial-frame-plist) |
174 | 196 |
175 (defvar frame-initial-geometry-arguments nil) | 197 (defvar frame-initial-geometry-arguments nil) |
176 | 198 |
199 ;; XEmacs addition | |
177 (defun canonicalize-frame-plists () | 200 (defun canonicalize-frame-plists () |
178 (setq initial-frame-plist (safe-alist-to-plist initial-frame-plist)) | 201 (setq initial-frame-plist (safe-alist-to-plist initial-frame-plist)) |
179 (setq default-frame-plist (safe-alist-to-plist default-frame-plist))) | 202 (setq default-frame-plist (safe-alist-to-plist default-frame-plist))) |
180 | 203 |
181 ;;; startup.el calls this function before loading the user's init | 204 ;; startup.el calls this function before loading the user's init |
182 ;;; file - if there is no frame with a minibuffer open now, create | 205 ;; file - if there is no frame with a minibuffer open now, create |
183 ;;; one to display messages while loading the init file. | 206 ;; one to display messages while loading the init file. |
184 (defun frame-initialize () | 207 (defun frame-initialize () |
208 "Create an initial frame if necessary." | |
185 ;; In batch mode, we actually use the initial terminal device for output. | 209 ;; In batch mode, we actually use the initial terminal device for output. |
210 ;; XEmacs addition | |
186 (canonicalize-frame-plists) | 211 (canonicalize-frame-plists) |
212 | |
187 (if (not (noninteractive)) | 213 (if (not (noninteractive)) |
188 (progn | 214 (progn |
189 ;; Don't call select-frame here - focus is a matter of WM policy. | 215 ;; Turn on special-display processing only if there's a window system. |
216 (setq special-display-function 'special-display-popup-frame) | |
190 | 217 |
191 ;; If there is no frame with a minibuffer besides the terminal | 218 ;; If there is no frame with a minibuffer besides the terminal |
192 ;; frame, then we need to create the opening frame. Make sure | 219 ;; frame, then we need to create the opening frame. Make sure |
193 ;; it has a minibuffer, but let initial-frame-plist omit the | 220 ;; it has a minibuffer, but let initial-frame-plist omit the |
194 ;; minibuffer spec. | 221 ;; minibuffer spec. |
195 (or (delq terminal-frame (minibuffer-frame-list)) | 222 (or (delq terminal-frame (minibuffer-frame-list)) |
196 (progn | 223 (progn |
197 (setq frame-initial-frame-plist | 224 (setq frame-initial-frame-plist |
198 (append initial-frame-plist default-frame-plist)) | 225 (append initial-frame-plist default-frame-plist)) |
199 ;; FSFmacs has scroll-bar junk here that we don't need. | 226 ;; XEmacs change: omit the scrollbar settings |
227 ; (or (assq 'horizontal-scroll-bars frame-initial-frame-alist) | |
228 ; (setq frame-initial-frame-alist | |
229 ; (cons '(horizontal-scroll-bars . t) | |
230 ; frame-initial-frame-alist))) | |
200 (setq default-minibuffer-frame | 231 (setq default-minibuffer-frame |
201 (setq frame-initial-frame | 232 (setq frame-initial-frame |
202 (make-frame initial-frame-plist | 233 (make-frame initial-frame-plist |
203 (car (delq terminal-device | 234 (car (delq terminal-device |
204 (device-list)))))) | 235 (device-list)))))) |
207 ;; It would be wrong to reapply them then, | 238 ;; It would be wrong to reapply them then, |
208 ;; because that would override explicit user resizing. | 239 ;; because that would override explicit user resizing. |
209 (setq initial-frame-plist | 240 (setq initial-frame-plist |
210 (frame-remove-geometry-props initial-frame-plist)))) | 241 (frame-remove-geometry-props initial-frame-plist)))) |
211 ;; At this point, we know that we have a frame open, so we | 242 ;; At this point, we know that we have a frame open, so we |
212 ;; can delete the terminal device. | 243 ;; can delete the terminal frame. |
213 ;; (delete-device terminal-device) | 244 ;; XEmacs change: Do it the same way Fkill_emacs does it. -slb |
214 ;; Do it the same way Fkill_emacs does it. -slb | |
215 (delete-console terminal-console) | 245 (delete-console terminal-console) |
216 (setq terminal-frame nil) | 246 (setq terminal-frame nil)) |
217 | 247 |
218 ;; FSFmacs sets frame-creation-function here, but no need. | 248 ;; XEmacs change: omit the pc window-system stuff. |
219 ))) | 249 ; ;; No, we're not running a window system. Use make-terminal-frame if |
220 | 250 ; ;; we support that feature, otherwise arrange to cause errors. |
221 ;;; startup.el calls this function after loading the user's init | 251 ; (or (eq window-system 'pc) |
222 ;;; file. Now default-frame-plist and initial-frame-plist contain | 252 ; (setq frame-creation-function |
223 ;;; information to which we must react; do what needs to be done. | 253 ; (if (fboundp 'tty-create-frame-with-faces) |
254 ; 'tty-create-frame-with-faces | |
255 ; (function | |
256 ; (lambda (parameters) | |
257 ; (error | |
258 ; "Can't create multiple frames without a window system")))))) | |
259 )) | |
260 | |
261 (defvar frame-notice-user-settings t | |
262 "Non-nil means function `frame-notice-user-settings' wasn't run yet.") | |
263 | |
264 ;; startup.el calls this function after loading the user's init | |
265 ;; file. Now default-frame-plist and initial-frame-plist contain | |
266 ;; information to which we must react; do what needs to be done. | |
224 (defun frame-notice-user-settings () | 267 (defun frame-notice-user-settings () |
225 | 268 "Act on user's init file settings of frame parameters. |
226 ;; FSFmacs has menu-bar junk here that we don't need. | 269 React to settings of `default-frame-plist', `initial-frame-plist' there." |
227 | 270 ;; XEmacs addition |
228 (canonicalize-frame-plists) | 271 (canonicalize-frame-plists) |
272 | |
273 ;; XEmacs change: omit menu-bar manipulations. | |
274 ; ;; Make menu-bar-mode and default-frame-alist consistent. | |
275 ; (when (boundp 'menu-bar-mode) | |
276 ; (let ((default (assq 'menu-bar-lines default-frame-alist))) | |
277 ; (if default | |
278 ; (setq menu-bar-mode (not (eq (cdr default) 0))) | |
279 ; (setq default-frame-alist | |
280 ; (cons (cons 'menu-bar-lines (if menu-bar-mode 1 0)) | |
281 ; default-frame-alist))))) | |
282 | |
283 ;; XEmacs change: omit tool-bar manipulations. | |
284 ; ;; Make tool-bar-mode and default-frame-alist consistent. Don't do | |
285 ; ;; it in batch mode since that would leave a tool-bar-lines | |
286 ; ;; parameter in default-frame-alist in a dumped Emacs, which is not | |
287 ; ;; what we want. | |
288 ; (when (and (boundp 'tool-bar-mode) | |
289 ; (not noninteractive)) | |
290 ; (let ((default (assq 'tool-bar-lines default-frame-alist))) | |
291 ; (if default | |
292 ; (setq tool-bar-mode (not (eq (cdr default) 0))) | |
293 ; (setq default-frame-alist | |
294 ; (cons (cons 'tool-bar-lines (if tool-bar-mode 1 0)) | |
295 ; default-frame-alist))))) | |
229 | 296 |
230 ;; Creating and deleting frames may shift the selected frame around, | 297 ;; Creating and deleting frames may shift the selected frame around, |
231 ;; and thus the current buffer. Protect against that. We don't | 298 ;; and thus the current buffer. Protect against that. We don't |
232 ;; want to use save-excursion here, because that may also try to set | 299 ;; want to use save-excursion here, because that may also try to set |
233 ;; the buffer of the selected window, which fails when the selected | 300 ;; the buffer of the selected window, which fails when the selected |
234 ;; window is the minibuffer. | 301 ;; window is the minibuffer. |
235 (let ((old-buffer (current-buffer))) | 302 (let ((old-buffer (current-buffer))) |
236 | 303 |
304 ;; XEmacs change: omit special handling for MS-DOS | |
305 ; (when (and frame-notice-user-settings | |
306 ; (null frame-initial-frame)) | |
307 ; ;; This case happens when we don't have a window system, and | |
308 ; ;; also for MS-DOS frames. | |
309 ; (let ((parms (frame-parameters frame-initial-frame))) | |
310 ; ;; Don't change the frame names. | |
311 ; (setq parms (delq (assq 'name parms) parms)) | |
312 ; ;; Can't modify the minibuffer parameter, so don't try. | |
313 ; (setq parms (delq (assq 'minibuffer parms) parms)) | |
314 ; (modify-frame-parameters nil | |
315 ; (if (null window-system) | |
316 ; (append initial-frame-alist | |
317 ; default-frame-alist | |
318 ; parms | |
319 ; nil) | |
320 ; ;; initial-frame-alist and | |
321 ; ;; default-frame-alist were already | |
322 ; ;; applied in pc-win.el. | |
323 ; parms)) | |
324 ; (if (null window-system) ;; MS-DOS does this differently in pc-win.el | |
325 ; (let ((newparms (frame-parameters)) | |
326 ; (frame (selected-frame))) | |
327 ; (tty-handle-reverse-video frame newparms) | |
328 ; ;; If we changed the background color, we need to update | |
329 ; ;; the background-mode parameter, and maybe some faces, | |
330 ; ;; too. | |
331 ; (when (assq 'background-color newparms) | |
332 ; (unless (or (assq 'background-mode initial-frame-alist) | |
333 ; (assq 'background-mode default-frame-alist)) | |
334 ; (frame-set-background-mode frame)) | |
335 ; (face-set-after-frame-default frame)))))) | |
336 | |
237 ;; If the initial frame is still around, apply initial-frame-plist | 337 ;; If the initial frame is still around, apply initial-frame-plist |
238 ;; and default-frame-plist to it. | 338 ;; and default-frame-plist to it. |
239 (if (frame-live-p frame-initial-frame) | 339 (when (frame-live-p frame-initial-frame) |
340 | |
341 ;; XEmacs change: omit the tool-bar manipulations | |
342 ; ;; When tool-bar has been switched off, correct the frame size | |
343 ; ;; by the lines added in x-create-frame for the tool-bar and | |
344 ; ;; switch `tool-bar-mode' off. | |
345 ; (when (display-graphic-p) | |
346 ; (let ((tool-bar-lines (or (assq 'tool-bar-lines initial-frame-alist) | |
347 ; (assq 'tool-bar-lines default-frame-alist)))) | |
348 ; (when (and tool-bar-originally-present | |
349 ; (or (null tool-bar-lines) | |
350 ; (null (cdr tool-bar-lines)) | |
351 ; (eq 0 (cdr tool-bar-lines)))) | |
352 ; (let* ((char-height (frame-char-height frame-initial-frame)) | |
353 ; (image-height tool-bar-images-pixel-height) | |
354 ; (margin (cond ((and (consp tool-bar-button-margin) | |
355 ; (integerp (cdr tool-bar-button-margin)) | |
356 ; (> tool-bar-button-margin 0)) | |
357 ; (cdr tool-bar-button-margin)) | |
358 ; ((and (integerp tool-bar-button-margin) | |
359 ; (> tool-bar-button-margin 0)) | |
360 ; tool-bar-button-margin) | |
361 ; (t 0))) | |
362 ; (relief (if (and (integerp tool-bar-button-relief) | |
363 ; (> tool-bar-button-relief 0)) | |
364 ; tool-bar-button-relief 3)) | |
365 ; (lines (/ (+ image-height | |
366 ; (* 2 margin) | |
367 ; (* 2 relief) | |
368 ; (1- char-height)) | |
369 ; char-height)) | |
370 ; (height (frame-parameter frame-initial-frame 'height)) | |
371 ; (newparms (list (cons 'height (- height lines)))) | |
372 ; (initial-top (cdr (assq 'top | |
373 ; frame-initial-geometry-arguments))) | |
374 ; (top (frame-parameter frame-initial-frame 'top))) | |
375 ; (when (and (consp initial-top) (eq '- (car initial-top))) | |
376 ; (let ((adjusted-top | |
377 ; (cond ((and (consp top) | |
378 ; (eq '+ (car top))) | |
379 ; (list '+ | |
380 ; (+ (cadr top) | |
381 ; (* lines char-height)))) | |
382 ; ((and (consp top) | |
383 ; (eq '- (car top))) | |
384 ; (list '- | |
385 ; (- (cadr top) | |
386 ; (* lines char-height)))) | |
387 ; (t (+ top (* lines char-height)))))) | |
388 ; (setq newparms | |
389 ; (append newparms | |
390 ; `((top . ,adjusted-top)) | |
391 ; nil)))) | |
392 ; (modify-frame-parameters frame-initial-frame newparms) | |
393 ; (tool-bar-mode -1))))) | |
240 | 394 |
241 ;; The initial frame we create above always has a minibuffer. | 395 ;; The initial frame we create above always has a minibuffer. |
242 ;; If the user wants to remove it, or make it a minibuffer-only | 396 ;; If the user wants to remove it, or make it a minibuffer-only |
243 ;; frame, then we'll have to delete the selected frame and make a | 397 ;; frame, then we'll have to delete the selected frame and make a |
244 ;; new one; you can't remove or add a root window to/from an | 398 ;; new one; you can't remove or add a root window to/from an |
259 (list (lax-plist-get default-frame-plist | 413 (list (lax-plist-get default-frame-plist |
260 'minibuffer))) | 414 'minibuffer))) |
261 '(t))) | 415 '(t))) |
262 t)) | 416 t)) |
263 ;; Create the new frame. | 417 ;; Create the new frame. |
264 (let (props | 418 (let (props new) |
265 ) | |
266 ;; If the frame isn't visible yet, wait till it is. | 419 ;; If the frame isn't visible yet, wait till it is. |
267 ;; If the user has to position the window, | 420 ;; If the user has to position the window, |
268 ;; Emacs doesn't know its real position until | 421 ;; Emacs doesn't know its real position until |
269 ;; the frame is seen to be visible. | 422 ;; the frame is seen to be visible. |
270 | 423 |
424 ;; XEmacs change: check the initially-unmapped property | |
271 (if (frame-property frame-initial-frame 'initially-unmapped) | 425 (if (frame-property frame-initial-frame 'initially-unmapped) |
272 nil | 426 nil |
273 (while (not (frame-visible-p frame-initial-frame)) | 427 (while (not (frame-visible-p frame-initial-frame)) |
274 (sleep-for 1))) | 428 (sleep-for 1))) |
275 (setq props (frame-properties frame-initial-frame)) | 429 (setq props (frame-properties frame-initial-frame)) |
430 | |
276 ;; Get rid of `name' unless it was specified explicitly before. | 431 ;; Get rid of `name' unless it was specified explicitly before. |
277 (or (lax-plist-member frame-initial-frame-plist 'name) | 432 (or (lax-plist-member frame-initial-frame-plist 'name) |
278 (setq props (lax-plist-remprop props 'name))) | 433 (setq props (lax-plist-remprop props 'name))) |
279 (setq props (append initial-frame-plist default-frame-plist | 434 |
435 (setq props (append initial-frame-plist | |
436 default-frame-plist | |
280 props | 437 props |
281 nil)) | 438 nil)) |
439 | |
282 ;; Get rid of `reverse', because that was handled | 440 ;; Get rid of `reverse', because that was handled |
283 ;; when we first made the frame. | 441 ;; when we first made the frame. |
284 (laxputf props 'reverse nil) | 442 (laxputf props 'reverse nil) |
285 ;; Get rid of `window-id', otherwise make-frame will | 443 |
286 ;; think we're trying to setup an external widget. | 444 ;; XEmacs addition: Get rid of `window-id', otherwise make-frame |
445 ;; will think we're trying to setup an external widget. | |
287 (laxremf props 'window-id) | 446 (laxremf props 'window-id) |
447 | |
288 (if (lax-plist-member frame-initial-geometry-arguments 'height) | 448 (if (lax-plist-member frame-initial-geometry-arguments 'height) |
289 (laxremf props 'height)) | 449 (laxremf props 'height)) |
290 (if (lax-plist-member frame-initial-geometry-arguments 'width) | 450 (if (lax-plist-member frame-initial-geometry-arguments 'width) |
291 (laxremf props 'width)) | 451 (laxremf props 'width)) |
292 (if (lax-plist-member frame-initial-geometry-arguments 'left) | 452 (if (lax-plist-member frame-initial-geometry-arguments 'left) |
293 (laxremf props 'left)) | 453 (laxremf props 'left)) |
294 (if (lax-plist-member frame-initial-geometry-arguments 'top) | 454 (if (lax-plist-member frame-initial-geometry-arguments 'top) |
295 (laxremf props 'top)) | 455 (laxremf props 'top)) |
296 | |
297 ;; Now create the replacement initial frame. | 456 ;; Now create the replacement initial frame. |
298 (make-frame | 457 (setq new |
299 ;; Use the geometry args that created the existing | 458 (make-frame |
300 ;; frame, rather than the props we get for it. | 459 ;; Use the geometry args that created the existing |
301 (append '(user-size t user-position t) | 460 ;; frame, rather than the props we get for it. |
302 frame-initial-geometry-arguments | 461 (append '(user-size t user-position t) |
303 props)) | 462 frame-initial-geometry-arguments |
463 props))) | |
304 ;; The initial frame, which we are about to delete, may be | 464 ;; The initial frame, which we are about to delete, may be |
305 ;; the only frame with a minibuffer. If it is, create a | 465 ;; the only frame with a minibuffer. If it is, create a |
306 ;; new one. | 466 ;; new one. |
307 (or (delq frame-initial-frame (minibuffer-frame-list)) | 467 (or (delq frame-initial-frame (minibuffer-frame-list)) |
308 (make-initial-minibuffer-frame nil)) | 468 (make-initial-minibuffer-frame nil)) |
336 (setq default-minibuffer-frame new-surrogate)) | 496 (setq default-minibuffer-frame new-surrogate)) |
337 | 497 |
338 ;; Wean the frames using frame-initial-frame as | 498 ;; Wean the frames using frame-initial-frame as |
339 ;; their minibuffer frame. | 499 ;; their minibuffer frame. |
340 (mapcar | 500 (mapcar |
341 #' | 501 #'(lambda (frame) |
342 (lambda (frame) | 502 (set-frame-property frame 'minibuffer |
343 (set-frame-property frame 'minibuffer | 503 new-minibuffer)) |
344 new-minibuffer)) | 504 users-of-initial)))) |
345 users-of-initial)))) | |
346 | 505 |
347 ;; Redirect events enqueued at this frame to the new frame. | 506 ;; Redirect events enqueued at this frame to the new frame. |
348 ;; Is this a good idea? | 507 ;; Is this a good idea? |
349 ;; Probably not, since this whole redirect-frame-focus | 508 ;; Probably not, since this whole redirect-frame-focus |
350 ;; stuff is a load of trash, and so is this function we're in. | 509 ;; stuff is a load of trash, and so is this function we're in. |
382 (setq newval (lax-plist-get allprops (car tail))) | 541 (setq newval (lax-plist-get allprops (car tail))) |
383 (or (eq oldval newval) | 542 (or (eq oldval newval) |
384 (laxputf newprops (car tail) newval))) | 543 (laxputf newprops (car tail) newval))) |
385 (setq tail (cddr tail))) | 544 (setq tail (cddr tail))) |
386 (set-frame-properties frame-initial-frame newprops) | 545 (set-frame-properties frame-initial-frame newprops) |
387 ;silly FSFmacs junk | 546 ;; XEmacs change: omit the background manipulation |
388 ;if (lax-plist-member newprops 'font) | 547 ; ;; If we changed the background color, |
389 ; (frame-update-faces frame-initial-frame)) | 548 ; ;; we need to update the background-mode parameter |
390 | 549 ; ;; and maybe some faces too. |
550 ; (when (assq 'background-color newparms) | |
551 ; (unless (assq 'background-mode newparms) | |
552 ; (frame-set-background-mode frame-initial-frame)) | |
553 ; (face-set-after-frame-default frame-initial-frame))))) | |
391 ))) | 554 ))) |
392 | 555 |
393 ;; Restore the original buffer. | 556 ;; Restore the original buffer. |
394 (set-buffer old-buffer) | 557 (set-buffer old-buffer) |
395 | 558 |
396 ;; Make sure the initial frame can be GC'd if it is ever deleted. | 559 ;; Make sure the initial frame can be GC'd if it is ever deleted. |
397 ;; Make sure frame-notice-user-settings does nothing if called twice. | 560 ;; Make sure frame-notice-user-settings does nothing if called twice. |
561 (setq frame-notice-user-settings nil) | |
398 (setq frame-initial-frame nil))) | 562 (setq frame-initial-frame nil))) |
399 | 563 |
400 (defun make-initial-minibuffer-frame (device) | 564 (defun make-initial-minibuffer-frame (device) |
401 (let ((props (append '(minibuffer only) | 565 (let ((props (append '(minibuffer only) |
402 (safe-alist-to-plist minibuffer-frame-plist)))) | 566 (safe-alist-to-plist minibuffer-frame-plist)))) |
403 (make-frame props device))) | 567 (make-frame props device))) |
404 | 568 |
405 | 569 |
406 ;;;; Creation of additional frames, and other frame miscellanea | 570 ;;;; Creation of additional frames, and other frame miscellanea |
407 | 571 |
572 (defun modify-all-frames-properties (plist) | |
573 "Modify all current and future frames' parameters according to PLIST. | |
574 This changes `default-frame-plist' and possibly `initial-frame-plist'. | |
575 See `set-frame-properties' for more information." | |
576 (dolist (frame (frame-list)) | |
577 (set-frame-properties frame plist)) | |
578 | |
579 ;; XEmacs change: iterate over plists instead of alists | |
580 (map-plist | |
581 #'(lambda (prop val) | |
582 ;; initial-frame-plist needs setting only when | |
583 ;; frame-notice-user-settings is true | |
584 (and frame-notice-user-settings | |
585 (lax-plist-remprop initial-frame-plist prop)) | |
586 (lax-plist-remprop default-frame-plist prop)) | |
587 plist) | |
588 | |
589 (and frame-notice-user-settings | |
590 (setq initial-frame-plist (append initial-frame-plist plist))) | |
591 (setq default-frame-plist (append default-frame-plist plist))) | |
592 | |
408 (defun get-other-frame () | 593 (defun get-other-frame () |
409 "Return some frame other than the selected frame, creating one if necessary." | 594 "Return some frame other than the current frame. |
595 Create one if necessary. Note that the minibuffer frame, if separate, | |
596 is not considered (see `next-frame')." | |
410 (let* ((this (selected-frame)) | 597 (let* ((this (selected-frame)) |
411 ;; search visible frames first | 598 ;; search visible frames first |
412 (next (next-frame this 'visible-nomini))) | 599 (next (next-frame this 'visible-nomini))) |
413 ;; then search iconified frames | 600 ;; then search iconified frames |
414 (if (eq this next) | 601 (if (eq this next) |
421 (defun next-multiframe-window () | 608 (defun next-multiframe-window () |
422 "Select the next window, regardless of which frame it is on." | 609 "Select the next window, regardless of which frame it is on." |
423 (interactive) | 610 (interactive) |
424 (select-window (next-window (selected-window) | 611 (select-window (next-window (selected-window) |
425 (> (minibuffer-depth) 0) | 612 (> (minibuffer-depth) 0) |
426 t))) | 613 t)) |
614 ;; XEmacs change: select-window already selects the containing frame | |
615 ;(select-frame-set-input-focus (selected-frame)) | |
616 ) | |
427 | 617 |
428 (defun previous-multiframe-window () | 618 (defun previous-multiframe-window () |
429 "Select the previous window, regardless of which frame it is on." | 619 "Select the previous window, regardless of which frame it is on." |
430 (interactive) | 620 (interactive) |
431 (select-window (previous-window (selected-window) | 621 (select-window (previous-window (selected-window) |
432 (> (minibuffer-depth) 0) | 622 (> (minibuffer-depth) 0) |
433 t))) | 623 t)) |
434 | 624 ;; XEmacs change: select-window already selects the containing frame |
625 ;(select-frame-set-input-focus (selected-frame)) | |
626 ) | |
627 | |
628 ;; XEmacs change: Emacs has make-frame-on-display | |
435 (defun make-frame-on-device (type connection &optional props) | 629 (defun make-frame-on-device (type connection &optional props) |
436 "Create a frame of type TYPE on CONNECTION. | 630 "Create a frame of type TYPE on CONNECTION. |
437 TYPE should be a symbol naming the device type, i.e. one of | 631 TYPE should be a symbol naming the device type, i.e. one of |
438 | 632 |
439 x An X display. CONNECTION should be a standard display string | 633 x An X display. CONNECTION should be a standard display string |
456 | 650 |
457 If a connection to CONNECTION already exists, it is reused; otherwise, | 651 If a connection to CONNECTION already exists, it is reused; otherwise, |
458 a new connection is opened." | 652 a new connection is opened." |
459 (make-frame props (make-device type connection props))) | 653 (make-frame props (make-device type connection props))) |
460 | 654 |
655 ;; XEmacs omission: Emacs has make-frame-command here, but it reduces to | |
656 ;; make-frame for us. | |
657 | |
658 ;; XEmacs omission: the following 2 variables are not yet implemented. | |
659 ;(defvar before-make-frame-hook nil | |
660 ; "Functions to run before a frame is created.") | |
661 ; | |
662 ;(defvar after-make-frame-functions nil | |
663 ; "Functions to run after a frame is created. | |
664 ;The functions are run with one arg, the newly created frame.") | |
665 ; | |
666 (defvar after-setting-font-hook nil | |
667 "Functions to run after a frame's font has been changed.") | |
668 | |
461 ;; Alias, kept temporarily. | 669 ;; Alias, kept temporarily. |
462 (defalias 'new-frame 'make-frame) | 670 (defalias 'new-frame 'make-frame) |
463 | 671 (make-obsolete 'new-frame 'make-frame) |
464 ; FSFmacs has make-frame here. We have it in C, so no need for | 672 |
465 ; frame-creation-function. | 673 ;; XEmacs change: Emacs has make-frame here. We have it in C, so no need for |
466 | 674 ;; frame-creation-function. |
675 | |
676 ;; XEmacs addition: support optional DEVICE argument. | |
467 (defun filtered-frame-list (predicate &optional device) | 677 (defun filtered-frame-list (predicate &optional device) |
468 "Return a list of all live frames which satisfy PREDICATE. | 678 "Return a list of all live frames which satisfy PREDICATE. |
469 If optional second arg DEVICE is non-nil, restrict the frames | 679 If optional second arg DEVICE is non-nil, restrict the frames |
470 returned to that device." | 680 returned to that device." |
471 (let ((frames (if device (device-frame-list device) | 681 (let ((frames (if device (device-frame-list device) |
475 (if (funcall predicate (car frames)) | 685 (if (funcall predicate (car frames)) |
476 (setq good-frames (cons (car frames) good-frames))) | 686 (setq good-frames (cons (car frames) good-frames))) |
477 (setq frames (cdr frames))) | 687 (setq frames (cdr frames))) |
478 good-frames)) | 688 good-frames)) |
479 | 689 |
690 ;; XEmacs addition: support optional DEVICE argument. | |
480 (defun minibuffer-frame-list (&optional device) | 691 (defun minibuffer-frame-list (&optional device) |
481 "Return a list of all frames with their own minibuffers. | 692 "Return a list of all frames with their own minibuffers. |
482 If optional second arg DEVICE is non-nil, restrict the frames | 693 If optional second arg DEVICE is non-nil, restrict the frames |
483 returned to that device." | 694 returned to that device." |
484 (filtered-frame-list | 695 (filtered-frame-list |
485 #'(lambda (frame) | 696 #'(lambda (frame) |
486 (eq frame (window-frame (minibuffer-window frame)))) | 697 (eq frame (window-frame (minibuffer-window frame)))) |
487 device)) | 698 device)) |
488 | 699 |
700 ;; XEmacs omission: Emacs has frames-on-display-list here, but that is | |
701 ;; essentially equivalent to supplying the optional DEVICE argument to | |
702 ;; filtered-frame-list. | |
703 | |
704 ;; XEmacs addition: the following two functions make life a lot simpler below. | |
705 (defsubst display-frame (display) | |
706 "Return the active frame for DISPLAY. | |
707 DISPLAY may be a frame, a device, or a console. If it is omitted or nil, | |
708 it defaults to the selected frame." | |
709 (cond | |
710 ((null display) (selected-frame)) | |
711 ((framep display) display) | |
712 ((devicep display) (selected-frame display)) | |
713 ((consolep display) (selected-frame (car (console-device-list display)))) | |
714 (t (error 'wrong-type-argument "Not a frame, device, or console" display)))) | |
715 | |
716 (defsubst display-device (display) | |
717 "Return the device for DISPLAY. | |
718 DISPLAY may be a frame, a device, or a console. If it is omitted or nil, | |
719 it defaults to the selected frame." | |
720 (cond | |
721 ((null display) (selected-device)) | |
722 ((framep display) (frame-device display)) | |
723 ((devicep display) display) | |
724 ((consolep display) (car (console-device-list display))) | |
725 (t (error 'wrong-type-argument "Not a frame, device, or console" display)))) | |
726 | |
727 ;; Emacs compatibility function. We do not allow display names of the type | |
728 ;; HOST:SERVER.SCREEN as Emacs does, but we do handle devices and consoles. | |
729 (defun framep-on-display (&optional display) | |
730 "Return the type of frames on DISPLAY. | |
731 DISPLAY may be a frame, a device, or a console. If it is a frame, its type | |
732 is returned. If DISPLAY is omitted or nil, it defaults to the selected | |
733 frame. All frames on a given device or console are of the same type." | |
734 (cond | |
735 ((null display) (frame-type (selected-frame))) | |
736 ((framep display) (frame-type display)) | |
737 ((devicep display) (device-type display)) | |
738 ((consolep display) (console-type display)) | |
739 (t (error 'wrong-type-argument "Not a frame, device, or console" display)))) | |
740 | |
741 ;; XEmacs addition: Emacs does not have this function. | |
489 (defun frame-minibuffer-only-p (frame) | 742 (defun frame-minibuffer-only-p (frame) |
490 "Return non-nil if FRAME is a minibuffer-only frame." | 743 "Return non-nil if FRAME is a minibuffer-only frame." |
491 (eq (frame-root-window frame) (minibuffer-window frame))) | 744 (eq (frame-root-window frame) (minibuffer-window frame))) |
492 | 745 |
493 (defun frame-remove-geometry-props (plist) | 746 (defun frame-remove-geometry-props (plist) |
506 frame-initial-geometry-arguments))) | 759 frame-initial-geometry-arguments))) |
507 (setq plist (lax-plist-remprop plist property))))) | 760 (setq plist (lax-plist-remprop plist property))))) |
508 '(height width top left user-size user-position)) | 761 '(height width top left user-size user-position)) |
509 plist) | 762 plist) |
510 | 763 |
764 ;; XEmacs change: Emacs has focus-follows-mouse here, which lets them | |
765 ;; Customize it. XEmacs has it builtin. Should that change? | |
766 | |
767 ;; XEmacs change: we have focus-frame instead of multiple foo-focus-frame | |
768 ;; functions. | |
769 (defun select-frame-set-input-focus (frame) | |
770 "Select FRAME, raise it, and set input focus, if possible." | |
771 (raise-frame frame) | |
772 (focus-frame frame) ;; This also selects FRAME | |
773 ;; XEmacs change: This is a bad idea; you should in general never warp the | |
774 ;; pointer unless the user asks for it. | |
775 ;;(if focus-follows-mouse | |
776 ;; (set-mouse-position (selected-window) (1- (frame-width frame)) 0))) | |
777 ) | |
778 | |
511 (defun other-frame (arg) | 779 (defun other-frame (arg) |
512 "Select the ARG'th different visible frame, and raise it. | 780 "Select the ARG'th different visible frame, and raise it. |
513 All frames are arranged in a cyclic order. | 781 All frames are arranged in a cyclic order. |
514 This command selects the frame ARG steps away in that order. | 782 This command selects the frame ARG steps away in that order. |
515 A negative ARG moves in the opposite order. | 783 A negative ARG moves in the opposite order. |
516 | 784 |
517 This sets the window system focus, regardless of the value | 785 To make this command work properly, you must tell Emacs |
518 of `focus-follows-mouse'." | 786 how the system (or the window manager) generally handles |
787 focus-switching between windows. If moving the mouse onto a window | |
788 selects it (gives it focus), set `focus-follows-mouse' to t. | |
789 Otherwise, that variable should be nil." | |
519 (interactive "p") | 790 (interactive "p") |
520 (let ((frame (selected-frame))) | 791 (let ((frame (selected-frame))) |
521 (while (> arg 0) | 792 (while (> arg 0) |
522 (setq frame (next-frame frame 'visible-nomini)) | 793 (setq frame (next-frame frame 'visible-nomini)) |
794 (while (not (eq (frame-visible-p frame) t)) | |
795 (setq frame (next-frame frame 'visible-nomini))) | |
523 (setq arg (1- arg))) | 796 (setq arg (1- arg))) |
524 (while (< arg 0) | 797 (while (< arg 0) |
525 (setq frame (previous-frame frame 'visible-nomini)) | 798 (setq frame (previous-frame frame 'visible-nomini)) |
799 (while (not (eq (frame-visible-p frame) t)) | |
800 (setq frame (previous-frame frame 'visible-nomini))) | |
526 (setq arg (1+ arg))) | 801 (setq arg (1+ arg))) |
527 (raise-frame frame) | 802 (select-frame-set-input-focus frame))) |
528 (focus-frame frame) | 803 |
529 ;this is a bad idea; you should in general never warp the | 804 (defun iconify-or-deiconify-frame () |
530 ;pointer unless the user asks for this. Furthermore, | 805 "Iconify the selected frame, or deiconify if it's currently an icon." |
531 ;our version of `set-mouse-position' takes a window, | 806 (interactive) |
532 ;not a frame. | 807 (if (lax-plist-get (frame-properties) 'visibility) |
533 ;(set-mouse-position (selected-frame) (1- (frame-width)) 0) | 808 (iconify-frame) |
534 ;some weird FSFmacs randomness | 809 (make-frame-visible))) |
535 ;(if (fboundp 'unfocus-frame) | 810 |
536 ; (unfocus-frame)))) | 811 (defun make-frame-names-alist () |
537 )) | 812 (let* ((current-frame (selected-frame)) |
813 (falist | |
814 (cons | |
815 (cons (frame-property current-frame 'name) current-frame) nil)) | |
816 (frame (next-frame current-frame t))) | |
817 (while (not (eq frame current-frame)) | |
818 (progn | |
819 (setq falist (cons (cons (frame-property frame 'name) frame) falist)) | |
820 (setq frame (next-frame frame t)))) | |
821 falist)) | |
822 | |
823 (defvar frame-name-history nil) | |
824 (defun select-frame-by-name (name) | |
825 "Select the frame on the current terminal whose name is NAME and raise it. | |
826 If there is no frame by that name, signal an error." | |
827 (interactive | |
828 (let* ((frame-names-alist (make-frame-names-alist)) | |
829 (default (car (car frame-names-alist))) | |
830 (input (completing-read | |
831 (format "Select Frame (default %s): " default) | |
832 frame-names-alist nil t nil 'frame-name-history default))) | |
833 ;; XEmacs change: use the last param of completing-read to simplify. | |
834 (list input))) | |
835 (let* ((frame-names-alist (make-frame-names-alist)) | |
836 (frame (cdr (assoc name frame-names-alist)))) | |
837 (or frame | |
838 (error "There is no frame named `%s'" name)) | |
839 (make-frame-visible frame) | |
840 ;; XEmacs change: make-frame-visible implies (raise-frame) | |
841 ;; (raise-frame frame) | |
842 ;; XEmacs change: we defined this function, might as well use it. | |
843 (select-frame-set-input-focus frame))) | |
538 | 844 |
539 ;; XEmacs-added utility functions | 845 ;; XEmacs-added utility functions |
540 | 846 |
541 (defmacro save-selected-frame (&rest body) | 847 (defmacro save-selected-frame (&rest body) |
542 "Execute forms in BODY, then restore the selected frame. | 848 "Execute forms in BODY, then restore the selected frame. |
552 The value returned is the value of the last form in BODY." | 858 The value returned is the value of the last form in BODY." |
553 `(save-selected-frame | 859 `(save-selected-frame |
554 (select-frame ,frame) | 860 (select-frame ,frame) |
555 ,@body)) | 861 ,@body)) |
556 | 862 |
557 ; this is in C in FSFmacs | 863 ; This is in C in Emacs |
558 (defun frame-list () | 864 (defun frame-list () |
559 "Return a list of all frames on all devices/consoles." | 865 "Return a list of all frames on all devices/consoles." |
560 ;; Lists are copies, so nconc is safe here. | 866 ;; Lists are copies, so nconc is safe here. |
561 (apply 'nconc (mapcar 'device-frame-list (device-list)))) | 867 (apply 'nconc (mapcar 'device-frame-list (device-list)))) |
562 | 868 |
621 listed in CONFIGURATION. But if optional second argument NODELETE | 927 listed in CONFIGURATION. But if optional second argument NODELETE |
622 is given and non-nil, the unwanted frames are iconified instead." | 928 is given and non-nil, the unwanted frames are iconified instead." |
623 (or (frame-configuration-p configuration) | 929 (or (frame-configuration-p configuration) |
624 (signal 'wrong-type-argument | 930 (signal 'wrong-type-argument |
625 (list 'frame-configuration-p configuration))) | 931 (list 'frame-configuration-p configuration))) |
626 (let ((config-plist (cdr configuration)) | 932 (let ((config-alist (cdr configuration)) |
627 frames-to-delete) | 933 frames-to-delete) |
628 (mapc (lambda (frame) | 934 (mapc #'(lambda (frame) |
629 (let ((properties (assq frame config-plist))) | 935 (let ((properties (assq frame config-alist))) |
630 (if properties | 936 (if properties |
631 (progn | 937 (progn |
632 (set-frame-properties | 938 (set-frame-properties |
633 frame | 939 frame |
634 ;; Since we can't set a frame's minibuffer status, | 940 ;; Since we can't set a frame's minibuffer status, |
635 ;; we might as well omit the parameter altogether. | 941 ;; we might as well omit the parameter altogether. |
636 (lax-plist-remprop (nth 1 properties) 'minibuffer)) | 942 (lax-plist-remprop (nth 1 properties) 'minibuffer)) |
637 (set-window-configuration (nth 2 properties))) | 943 (set-window-configuration (nth 2 properties))) |
638 (setq frames-to-delete (cons frame frames-to-delete))))) | 944 (setq frames-to-delete (cons frame frames-to-delete))))) |
639 (frame-list)) | 945 (frame-list)) |
640 (if nodelete | 946 (if nodelete |
641 ;; Note: making frames invisible here was tried | 947 ;; Note: making frames invisible here was tried |
642 ;; but led to some strange behavior--each time the frame | 948 ;; but led to some strange behavior--each time the frame |
643 ;; was made visible again, the window manager asked afresh | 949 ;; was made visible again, the window manager asked afresh |
644 ;; for where to put it. | 950 ;; for where to put it. |
645 (mapc 'iconify-frame frames-to-delete) | 951 (mapc #'iconify-frame frames-to-delete) |
646 (mapc 'delete-frame frames-to-delete)))) | 952 (mapc #'delete-frame frames-to-delete)))) |
647 | 953 |
648 ; this function is in subr.el in FSFmacs. | 954 ; XEmacs change: this function is in subr.el in Emacs. |
649 ; that's because they don't always include frame.el, while we do. | 955 ; That's because they don't always include frame.el, while we do. |
650 | 956 |
651 (defun frame-configuration-p (object) | 957 (defun frame-configuration-p (object) |
652 "Return non-nil if OBJECT seems to be a frame configuration. | 958 "Return non-nil if OBJECT seems to be a frame configuration. |
653 Any list whose car is `frame-configuration' is assumed to be a frame | 959 Any list whose car is `frame-configuration' is assumed to be a frame |
654 configuration." | 960 configuration." |
655 (and (consp object) | 961 (and (consp object) |
656 (eq (car object) 'frame-configuration))) | 962 (eq (car object) 'frame-configuration))) |
657 | 963 |
658 | 964 |
659 ;; FSFmacs has functions `frame-width', `frame-height' here. | 965 ;;;; Convenience functions for accessing and interactively changing |
660 ;; We have them in C. | 966 ;;;; frame parameters. |
661 | 967 |
662 ;; FSFmacs has weird functions `set-default-font', `set-background-color', | 968 (defun frame-height (&optional frame) |
663 ;; `set-foreground-color' here. They don't do sensible things like | 969 "Return number of lines available for display on FRAME. |
664 ;; set faces; instead they set frame properties (??!!) and call | 970 If FRAME is omitted, describe the currently selected frame." |
665 ;; useless functions such as `frame-update-faces' and | 971 (frame-property frame 'height)) |
666 ;; `frame-update-face-colors'. | 972 |
667 | 973 (defun frame-width (&optional frame) |
668 ;; FSFmacs has functions `set-cursor-color', `set-mouse-color', and | 974 "Return number of columns available for display on FRAME. |
669 ;; `set-border-color', which refer to frame properties. | 975 If FRAME is omitted, describe the currently selected frame." |
670 ;; #### We need to use specifiers here. | 976 (frame-property frame 'width)) |
671 | 977 |
672 ;(defun auto-raise-mode (arg) | 978 (defalias 'set-default-font 'set-frame-font) |
673 ; "Toggle whether or not the selected frame should auto-raise. | 979 |
674 ;With arg, turn auto-raise mode on if and only if arg is positive. | 980 ;; XEmacs change: this function differs significantly from Emacs. |
675 ;Note that this controls Emacs's own auto-raise feature. | 981 (defun set-frame-font (font-name &optional keep-size) |
676 ;Some window managers allow you to enable auto-raise for certain windows. | 982 "Set the font of the selected frame to FONT-NAME. |
677 ;You can use that for Emacs windows if you wish, but if you do, | 983 When called interactively, prompt for the name of the font to use. |
678 ;that is beyond the control of Emacs and this command has no effect on it." | 984 To get the frame's current default font, use `(face-font-name 'default)'. |
679 ; (interactive "P") | 985 |
680 ; (if (null arg) | 986 The default behavior is to keep the numbers of lines and columns in |
681 ; (setq arg | 987 the frame, thus may change its pixel size. If optional KEEP-SIZE is |
682 ; (if (frame-property (selected-frame) 'auto-raise) | 988 non-nil (interactively, prefix argument) the current frame size (in |
683 ; -1 1))) | 989 pixels) is kept by adjusting the numbers of the lines and columns." |
684 ; (set-frame-property (selected-frame) 'auto-raise (> arg 0))) | 990 (interactive |
685 | 991 (let* ((frame (selected-frame)) |
686 ;(defun auto-lower-mode (arg) | 992 (completion-ignore-case t) |
687 ; "Toggle whether or not the selected frame should auto-lower. | 993 (font (completing-read "Font name: " |
688 ;With arg, turn auto-lower mode on if and only if arg is positive. | 994 (mapcar #'list |
689 ;Note that this controls Emacs's own auto-lower feature. | 995 (list-fonts "*" frame)) |
690 ;Some window managers allow you to enable auto-lower for certain windows. | 996 nil nil nil nil |
691 ;You can use that for Emacs windows if you wish, but if you do, | 997 (face-font-name 'default frame)))) |
692 ;that is beyond the control of Emacs and this command has no effect on it." | 998 (list font current-prefix-arg))) |
693 ; (interactive "P") | 999 (let* ((frame (selected-frame)) |
694 ; (if (null arg) | 1000 (fht (frame-pixel-height frame)) |
695 ; (setq arg | 1001 (fwd (frame-pixel-width frame)) |
696 ; (if (frame-property (selected-frame) 'auto-lower) | 1002 (face-list-to-change (face-list))) |
697 ; -1 1))) | 1003 (when (eq (device-type) 'mswindows) |
698 ; (set-frame-property (selected-frame) 'auto-lower (> arg 0))) | 1004 (setq face-list-to-change |
699 | 1005 (delq 'border-glyph face-list-to-change))) |
700 ;; FSFmacs has silly functions `toggle-scroll-bar', | 1006 ;; FIXME: Is it sufficient to just change the default face, due to |
701 ;; `toggle-horizontal-scrollbar' | 1007 ;; face inheritance? |
1008 (dolist (face face-list-to-change) | |
1009 (when (face-font-instance face) | |
1010 (condition-case c | |
1011 (set-face-font face font-name frame) | |
1012 (error | |
1013 (display-error c nil) | |
1014 (sit-for 1))))) | |
1015 (if keep-size | |
1016 (set-frame-pixel-size frame fwd fht))) | |
1017 (run-hooks 'after-setting-font-hook)) | |
1018 | |
1019 (defun set-frame-property (frame prop val) | |
1020 "Set property PROP of FRAME to VAL. See `set-frame-properties'." | |
1021 (set-frame-properties frame (list prop val))) | |
1022 | |
1023 ;; XEmacs change: this function differs significantly from Emacs. | |
1024 (defun set-background-color (color-name) | |
1025 "Set the background color of the selected frame to COLOR-NAME. | |
1026 When called interactively, prompt for the name of the color to use. | |
1027 To get the frame's current background color, use | |
1028 `(face-background-name 'default)'." | |
1029 (interactive (list (read-color "Color: "))) | |
1030 ;; (set-face-foreground 'text-cursor color-name (selected-frame)) | |
1031 (set-face-background 'default color-name (selected-frame))) | |
1032 | |
1033 ;; XEmacs change: this function differs significantly from Emacs. | |
1034 (defun set-foreground-color (color-name) | |
1035 "Set the foreground color of the selected frame to COLOR-NAME. | |
1036 When called interactively, prompt for the name of the color to use. | |
1037 To get the frame's current foreground color, use | |
1038 `(face-foreground-name 'default)'." | |
1039 (interactive (list (read-color "Color: "))) | |
1040 (set-face-foreground 'default color-name (selected-frame))) | |
1041 | |
1042 ;; XEmacs change: this function differs significantly from Emacs. | |
1043 (defun set-cursor-color (color-name) | |
1044 "Set the text cursor color of the selected frame to COLOR-NAME. | |
1045 When called interactively, prompt for the name of the color to use. | |
1046 To get the frame's current cursor color, use | |
1047 '(face-background-name 'text-cursor)'." | |
1048 (interactive (list (read-color "Color: "))) | |
1049 (set-face-background 'text-cursor color-name (selected-frame))) | |
1050 | |
1051 ;; XEmacs change: this function differs significantly from Emacs. | |
1052 (defun set-mouse-color (color-name) | |
1053 "Set the color of the mouse pointer of the selected frame to COLOR-NAME. | |
1054 When called interactively, prompt for the name of the color to use. | |
1055 To get the frame's current mouse color, use | |
1056 `(face-foreground-name 'pointer)'." | |
1057 (interactive (list (read-color "Color: "))) | |
1058 (set-face-foreground 'pointer color-name (selected-frame))) | |
1059 | |
1060 ;; XEmacs change: this function differs significantly from Emacs. | |
1061 (defun set-border-color (color-name) | |
1062 "Set the color of the border of the selected frame to COLOR-NAME. | |
1063 When called interactively, prompt for the name of the color to use. | |
1064 To get the frame's current border color, use | |
1065 `(face-foreground-name 'border-glyph)'." | |
1066 (interactive (list (read-color "Color: "))) | |
1067 (set-face-foreground 'border-glyph color-name (selected-frame))) | |
702 | 1068 |
1069 ;;; BEGIN XEmacs addition | |
1070 ;;; This is the traditional XEmacs auto-raise and auto-lower, which applies | |
1071 ;;; to all frames. | |
1072 | |
1073 (defcustom auto-raise-frame nil | |
1074 "*If true, frames will be raised to the top when selected. | |
1075 Under X, most ICCCM-compliant window managers will have an option to do this | |
1076 for you, but this variable is provided in case you're using a broken WM." | |
1077 :type 'boolean | |
1078 :group 'frames) | |
1079 | |
1080 (defcustom auto-lower-frame nil | |
1081 "*If true, frames will be lowered to the bottom when no longer selected. | |
1082 Under X, most ICCCM-compliant window managers will have an option to do this | |
1083 for you, but this variable is provided in case you're using a broken WM." | |
1084 :type 'boolean | |
1085 :group 'frames) | |
1086 | |
1087 (defun default-select-frame-hook () | |
1088 "Implement the `auto-raise-frame' variable. | |
1089 For use as the value of `select-frame-hook'." | |
1090 (if auto-raise-frame (raise-frame (selected-frame)))) | |
1091 | |
1092 (defun default-deselect-frame-hook () | |
1093 "Implement the `auto-lower-frame' variable. | |
1094 For use as the value of `deselect-frame-hook'." | |
1095 (if auto-lower-frame (lower-frame (selected-frame))) | |
1096 (highlight-extent nil nil)) | |
1097 | |
1098 (or select-frame-hook | |
1099 (add-hook 'select-frame-hook 'default-select-frame-hook)) | |
1100 | |
1101 (or deselect-frame-hook | |
1102 (add-hook 'deselect-frame-hook 'default-deselect-frame-hook)) | |
1103 | |
1104 ;;; END XEmacs addition | |
1105 ;;; Following is the Emacs auto-raise/auto-lower interface, which lets the | |
1106 ;;; user select individual frames to auto-raise and auto-lower | |
1107 | |
1108 ;; XEmacs addition: the next two variables do not appear in Emacs | |
1109 (defvar auto-raise-specifier (make-boolean-specifier auto-raise-frame) | |
1110 "Specifier that determines which frames should auto-raise. | |
1111 A value of `t' means that a frame auto-raises; `nil' means it does not.") | |
1112 | |
1113 (defvar auto-lower-specifier (make-boolean-specifier auto-lower-frame) | |
1114 "Specifier that determines which frames should auto-lower. | |
1115 A value of `t' means that a frame auto-lowers; `nil' means it does not.") | |
1116 | |
1117 ;; XEmacs change: use specifiers instead of frame-parameters | |
1118 (defun auto-raise-mode (arg) | |
1119 "Toggle whether or not the selected frame should auto-raise. | |
1120 With arg, turn auto-raise mode on if and only if arg is positive. | |
1121 Note that this controls Emacs's own auto-raise feature. | |
1122 Some window managers allow you to enable auto-raise for certain windows. | |
1123 You can use that for Emacs windows if you wish, but if you do, | |
1124 that is beyond the control of Emacs and this command has no effect on it." | |
1125 (interactive "P") | |
1126 (if (null arg) | |
1127 (setq arg | |
1128 (if (specifier-instance auto-raise-specifier (selected-frame)) | |
1129 -1 1))) | |
1130 (if (> arg 0) | |
1131 (progn | |
1132 (raise-frame (selected-frame)) | |
1133 (add-hook 'select-frame-hook 'default-select-frame-hook)) | |
1134 (set-specifier auto-raise-specifier (> arg 0) (selected-frame)))) | |
1135 | |
1136 ;; XEmacs change: use specifiers instead of frame-parameters | |
1137 (defun auto-lower-mode (arg) | |
1138 "Toggle whether or not the selected frame should auto-lower. | |
1139 With arg, turn auto-lower mode on if and only if arg is positive. | |
1140 Note that this controls Emacs's own auto-lower feature. | |
1141 Some window managers allow you to enable auto-lower for certain windows. | |
1142 You can use that for Emacs windows if you wish, but if you do, | |
1143 that is beyond the control of Emacs and this command has no effect on it." | |
1144 (interactive "P") | |
1145 (if (null arg) | |
1146 (setq arg | |
1147 (if (specifier-instance auto-lower-specifier (selected-frame)) | |
1148 -1 1))) | |
1149 (if (> arg 0) | |
1150 (progn | |
1151 (lower-frame (selected-frame)) | |
1152 (add-hook 'deselect-frame-hook 'default-deselect-frame-hook)) | |
1153 (set-specifier auto-lower-specifier (> arg 0) (selected-frame)))) | |
1154 | |
1155 ;; XEmacs omission: XEmacs does not support changing the frame name | |
1156 ;(defun set-frame-name (name) | |
1157 ; "Set the name of the selected frame to NAME. | |
1158 ;When called interactively, prompt for the name of the frame. | |
1159 ;The frame name is displayed on the modeline if the terminal displays only | |
1160 ;one frame, otherwise the name is displayed on the frame's caption bar." | |
1161 ; (interactive "sFrame name: ") | |
1162 ; (modify-frame-parameters (selected-frame) | |
1163 ; (list (cons 'name name)))) | |
1164 | |
1165 ;; XEmacs omission: XEmacs attaches scrollbars to windows, not frames. | |
1166 ;; See window-hscroll and ... what? window-start? | |
1167 ;(defun frame-current-scroll-bars (&optional frame) | |
1168 ; "Return the current scroll-bar settings in frame FRAME. | |
1169 ;Value is a cons (VERTICAL . HORISONTAL) where VERTICAL specifies the | |
1170 ;current location of the vertical scroll-bars (left, right, or nil), | |
1171 ;and HORISONTAL specifies the current location of the horisontal scroll | |
1172 ;bars (top, bottom, or nil)." | |
1173 ; (let ((vert (frame-parameter frame 'vertical-scroll-bars)) | |
1174 ; (hor nil)) | |
1175 ; (unless (memq vert '(left right nil)) | |
1176 ; (setq vert default-frame-scroll-bars)) | |
1177 ; (cons vert hor))) | |
1178 | |
1179 ;;;; Frame/display capabilities. | |
1180 (defun display-mouse-p (&optional display) | |
1181 "Return non-nil if DISPLAY has a mouse available. | |
1182 DISPLAY can be a frame, a device, a console, or nil (meaning the | |
1183 selected frame)." | |
1184 (case (framep-on-display display) | |
1185 ;; We assume X, NeXTstep, and GTK *always* have a pointing device | |
1186 ((x ns gtk) t) | |
1187 (mswindows (> mswindows-num-mouse-buttons 0)) | |
1188 (tty | |
1189 (and | |
1190 (fboundp 'gpm-is-supported-p) | |
1191 (gpm-is-supported-p (display-device display)))) | |
1192 (t nil))) | |
1193 | |
1194 (defun display-popup-menus-p (&optional display) | |
1195 "Return non-nil if popup menus are supported on DISPLAY. | |
1196 DISPLAY can be a frame, a device, a console, or nil (meaning the selected | |
1197 frame). Support for popup menus requires that the mouse be available." | |
1198 (and | |
1199 (memq (framep-on-display display) '(x ns gtk mswindows)) | |
1200 (display-mouse-p display))) | |
1201 | |
1202 (defun display-graphic-p (&optional display) | |
1203 "Return non-nil if DISPLAY is a graphic display. | |
1204 Graphical displays are those which are capable of displaying several | |
1205 frames and several different fonts at once. This is true for displays | |
1206 that use a window system such as X, and false for text-only terminals. | |
1207 DISPLAY can be a frame, a device, a console, or nil (meaning the selected | |
1208 frame)." | |
1209 (memq (framep-on-display display) '(x ns gtk mswindows))) | |
1210 | |
1211 (defun display-images-p (&optional display) | |
1212 "Return non-nil if DISPLAY can display images. | |
1213 DISPLAY can be a frame, a device, a console, or nil (meaning the selected | |
1214 frame)." | |
1215 (display-graphic-p display)) | |
1216 | |
1217 (defalias 'display-multi-frame-p 'display-graphic-p) | |
1218 (defalias 'display-multi-font-p 'display-graphic-p) | |
1219 | |
1220 (defun display-selections-p (&optional display) | |
1221 "Return non-nil if DISPLAY supports selections. | |
1222 A selection is a way to transfer text or other data between programs | |
1223 via special system buffers called `selection' or `cut buffer' or | |
1224 `clipboard'. | |
1225 DISPLAY can be a frame, a device, a console, or nil (meaning the selected | |
1226 frame)." | |
1227 (memq (framep-on-display display) '(x ns gtk mswindows))) | |
1228 | |
1229 (defun display-screens (&optional display) | |
1230 "Return the number of screens associated with DISPLAY." | |
1231 (device-num-screens (display-device display))) | |
1232 | |
1233 (defun display-pixel-height (&optional display) | |
1234 "Return the height of DISPLAY's screen in pixels. | |
1235 For character terminals, each character counts as a single pixel." | |
1236 (device-pixel-height (display-device display))) | |
1237 | |
1238 (defun display-pixel-width (&optional display) | |
1239 "Return the width of DISPLAY's screen in pixels. | |
1240 For character terminals, each character counts as a single pixel." | |
1241 (device-pixel-width (display-device display))) | |
1242 | |
1243 (defun display-mm-height (&optional display) | |
1244 "Return the height of DISPLAY's screen in millimeters. | |
1245 If the information is unavailable, value is nil." | |
1246 (device-mm-height (display-device display))) | |
1247 | |
1248 (defun display-mm-width (&optional display) | |
1249 "Return the width of DISPLAY's screen in millimeters. | |
1250 If the information is unavailable, value is nil." | |
1251 (device-mm-width (display-device display))) | |
1252 | |
1253 (defun display-backing-store (&optional display) | |
1254 "Return the backing store capability of DISPLAY's screen. | |
1255 The value may be `always', `when-mapped', `not-useful', or nil if | |
1256 the question is inapplicable to a certain kind of display." | |
1257 (device-backing-store (display-device display))) | |
1258 | |
1259 (defun display-save-under (&optional display) | |
1260 "Return non-nil if DISPLAY's screen supports the SaveUnder feature." | |
1261 (device-save-under (display-device display))) | |
1262 | |
1263 (defun display-planes (&optional display) | |
1264 "Return the number of planes supported by DISPLAY." | |
1265 (device-bitplanes (display-device display))) | |
1266 | |
1267 (defun display-color-cells (&optional display) | |
1268 "Return the number of color cells supported by DISPLAY." | |
1269 (device-color-cells (display-device display))) | |
1270 | |
1271 (defun display-visual-class (&optional display) | |
1272 "Returns the visual class of DISPLAY. | |
1273 The value is one of the symbols `static-gray', `gray-scale', | |
1274 `static-color', `pseudo-color', `true-color', or `direct-color'." | |
1275 (case (framep-on-display display) | |
1276 (x (x-display-visual-class (display-device display))) | |
1277 (gtk (gtk-display-visual-class (display-device display))) | |
1278 (mswindows (let ((planes (display-planes display))) | |
1279 (cond ((eq planes 1) 'static-gray) | |
1280 ((eq planes 4) 'static-color) | |
1281 ((> planes 8) 'true-color) | |
1282 (t 'pseudo-color)))) | |
1283 (t 'static-gray))) | |
1284 | |
1285 | |
1286 ;; XEmacs change: omit the Emacs 18 compatibility functions: | |
1287 ;; screen-height, screen-width, set-screen-height, and set-screen-width. | |
1288 | |
1289 (defun delete-other-frames (&optional frame) | |
1290 "Delete all frames except FRAME. | |
1291 If FRAME uses another frame's minibuffer, the minibuffer frame is | |
1292 left untouched. FRAME nil or omitted means use the selected frame." | |
1293 (interactive) | |
1294 (unless frame | |
1295 (setq frame (selected-frame))) | |
1296 (let* ((mini-frame (window-frame (minibuffer-window frame))) | |
1297 (frames (delq mini-frame (delq frame (frame-list))))) | |
1298 (mapc 'delete-frame frames))) | |
1299 | |
1300 ;; XEmacs change: we still use delete-frame-hook | |
1301 ;; miscellaneous obsolescence declarations | |
1302 ;(defvaralias 'delete-frame-hook 'delete-frame-functions) | |
1303 ;(make-obsolete-variable 'delete-frame-hook 'delete-frame-functions "21.4") | |
1304 | |
1305 | |
1306 ;; Highlighting trailing whitespace. | |
1307 ;; XEmacs omission: this functionality is provided by whitespace-mode in the | |
1308 ;; text-modes package. | |
1309 | |
1310 ;(make-variable-buffer-local 'show-trailing-whitespace) | |
1311 | |
1312 ;(defcustom show-trailing-whitespace nil | |
1313 ; "*Non-nil means highlight trailing whitespace in face `trailing-whitespace'. | |
1314 ; | |
1315 ;Setting this variable makes it local to the current buffer." | |
1316 ; :tag "Highlight trailing whitespace." | |
1317 ; :type 'boolean | |
1318 ; :group 'font-lock) | |
1319 | |
1320 | |
1321 ;; Scrolling | |
1322 ;; XEmacs omission: This functionality is always enabled on XEmacs. | |
1323 | |
1324 ;(defgroup scrolling nil | |
1325 ; "Scrolling windows." | |
1326 ; :version "21.1" | |
1327 ; :group 'frames) | |
1328 | |
1329 ;(defcustom auto-hscroll-mode t | |
1330 ; "*Allow or disallow automatic scrolling windows horizontally. | |
1331 ;If non-nil, windows are automatically scrolled horizontally to make | |
1332 ;point visible." | |
1333 ; :version "21.1" | |
1334 ; :type 'boolean | |
1335 ; :group 'scrolling) | |
1336 ;(defvaralias 'automatic-hscrolling 'auto-hscroll-mode) | |
1337 | |
1338 | |
1339 ;; Blinking cursor | |
1340 ;; XEmacs omission: this functionality is provided by blink-cursor in the | |
1341 ;; edit-utils package. | |
1342 | |
1343 ; (defgroup cursor nil | |
1344 ; "Displaying text cursors." | |
1345 ; :version "21.1" | |
1346 ; :group 'frames) | |
1347 | |
1348 ; (defcustom blink-cursor-delay 0.5 | |
1349 ; "*Seconds of idle time after which cursor starts to blink." | |
1350 ; :tag "Delay in seconds." | |
1351 ; :type 'number | |
1352 ; :group 'cursor) | |
1353 | |
1354 ; (defcustom blink-cursor-interval 0.5 | |
1355 ; "*Length of cursor blink interval in seconds." | |
1356 ; :tag "Blink interval in seconds." | |
1357 ; :type 'number | |
1358 ; :group 'cursor) | |
1359 | |
1360 ; (defvar blink-cursor-idle-timer nil | |
1361 ; "Timer started after `blink-cursor-delay' seconds of Emacs idle time. | |
1362 ; The function `blink-cursor-start' is called when the timer fires.") | |
1363 | |
1364 ; (defvar blink-cursor-timer nil | |
1365 ; "Timer started from `blink-cursor-start'. | |
1366 ; This timer calls `blink-cursor' every `blink-cursor-interval' seconds.") | |
1367 | |
1368 ; (defvar blink-cursor-mode nil | |
1369 ; "Non-nil means blinking cursor is active.") | |
1370 | |
1371 ; (defun blink-cursor-mode (arg) | |
1372 ; "Toggle blinking cursor mode. | |
1373 ; With a numeric argument, turn blinking cursor mode on iff ARG is positive. | |
1374 ; When blinking cursor mode is enabled, the cursor of the selected | |
1375 ; window blinks. | |
1376 | |
1377 ; Note that this command is effective only when Emacs | |
1378 ; displays through a window system, because then Emacs does its own | |
1379 ; cursor display. On a text-only terminal, this is not implemented." | |
1380 ; (interactive "P") | |
1381 ; (let ((on-p (if (null arg) | |
1382 ; (not blink-cursor-mode) | |
1383 ; (> (prefix-numeric-value arg) 0)))) | |
1384 ; (if blink-cursor-idle-timer | |
1385 ; (cancel-timer blink-cursor-idle-timer)) | |
1386 ; (if blink-cursor-timer | |
1387 ; (cancel-timer blink-cursor-timer)) | |
1388 ; (setq blink-cursor-idle-timer nil | |
1389 ; blink-cursor-timer nil | |
1390 ; blink-cursor-mode nil) | |
1391 ; (if on-p | |
1392 ; (progn | |
1393 ; ;; Hide the cursor. | |
1394 ; ;(internal-show-cursor nil nil) | |
1395 ; (setq blink-cursor-idle-timer | |
1396 ; (run-with-idle-timer blink-cursor-delay | |
1397 ; blink-cursor-delay | |
1398 ; 'blink-cursor-start)) | |
1399 ; (setq blink-cursor-mode t)) | |
1400 ; (internal-show-cursor nil t)))) | |
1401 | |
1402 ; ;; Note that this is really initialized from startup.el before | |
1403 ; ;; the init-file is read. | |
1404 | |
1405 ; (defcustom blink-cursor nil | |
1406 ; "*Non-nil means blinking cursor mode is active." | |
1407 ; :group 'cursor | |
1408 ; :tag "Blinking cursor" | |
1409 ; :type 'boolean | |
1410 ; :set #'(lambda (symbol value) | |
1411 ; (set-default symbol value) | |
1412 ; (blink-cursor-mode (or value 0)))) | |
1413 | |
1414 ; (defun blink-cursor-start () | |
1415 ; "Timer function called from the timer `blink-cursor-idle-timer'. | |
1416 ; This starts the timer `blink-cursor-timer', which makes the cursor blink | |
1417 ; if appropriate. It also arranges to cancel that timer when the next | |
1418 ; command starts, by installing a pre-command hook." | |
1419 ; (when (null blink-cursor-timer) | |
1420 ; (add-hook 'pre-command-hook 'blink-cursor-end) | |
1421 ; (setq blink-cursor-timer | |
1422 ; (run-with-timer blink-cursor-interval blink-cursor-interval | |
1423 ; 'blink-cursor-timer-function)))) | |
1424 | |
1425 ; (defun blink-cursor-timer-function () | |
1426 ; "Timer function of timer `blink-cursor-timer'." | |
1427 ; (internal-show-cursor nil (not (internal-show-cursor-p)))) | |
1428 | |
1429 ; (defun blink-cursor-end () | |
1430 ; "Stop cursor blinking. | |
1431 ; This is installed as a pre-command hook by `blink-cursor-start'. | |
1432 ; When run, it cancels the timer `blink-cursor-timer' and removes | |
1433 ; itself as a pre-command hook." | |
1434 ; (remove-hook 'pre-command-hook 'blink-cursor-end) | |
1435 ; (internal-show-cursor nil t) | |
1436 ; (cancel-timer blink-cursor-timer) | |
1437 ; (setq blink-cursor-timer nil)) | |
1438 | |
1439 | |
1440 ;; Hourglass pointer | |
1441 ;; XEmacs omission: this functionality is provided elsewhere. | |
1442 | |
1443 ; (defcustom display-hourglass t | |
1444 ; "*Non-nil means show an hourglass pointer when running under a window system." | |
1445 ; :tag "Hourglass pointer" | |
1446 ; :type 'boolean | |
1447 ; :group 'cursor) | |
1448 | |
1449 ; (defcustom hourglass-delay 1 | |
1450 ; "*Seconds to wait before displaying an hourglass pointer." | |
1451 ; :tag "Hourglass delay" | |
1452 ; :type 'number | |
1453 ; :group 'cursor) | |
1454 | |
1455 ; | |
1456 ; (defcustom cursor-in-non-selected-windows t | |
1457 ; "*Non-nil means show a hollow box cursor in non-selected-windows. | |
1458 ; If nil, don't show a cursor except in the selected window. | |
1459 ; Use Custom to set this variable to get the display updated." | |
1460 ; :tag "Cursor in non-selected windows" | |
1461 ; :type 'boolean | |
1462 ; :group 'cursor | |
1463 ; :set #'(lambda (symbol value) | |
1464 ; (set-default symbol value) | |
1465 ; (force-mode-line-update t))) | |
1466 | |
1467 | |
1468 ;;;; Key bindings | |
1469 ;; XEmacs change: these keybindings are in keydef.el. | |
1470 | |
1471 ;(define-key ctl-x-5-map "2" 'make-frame-command) | |
1472 ;(define-key ctl-x-5-map "1" 'delete-other-frames) | |
1473 ;(define-key ctl-x-5-map "0" 'delete-frame) | |
1474 ;(define-key ctl-x-5-map "o" 'other-frame) | |
1475 | |
1476 | |
1477 ;;; XEmacs addition: nothing below this point appears in the Emacs version. | |
1478 | |
703 ;;; Iconifying emacs. | 1479 ;;; Iconifying emacs. |
704 ;;; | 1480 ;;; |
705 ;;; The function iconify-emacs replaces every non-iconified emacs window | 1481 ;;; The function iconify-emacs replaces every non-iconified emacs window |
706 ;;; with a *single* icon. Iconified emacs windows are left alone. When | 1482 ;;; with a *single* icon. Iconified emacs windows are left alone. When |
707 ;;; emacs is in this globally-iconified state, de-iconifying any emacs icon | 1483 ;;; emacs is in this globally-iconified state, de-iconifying any emacs icon |
795 (declare-fboundp (console-tty-controlling-process | 1571 (declare-fboundp (console-tty-controlling-process |
796 (selected-console)))) | 1572 (selected-console)))) |
797 (suspend-console (selected-console))) | 1573 (suspend-console (selected-console))) |
798 (t | 1574 (t |
799 (suspend-emacs)))) | 1575 (suspend-emacs)))) |
800 | |
801 | |
802 ;;; auto-raise and auto-lower | |
803 | |
804 (defcustom auto-raise-frame nil | |
805 "*If true, frames will be raised to the top when selected. | |
806 Under X, most ICCCM-compliant window managers will have an option to do this | |
807 for you, but this variable is provided in case you're using a broken WM." | |
808 :type 'boolean | |
809 :group 'frames) | |
810 | |
811 (defcustom auto-lower-frame nil | |
812 "*If true, frames will be lowered to the bottom when no longer selected. | |
813 Under X, most ICCCM-compliant window managers will have an option to do this | |
814 for you, but this variable is provided in case you're using a broken WM." | |
815 :type 'boolean | |
816 :group 'frames) | |
817 | |
818 (defun default-select-frame-hook () | |
819 "Implement the `auto-raise-frame' variable. | |
820 For use as the value of `select-frame-hook'." | |
821 (if auto-raise-frame (raise-frame (selected-frame)))) | |
822 | |
823 (defun default-deselect-frame-hook () | |
824 "Implement the `auto-lower-frame' variable. | |
825 For use as the value of `deselect-frame-hook'." | |
826 (if auto-lower-frame (lower-frame (selected-frame))) | |
827 (highlight-extent nil nil)) | |
828 | |
829 (or select-frame-hook | |
830 (add-hook 'select-frame-hook 'default-select-frame-hook)) | |
831 | |
832 (or deselect-frame-hook | |
833 (add-hook 'deselect-frame-hook 'default-deselect-frame-hook)) | |
834 | 1576 |
835 | 1577 |
836 ;;; Application-specific frame-management | 1578 ;;; Application-specific frame-management |
837 | 1579 |
838 (defcustom get-frame-for-buffer-default-frame-name nil | 1580 (defcustom get-frame-for-buffer-default-frame-name nil |
1119 (setq pre-display-buffer-function 'get-frame-for-buffer) | 1861 (setq pre-display-buffer-function 'get-frame-for-buffer) |
1120 (setq temp-buffer-show-function 'show-temp-buffer-in-current-frame) | 1862 (setq temp-buffer-show-function 'show-temp-buffer-in-current-frame) |
1121 | 1863 |
1122 | 1864 |
1123 ;; from Bob Weiner <bweiner@pts.mot.com>, modified by Ben Wing | 1865 ;; from Bob Weiner <bweiner@pts.mot.com>, modified by Ben Wing |
1124 (defun delete-other-frames (&optional frame) | |
1125 "Delete all but FRAME (or the selected frame)." | |
1126 (interactive) | |
1127 (mapc 'delete-frame (delq (or frame (selected-frame)) (frame-list)))) | |
1128 | 1866 |
1129 ;; By adding primitives to directly access the window hierarchy, | 1867 ;; By adding primitives to directly access the window hierarchy, |
1130 ;; we can move many functions into Lisp. We do it this way | 1868 ;; we can move many functions into Lisp. We do it this way |
1131 ;; because the implementations are simpler in Lisp, and because | 1869 ;; because the implementations are simpler in Lisp, and because |
1132 ;; new functions like this can be added without requiring C | 1870 ;; new functions like this can be added without requiring C |
1258 | 1996 |
1259 | 1997 |
1260 | 1998 |
1261 ;; frame properties. | 1999 ;; frame properties. |
1262 | 2000 |
1263 (defun set-frame-property (frame prop val) | |
1264 "Set property PROP of FRAME to VAL. See `set-frame-properties'." | |
1265 (set-frame-properties frame (list prop val))) | |
1266 | |
1267 (defun frame-height (&optional frame) | |
1268 "Return number of lines available for display on FRAME." | |
1269 (frame-property frame 'height)) | |
1270 | |
1271 (defun frame-width (&optional frame) | |
1272 "Return number of columns available for display on FRAME." | |
1273 (frame-property frame 'width)) | |
1274 | |
1275 (put 'cursor-color 'frame-property-alias [text-cursor background]) | 2001 (put 'cursor-color 'frame-property-alias [text-cursor background]) |
1276 (put 'modeline 'frame-property-alias 'has-modeline-p) | 2002 (put 'modeline 'frame-property-alias 'has-modeline-p) |
1277 | 2003 |
1278 | 2004 |
1279 (provide 'frame) | 2005 (provide 'frame) |