1 ;;; frame.el --- multi-frame management independent of window systems
3 ;; Copyright (C) 1993, 1994, 1996, 1997, 2000, 2001, 2002, 2003,
4 ;; 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 3, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
30 (defvar frame-creation-function nil
31 "Window-system dependent function to call to create a new frame.
32 The window system startup file should set this to its frame creation
33 function, which should take an alist of parameters as its argument.")
35 ;; The initial value given here used to ask for a minibuffer.
36 ;; But that's not necessary, because the default is to have one.
37 ;; By not specifying it here, we let an X resource specify it.
38 (defcustom initial-frame-alist nil
39 "*Alist of frame parameters for creating the initial X window frame.
40 You can set this in your `.emacs' file; for example,
41 (setq initial-frame-alist '((top . 1) (left . 1) (width . 80) (height . 55)))
42 Parameters specified here supersede the values given in `default-frame-alist'.
44 If the value calls for a frame without a minibuffer, and you have not created
45 a minibuffer frame on your own, one is created according to
46 `minibuffer-frame-alist'.
48 You can specify geometry-related options for just the initial frame
49 by setting this variable in your `.emacs' file; however, they won't
50 take effect until Emacs reads `.emacs', which happens after first creating
51 the frame. If you want the frame to have the proper geometry as soon
52 as it appears, you need to use this three-step process:
53 * Specify X resources to give the geometry you want.
54 * Set `default-frame-alist' to override these options so that they
55 don't affect subsequent frames.
56 * Set `initial-frame-alist' in a way that matches the X resources,
57 to override what you put in `default-frame-alist'."
58 :type
'(repeat (cons :format
"%v"
59 (symbol :tag
"Parameter")
63 (defcustom minibuffer-frame-alist
'((width .
80) (height .
2))
64 "*Alist of frame parameters for initially creating a minibuffer frame.
65 You can set this in your `.emacs' file; for example,
66 (setq minibuffer-frame-alist
67 '((top . 1) (left . 1) (width . 80) (height . 2)))
68 Parameters specified here supersede the values given in
69 `default-frame-alist', for a minibuffer frame."
70 :type
'(repeat (cons :format
"%v"
71 (symbol :tag
"Parameter")
75 (defcustom pop-up-frame-alist nil
76 "*Alist of frame parameters used when creating pop-up frames.
77 Pop-up frames are used for completions, help, and the like.
78 This variable can be set in your init file, like this:
79 (setq pop-up-frame-alist '((width . 80) (height . 20)))
80 These supersede the values given in `default-frame-alist',
82 :type
'(repeat (cons :format
"%v"
83 (symbol :tag
"Parameter")
87 (setq pop-up-frame-function
88 ;; Using `function' here caused some sort of problem.
90 (make-frame pop-up-frame-alist
)))
92 (defcustom special-display-frame-alist
93 '((height .
14) (width .
80) (unsplittable . t
))
94 "*Alist of frame parameters used when creating special frames.
95 Special frames are used for buffers whose names are in
96 `special-display-buffer-names' and for buffers whose names match
97 one of the regular expressions in `special-display-regexps'.
98 This variable can be set in your init file, like this:
99 (setq special-display-frame-alist '((width . 80) (height . 20)))
100 These supersede the values given in `default-frame-alist'."
101 :type
'(repeat (cons :format
"%v"
102 (symbol :tag
"Parameter")
103 (sexp :tag
"Value")))
106 (defun special-display-popup-frame (buffer &optional args
)
107 "Display BUFFER in its own frame, reusing an existing window if any.
108 Return the window chosen.
109 Currently we do not insist on selecting the window within its frame.
110 If ARGS is an alist, use it as a list of frame parameter specs.
111 If ARGS is a list whose car is a symbol,
112 use (car ARGS) as a function to do the work.
113 Pass it BUFFER as first arg, and (cdr ARGS) gives the rest of the args."
114 (if (and args
(symbolp (car args
)))
115 (apply (car args
) buffer
(cdr args
))
116 (let ((window (get-buffer-window buffer
0)))
118 ;; If we have a window already, make it visible.
120 (let ((frame (window-frame window
)))
121 (make-frame-visible frame
)
124 ;; Reuse the current window if the user requested it.
125 (when (cdr (assq 'same-window args
))
127 (progn (switch-to-buffer buffer
) (selected-window))
129 ;; Stay on the same frame if requested.
130 (when (or (cdr (assq 'same-frame args
)) (cdr (assq 'same-window args
)))
131 (let* ((pop-up-frames nil
) (pop-up-windows t
)
132 special-display-regexps special-display-buffer-names
133 (window (display-buffer buffer
)))
134 ;; Only do it if this is a new window:
135 ;; (set-window-dedicated-p window t)
137 ;; If no window yet, make one in a new frame.
139 (with-current-buffer buffer
140 (make-frame (append args special-display-frame-alist
)))))
141 (set-window-buffer (frame-selected-window frame
) buffer
)
142 (set-window-dedicated-p (frame-selected-window frame
) t
)
143 (frame-selected-window frame
))))))
145 (defun handle-delete-frame (event)
146 "Handle delete-frame events from the X server."
148 (let ((frame (posn-window (event-start event
)))
152 (and (frame-visible-p (car tail
))
153 (not (eq (car tail
) frame
))
155 (setq tail
(cdr tail
)))
157 (delete-frame frame t
)
158 ;; Gildea@x.org says it is ok to ask questions before terminating.
159 (save-buffers-kill-emacs))))
161 ;;;; Arrangement of frames at startup
163 ;; 1) Load the window system startup file from the lisp library and read the
164 ;; high-priority arguments (-q and the like). The window system startup
165 ;; file should create any frames specified in the window system defaults.
167 ;; 2) If no frames have been opened, we open an initial text frame.
169 ;; 3) Once the init file is done, we apply any newly set parameters
170 ;; in initial-frame-alist to the frame.
172 ;; These are now called explicitly at the proper times,
173 ;; since that is easier to understand.
174 ;; Actually using hooks within Emacs is bad for future maintenance. --rms.
175 ;; (add-hook 'before-init-hook 'frame-initialize)
176 ;; (add-hook 'window-setup-hook 'frame-notice-user-settings)
178 ;; If we create the initial frame, this is it.
179 (defvar frame-initial-frame nil
)
181 ;; Record the parameters used in frame-initialize to make the initial frame.
182 (defvar frame-initial-frame-alist
)
184 (defvar frame-initial-geometry-arguments nil
)
186 ;; startup.el calls this function before loading the user's init
187 ;; file - if there is no frame with a minibuffer open now, create
188 ;; one to display messages while loading the init file.
189 (defun frame-initialize ()
190 "Create an initial frame if necessary."
191 ;; Are we actually running under a window system at all?
192 (if (and window-system
(not noninteractive
) (not (eq window-system
'pc
)))
194 ;; Turn on special-display processing only if there's a window system.
195 (setq special-display-function
'special-display-popup-frame
)
197 ;; If there is no frame with a minibuffer besides the terminal
198 ;; frame, then we need to create the opening frame. Make sure
199 ;; it has a minibuffer, but let initial-frame-alist omit the
201 (or (delq terminal-frame
(minibuffer-frame-list))
203 (setq frame-initial-frame-alist
204 (append initial-frame-alist default-frame-alist nil
))
205 (or (assq 'horizontal-scroll-bars frame-initial-frame-alist
)
206 (setq frame-initial-frame-alist
207 (cons '(horizontal-scroll-bars . t
)
208 frame-initial-frame-alist
)))
209 (setq default-minibuffer-frame
210 (setq frame-initial-frame
211 (make-frame frame-initial-frame-alist
)))
212 ;; Delete any specifications for window geometry parameters
213 ;; so that we won't reapply them in frame-notice-user-settings.
214 ;; It would be wrong to reapply them then,
215 ;; because that would override explicit user resizing.
216 (setq initial-frame-alist
217 (frame-remove-geometry-params initial-frame-alist
))))
218 ;; At this point, we know that we have a frame open, so we
219 ;; can delete the terminal frame.
220 (delete-frame terminal-frame
)
221 (setq terminal-frame nil
))
223 ;; No, we're not running a window system. Use make-terminal-frame if
224 ;; we support that feature, otherwise arrange to cause errors.
225 (or (eq window-system
'pc
)
226 (setq frame-creation-function
227 (if (fboundp 'tty-create-frame-with-faces
)
228 'tty-create-frame-with-faces
232 "Can't create multiple frames without a window system"))))))))
234 (defvar frame-notice-user-settings t
235 "Non-nil means function `frame-notice-user-settings' wasn't run yet.")
237 ;; startup.el calls this function after loading the user's init
238 ;; file. Now default-frame-alist and initial-frame-alist contain
239 ;; information to which we must react; do what needs to be done.
240 (defun frame-notice-user-settings ()
241 "Act on user's init file settings of frame parameters.
242 React to settings of `default-frame-alist', `initial-frame-alist' there."
243 ;; Make menu-bar-mode and default-frame-alist consistent.
244 (when (boundp 'menu-bar-mode
)
245 (let ((default (assq 'menu-bar-lines default-frame-alist
)))
247 (setq menu-bar-mode
(not (eq (cdr default
) 0)))
248 (setq default-frame-alist
249 (cons (cons 'menu-bar-lines
(if menu-bar-mode
1 0))
250 default-frame-alist
)))))
252 ;; Make tool-bar-mode and default-frame-alist consistent. Don't do
253 ;; it in batch mode since that would leave a tool-bar-lines
254 ;; parameter in default-frame-alist in a dumped Emacs, which is not
256 (when (and (boundp 'tool-bar-mode
)
257 (not noninteractive
))
258 (let ((default (assq 'tool-bar-lines default-frame-alist
)))
260 (setq tool-bar-mode
(not (eq (cdr default
) 0)))
261 (setq default-frame-alist
262 (cons (cons 'tool-bar-lines
(if tool-bar-mode
1 0))
263 default-frame-alist
)))))
265 ;; Creating and deleting frames may shift the selected frame around,
266 ;; and thus the current buffer. Protect against that. We don't
267 ;; want to use save-excursion here, because that may also try to set
268 ;; the buffer of the selected window, which fails when the selected
269 ;; window is the minibuffer.
270 (let ((old-buffer (current-buffer)))
272 (when (and frame-notice-user-settings
273 (null frame-initial-frame
))
274 ;; This case happens when we don't have a window system, and
275 ;; also for MS-DOS frames.
276 (let ((parms (frame-parameters frame-initial-frame
)))
277 ;; Don't change the frame names.
278 (setq parms
(delq (assq 'name parms
) parms
))
279 ;; Can't modify the minibuffer parameter, so don't try.
280 (setq parms
(delq (assq 'minibuffer parms
) parms
))
281 (modify-frame-parameters nil
282 (if (null window-system
)
283 (append initial-frame-alist
287 ;; initial-frame-alist and
288 ;; default-frame-alist were already
289 ;; applied in pc-win.el.
291 (if (null window-system
) ;; MS-DOS does this differently in pc-win.el
292 (let ((newparms (frame-parameters))
293 (frame (selected-frame)))
294 (tty-handle-reverse-video frame newparms
)
295 ;; If we changed the background color, we need to update
296 ;; the background-mode parameter, and maybe some faces,
298 (when (assq 'background-color newparms
)
299 (unless (or (assq 'background-mode initial-frame-alist
)
300 (assq 'background-mode default-frame-alist
))
301 (frame-set-background-mode frame
))
302 (face-set-after-frame-default frame
))))))
304 ;; If the initial frame is still around, apply initial-frame-alist
305 ;; and default-frame-alist to it.
306 (when (frame-live-p frame-initial-frame
)
308 ;; When tool-bar has been switched off, correct the frame size
309 ;; by the lines added in x-create-frame for the tool-bar and
310 ;; switch `tool-bar-mode' off.
311 (when (display-graphic-p)
312 (let ((tool-bar-lines (or (assq 'tool-bar-lines initial-frame-alist
)
313 (assq 'tool-bar-lines default-frame-alist
))))
314 (when (and tool-bar-originally-present
315 (or (null tool-bar-lines
)
316 (null (cdr tool-bar-lines
))
317 (eq 0 (cdr tool-bar-lines
))))
318 (let* ((char-height (frame-char-height frame-initial-frame
))
319 (image-height tool-bar-images-pixel-height
)
320 (margin (cond ((and (consp tool-bar-button-margin
)
321 (integerp (cdr tool-bar-button-margin
))
322 (> tool-bar-button-margin
0))
323 (cdr tool-bar-button-margin
))
324 ((and (integerp tool-bar-button-margin
)
325 (> tool-bar-button-margin
0))
326 tool-bar-button-margin
)
328 (relief (if (and (integerp tool-bar-button-relief
)
329 (> tool-bar-button-relief
0))
330 tool-bar-button-relief
3))
331 (lines (/ (+ image-height
336 (height (frame-parameter frame-initial-frame
'height
))
337 (newparms (list (cons 'height
(- height lines
))))
338 (initial-top (cdr (assq 'top
339 frame-initial-geometry-arguments
)))
340 (top (frame-parameter frame-initial-frame
'top
)))
341 (when (and (consp initial-top
) (eq '-
(car initial-top
)))
343 (cond ((and (consp top
)
347 (* lines char-height
))))
352 (* lines char-height
))))
353 (t (+ top
(* lines char-height
))))))
356 `((top .
,adjusted-top
))
358 (modify-frame-parameters frame-initial-frame newparms
)
359 (tool-bar-mode -
1)))))
361 ;; The initial frame we create above always has a minibuffer.
362 ;; If the user wants to remove it, or make it a minibuffer-only
363 ;; frame, then we'll have to delete the current frame and make a
364 ;; new one; you can't remove or add a root window to/from an
367 ;; NOTE: default-frame-alist was nil when we created the
368 ;; existing frame. We need to explicitly include
369 ;; default-frame-alist in the parameters of the screen we
370 ;; create here, so that its new value, gleaned from the user's
371 ;; .emacs file, will be applied to the existing screen.
372 (if (not (eq (cdr (or (assq 'minibuffer initial-frame-alist
)
373 (assq 'minibuffer default-frame-alist
)
376 ;; Create the new frame.
378 ;; If the frame isn't visible yet, wait till it is.
379 ;; If the user has to position the window,
380 ;; Emacs doesn't know its real position until
381 ;; the frame is seen to be visible.
382 (while (not (cdr (assq 'visibility
383 (frame-parameters frame-initial-frame
))))
385 (setq parms
(frame-parameters frame-initial-frame
))
387 ;; Get rid of `name' unless it was specified explicitly before.
388 (or (assq 'name frame-initial-frame-alist
)
389 (setq parms
(delq (assq 'name parms
) parms
)))
391 (setq parms
(append initial-frame-alist
396 ;; Get rid of `reverse', because that was handled
397 ;; when we first made the frame.
398 (setq parms
(cons '(reverse) (delq (assq 'reverse parms
) parms
)))
400 (if (assq 'height frame-initial-geometry-arguments
)
401 (setq parms
(assq-delete-all 'height parms
)))
402 (if (assq 'width frame-initial-geometry-arguments
)
403 (setq parms
(assq-delete-all 'width parms
)))
404 (if (assq 'left frame-initial-geometry-arguments
)
405 (setq parms
(assq-delete-all 'left parms
)))
406 (if (assq 'top frame-initial-geometry-arguments
)
407 (setq parms
(assq-delete-all 'top parms
)))
410 ;; Use the geometry args that created the existing
411 ;; frame, rather than the parms we get for it.
412 (append frame-initial-geometry-arguments
413 '((user-size . t
) (user-position . t
))
415 ;; The initial frame, which we are about to delete, may be
416 ;; the only frame with a minibuffer. If it is, create a
418 (or (delq frame-initial-frame
(minibuffer-frame-list))
419 (make-initial-minibuffer-frame nil
))
421 ;; If the initial frame is serving as a surrogate
422 ;; minibuffer frame for any frames, we need to wean them
423 ;; onto a new frame. The default-minibuffer-frame
424 ;; variable must be handled similarly.
425 (let ((users-of-initial
427 (function (lambda (frame)
428 (and (not (eq frame frame-initial-frame
))
430 (minibuffer-window frame
))
431 frame-initial-frame
)))))))
432 (if (or users-of-initial
433 (eq default-minibuffer-frame frame-initial-frame
))
435 ;; Choose an appropriate frame. Prefer frames which
436 ;; are only minibuffers.
437 (let* ((new-surrogate
439 (or (filtered-frame-list
442 (eq (cdr (assq 'minibuffer
443 (frame-parameters frame
)))
445 (minibuffer-frame-list))))
446 (new-minibuffer (minibuffer-window new-surrogate
)))
448 (if (eq default-minibuffer-frame frame-initial-frame
)
449 (setq default-minibuffer-frame new-surrogate
))
451 ;; Wean the frames using frame-initial-frame as
452 ;; their minibuffer frame.
456 (modify-frame-parameters
457 frame
(list (cons 'minibuffer new-minibuffer
)))))
460 ;; Redirect events enqueued at this frame to the new frame.
461 ;; Is this a good idea?
462 (redirect-frame-focus frame-initial-frame new
)
464 ;; Finally, get rid of the old frame.
465 (delete-frame frame-initial-frame t
))
467 ;; Otherwise, we don't need all that rigamarole; just apply
468 ;; the new parameters.
469 (let (newparms allparms tail
)
470 (setq allparms
(append initial-frame-alist
471 default-frame-alist nil
))
472 (if (assq 'height frame-initial-geometry-arguments
)
473 (setq allparms
(assq-delete-all 'height allparms
)))
474 (if (assq 'width frame-initial-geometry-arguments
)
475 (setq allparms
(assq-delete-all 'width allparms
)))
476 (if (assq 'left frame-initial-geometry-arguments
)
477 (setq allparms
(assq-delete-all 'left allparms
)))
478 (if (assq 'top frame-initial-geometry-arguments
)
479 (setq allparms
(assq-delete-all 'top allparms
)))
481 ;; Find just the parms that have changed since we first
482 ;; made this frame. Those are the ones actually set by
483 ;; the init file. For those parms whose values we already knew
484 ;; (such as those spec'd by command line options)
485 ;; it is undesirable to specify the parm again
486 ;; once the user has seen the frame and been able to alter it
490 (setq oldval
(assq (car (car tail
))
491 frame-initial-frame-alist
))
492 (setq newval
(cdr (assq (car (car tail
)) allparms
)))
493 (or (and oldval
(eq (cdr oldval
) newval
))
495 (cons (cons (car (car tail
)) newval
) newparms
))))
496 (setq tail
(cdr tail
)))
497 (setq newparms
(nreverse newparms
))
498 (modify-frame-parameters frame-initial-frame
500 ;; If we changed the background color,
501 ;; we need to update the background-mode parameter
502 ;; and maybe some faces too.
503 (when (assq 'background-color newparms
)
504 (unless (assq 'background-mode newparms
)
505 (frame-set-background-mode frame-initial-frame
))
506 (face-set-after-frame-default frame-initial-frame
)))))
508 ;; Restore the original buffer.
509 (set-buffer old-buffer
)
511 ;; Make sure the initial frame can be GC'd if it is ever deleted.
512 ;; Make sure frame-notice-user-settings does nothing if called twice.
513 (setq frame-notice-user-settings nil
)
514 (setq frame-initial-frame nil
)))
516 (defun make-initial-minibuffer-frame (display)
517 (let ((parms (append minibuffer-frame-alist
'((minibuffer . only
)))))
519 (make-frame-on-display display parms
)
520 (make-frame parms
))))
522 ;;;; Creation of additional frames, and other frame miscellanea
524 (defun modify-all-frames-parameters (alist)
525 "Modify all current and future frames' parameters according to ALIST.
526 This changes `default-frame-alist' and possibly `initial-frame-alist'.
527 See help of `modify-frame-parameters' for more information."
528 (let (element) ;; temp
529 (dolist (frame (frame-list))
530 (modify-frame-parameters frame alist
))
532 (dolist (pair alist
) ;; conses to add/replace
533 ;; initial-frame-alist needs setting only when
534 ;; frame-notice-user-settings is true
535 (and frame-notice-user-settings
536 (setq element
(assoc (car pair
) initial-frame-alist
))
537 (setq initial-frame-alist
(delq element initial-frame-alist
)))
538 (and (setq element
(assoc (car pair
) default-frame-alist
))
539 (setq default-frame-alist
(delq element default-frame-alist
)))))
540 (and frame-notice-user-settings
541 (setq initial-frame-alist
(append initial-frame-alist alist
)))
542 (setq default-frame-alist
(append default-frame-alist alist
)))
544 (defun get-other-frame ()
545 "Return some frame other than the current frame.
546 Create one if necessary. Note that the minibuffer frame, if separate,
547 is not considered (see `next-frame')."
548 (let ((s (if (equal (next-frame (selected-frame)) (selected-frame))
550 (next-frame (selected-frame)))))
553 (defun next-multiframe-window ()
554 "Select the next window, regardless of which frame it is on."
556 (select-window (next-window (selected-window)
557 (> (minibuffer-depth) 0)
559 (select-frame-set-input-focus (selected-frame)))
561 (defun previous-multiframe-window ()
562 "Select the previous window, regardless of which frame it is on."
564 (select-window (previous-window (selected-window)
565 (> (minibuffer-depth) 0)
567 (select-frame-set-input-focus (selected-frame)))
569 (defun make-frame-on-display (display &optional parameters
)
570 "Make a frame on display DISPLAY.
571 The optional second argument PARAMETERS specifies additional frame parameters."
572 (interactive "sMake frame on display: ")
573 (or (string-match "\\`[^:]*:[0-9]+\\(\\.[0-9]+\\)?\\'" display
)
574 (error "Invalid display, not HOST:SERVER or HOST:SERVER.SCREEN"))
575 (make-frame (cons (cons 'display display
) parameters
)))
577 (defun make-frame-command ()
578 "Make a new frame, and select it if the terminal displays only one frame."
580 (if (and window-system
(not (eq window-system
'pc
)))
582 (select-frame (make-frame))))
584 (defvar before-make-frame-hook nil
585 "Functions to run before a frame is created.")
587 (defvar after-make-frame-functions nil
588 "Functions to run after a frame is created.
589 The functions are run with one arg, the newly created frame.")
591 (defvar after-setting-font-hook nil
592 "Functions to run after a frame's font has been changed.")
594 ;; Alias, kept temporarily.
595 (define-obsolete-function-alias 'new-frame
'make-frame
"22.1")
597 (defun make-frame (&optional parameters
)
598 "Return a newly created frame displaying the current buffer.
599 Optional argument PARAMETERS is an alist of parameters for the new frame.
600 Each element of PARAMETERS should have the form (NAME . VALUE), for example:
602 (name . STRING) The frame should be named STRING.
604 (width . NUMBER) The frame should be NUMBER characters in width.
605 (height . NUMBER) The frame should be NUMBER text lines high.
607 You cannot specify either `width' or `height', you must use neither or both.
609 (minibuffer . t) The frame should have a minibuffer.
610 (minibuffer . nil) The frame should have no minibuffer.
611 (minibuffer . only) The frame should contain only a minibuffer.
612 (minibuffer . WINDOW) The frame should use WINDOW as its minibuffer window.
614 Before the frame is created (via `frame-creation-function'), functions on the
615 hook `before-make-frame-hook' are run. After the frame is created, functions
616 on `after-make-frame-functions' are run with one arg, the newly created frame.
618 This function itself does not make the new frame the selected frame.
619 The previously selected frame remains selected. However, the
620 window system may select the new frame for its own reasons, for
621 instance if the frame appears under the mouse pointer and your
622 setup is for focus to follow the pointer."
624 (run-hooks 'before-make-frame-hook
)
625 (let ((frame (funcall frame-creation-function parameters
)))
626 (run-hook-with-args 'after-make-frame-functions frame
)
629 (defun filtered-frame-list (predicate)
630 "Return a list of all live frames which satisfy PREDICATE."
631 (let* ((frames (frame-list))
633 (while (consp frames
)
634 (unless (funcall predicate
(car frames
))
636 (setq frames
(cdr frames
)))
639 (defun minibuffer-frame-list ()
640 "Return a list of all frames with their own minibuffers."
642 (function (lambda (frame)
643 (eq frame
(window-frame (minibuffer-window frame
)))))))
645 (defun frames-on-display-list (&optional display
)
646 "Return a list of all frames on DISPLAY.
647 DISPLAY is a name of a display, a string of the form HOST:SERVER.SCREEN.
648 If DISPLAY is omitted or nil, it defaults to the selected frame's display."
649 (let* ((display (or display
(frame-parameter nil
'display
)))
650 (func #'(lambda (frame)
651 (equal (frame-parameter frame
'display
) display
))))
652 (filtered-frame-list func
)))
654 (defun framep-on-display (&optional display
)
655 "Return the type of frames on DISPLAY.
656 DISPLAY may be a display name or a frame. If it is a frame, its type is
658 If DISPLAY is omitted or nil, it defaults to the selected frame's display.
659 All frames on a given display are of the same type."
661 (framep (car (frames-on-display-list display
)))))
663 (defun frame-remove-geometry-params (param-list)
664 "Return the parameter list PARAM-LIST, but with geometry specs removed.
665 This deletes all bindings in PARAM-LIST for `top', `left', `width',
666 `height', `user-size' and `user-position' parameters.
667 Emacs uses this to avoid overriding explicit moves and resizings from
668 the user during startup."
669 (setq param-list
(cons nil param-list
))
670 (let ((tail param-list
))
671 (while (consp (cdr tail
))
672 (if (and (consp (car (cdr tail
)))
673 (memq (car (car (cdr tail
)))
674 '(height width top left user-position user-size
)))
676 (setq frame-initial-geometry-arguments
677 (cons (car (cdr tail
)) frame-initial-geometry-arguments
))
678 (setcdr tail
(cdr (cdr tail
))))
679 (setq tail
(cdr tail
)))))
680 (setq frame-initial-geometry-arguments
681 (nreverse frame-initial-geometry-arguments
))
684 (defun select-frame-set-input-focus (frame)
685 "Select FRAME, raise it, and set input focus, if possible."
688 ;; Ensure, if possible, that frame gets input focus.
689 (cond ((memq window-system
'(x mac
))
690 (x-focus-frame frame
))
691 ((eq window-system
'w32
)
692 (w32-focus-frame frame
)))
693 (cond (focus-follows-mouse
694 (set-mouse-position (selected-frame) (1- (frame-width)) 0))))
696 (defun other-frame (arg)
697 "Select the ARGth different visible frame on current display, and raise it.
698 All frames are arranged in a cyclic order.
699 This command selects the frame ARG steps away in that order.
700 A negative ARG moves in the opposite order.
702 To make this command work properly, you must tell Emacs
703 how the system (or the window manager) generally handles
704 focus-switching between windows. If moving the mouse onto a window
705 selects it (gives it focus), set `focus-follows-mouse' to t.
706 Otherwise, that variable should be nil."
708 (let ((frame (selected-frame)))
710 (setq frame
(next-frame frame
))
711 (while (not (eq (frame-visible-p frame
) t
))
712 (setq frame
(next-frame frame
)))
715 (setq frame
(previous-frame frame
))
716 (while (not (eq (frame-visible-p frame
) t
))
717 (setq frame
(previous-frame frame
)))
719 (select-frame-set-input-focus frame
)))
721 (defun iconify-or-deiconify-frame ()
722 "Iconify the selected frame, or deiconify if it's currently an icon."
724 (if (eq (cdr (assq 'visibility
(frame-parameters))) t
)
726 (make-frame-visible)))
728 (defun make-frame-names-alist ()
729 (let* ((current-frame (selected-frame))
732 (cons (frame-parameter current-frame
'name
) current-frame
) nil
))
733 (frame (next-frame nil t
)))
734 (while (not (eq frame current-frame
))
736 (setq falist
(cons (cons (frame-parameter frame
'name
) frame
) falist
))
737 (setq frame
(next-frame frame t
))))
740 (defvar frame-name-history nil
)
741 (defun select-frame-by-name (name)
742 "Select the frame on the current terminal whose name is NAME and raise it.
743 If there is no frame by that name, signal an error."
745 (let* ((frame-names-alist (make-frame-names-alist))
746 (default (car (car frame-names-alist
)))
747 (input (completing-read
748 (format "Select Frame (default %s): " default
)
749 frame-names-alist nil t nil
'frame-name-history
)))
750 (if (= (length input
) 0)
753 (let* ((frame-names-alist (make-frame-names-alist))
754 (frame (cdr (assoc name frame-names-alist
))))
756 (error "There is no frame named `%s'" name
))
757 (make-frame-visible frame
)
760 ;; Ensure, if possible, that frame gets input focus.
761 (cond ((memq window-system
'(x mac
))
762 (x-focus-frame frame
))
763 ((eq window-system
'w32
)
764 (w32-focus-frame frame
)))
765 (when focus-follows-mouse
766 (set-mouse-position frame
(1- (frame-width frame
)) 0))))
768 ;;;; Frame configurations
770 (defun current-frame-configuration ()
771 "Return a list describing the positions and states of all frames.
772 Its car is `frame-configuration'.
773 Each element of the cdr is a list of the form (FRAME ALIST WINDOW-CONFIG),
775 FRAME is a frame object,
776 ALIST is an association list specifying some of FRAME's parameters, and
777 WINDOW-CONFIG is a window configuration object for FRAME."
778 (cons 'frame-configuration
782 (frame-parameters frame
)
783 (current-window-configuration frame
))))
786 (defun set-frame-configuration (configuration &optional nodelete
)
787 "Restore the frames to the state described by CONFIGURATION.
788 Each frame listed in CONFIGURATION has its position, size, window
789 configuration, and other parameters set as specified in CONFIGURATION.
790 However, this function does not restore deleted frames.
792 Ordinarily, this function deletes all existing frames not
793 listed in CONFIGURATION. But if optional second argument NODELETE
794 is given and non-nil, the unwanted frames are iconified instead."
795 (or (frame-configuration-p configuration
)
796 (signal 'wrong-type-argument
797 (list 'frame-configuration-p configuration
)))
798 (let ((config-alist (cdr configuration
))
802 (let ((parameters (assq frame config-alist
)))
805 (modify-frame-parameters
807 ;; Since we can't set a frame's minibuffer status,
808 ;; we might as well omit the parameter altogether.
809 (let* ((parms (nth 1 parameters
))
810 (mini (assq 'minibuffer parms
))
811 (name (assq 'name parms
))
812 (explicit-name (cdr (assq 'explicit-name parms
))))
813 (when mini
(setq parms
(delq mini parms
)))
814 ;; Leave name in iff it was set explicitly.
815 ;; This should fix the behavior reported in
816 ;; http://lists.gnu.org/archive/html/emacs-devel/2007-08/msg01632.html
817 (when (and name
(not explicit-name
))
818 (setq parms
(delq name parms
)))
820 (set-window-configuration (nth 2 parameters
)))
821 (setq frames-to-delete
(cons frame frames-to-delete
))))))
824 ;; Note: making frames invisible here was tried
825 ;; but led to some strange behavior--each time the frame
826 ;; was made visible again, the window manager asked afresh
827 ;; for where to put it.
828 (mapcar 'iconify-frame frames-to-delete
)
829 (mapcar 'delete-frame frames-to-delete
))))
831 ;;;; Convenience functions for accessing and interactively changing
832 ;;;; frame parameters.
834 (defun frame-height (&optional frame
)
835 "Return number of lines available for display on FRAME.
836 If FRAME is omitted, describe the currently selected frame."
837 (cdr (assq 'height
(frame-parameters frame
))))
839 (defun frame-width (&optional frame
)
840 "Return number of columns available for display on FRAME.
841 If FRAME is omitted, describe the currently selected frame."
842 (cdr (assq 'width
(frame-parameters frame
))))
844 (defalias 'set-default-font
'set-frame-font
)
845 (defun set-frame-font (font-name &optional keep-size
)
846 "Set the font of the selected frame to FONT-NAME.
847 When called interactively, prompt for the name of the font to use.
848 To get the frame's current default font, use `frame-parameters'.
850 The default behavior is to keep the numbers of lines and columns in
851 the frame, thus may change its pixel size. If optional KEEP-SIZE is
852 non-nil (interactively, prefix argument) the current frame size (in
853 pixels) is kept by adjusting the numbers of the lines and columns."
855 (let* ((completion-ignore-case t
)
856 (font (completing-read "Font name: "
858 ;; x-list-fonts will fail with an error
859 ;; if this frame doesn't support fonts.
860 (x-list-fonts "*" nil
(selected-frame)))
862 (frame-parameter nil
'font
))))
863 (list font current-prefix-arg
)))
866 (setq fht
(* (frame-parameter nil
'height
) (frame-char-height))
867 fwd
(* (frame-parameter nil
'width
) (frame-char-width))))
868 (modify-frame-parameters (selected-frame)
869 (list (cons 'font font-name
)))
871 (modify-frame-parameters
873 (list (cons 'height
(round fht
(frame-char-height)))
874 (cons 'width
(round fwd
(frame-char-width)))))))
875 (run-hooks 'after-setting-font-hook
'after-setting-font-hooks
))
877 (defun set-frame-parameter (frame parameter value
)
878 "Set frame parameter PARAMETER to VALUE on FRAME.
879 If FRAME is nil, it defaults to the selected frame.
880 See `modify-frame-parameters'."
881 (modify-frame-parameters frame
(list (cons parameter value
))))
883 (defun set-background-color (color-name)
884 "Set the background color of the selected frame to COLOR-NAME.
885 When called interactively, prompt for the name of the color to use.
886 To get the frame's current background color, use `frame-parameters'."
887 (interactive (list (facemenu-read-color "Background color: ")))
888 (modify-frame-parameters (selected-frame)
889 (list (cons 'background-color color-name
)))
891 (face-set-after-frame-default (selected-frame))))
893 (defun set-foreground-color (color-name)
894 "Set the foreground color of the selected frame to COLOR-NAME.
895 When called interactively, prompt for the name of the color to use.
896 To get the frame's current foreground color, use `frame-parameters'."
897 (interactive (list (facemenu-read-color "Foreground color: ")))
898 (modify-frame-parameters (selected-frame)
899 (list (cons 'foreground-color color-name
)))
901 (face-set-after-frame-default (selected-frame))))
903 (defun set-cursor-color (color-name)
904 "Set the text cursor color of the selected frame to COLOR-NAME.
905 When called interactively, prompt for the name of the color to use.
906 To get the frame's current cursor color, use `frame-parameters'."
907 (interactive (list (facemenu-read-color "Cursor color: ")))
908 (modify-frame-parameters (selected-frame)
909 (list (cons 'cursor-color color-name
))))
911 (defun set-mouse-color (color-name)
912 "Set the color of the mouse pointer of the selected frame to COLOR-NAME.
913 When called interactively, prompt for the name of the color to use.
914 To get the frame's current mouse color, use `frame-parameters'."
915 (interactive (list (facemenu-read-color "Mouse color: ")))
916 (modify-frame-parameters (selected-frame)
917 (list (cons 'mouse-color
919 (cdr (assq 'mouse-color
920 (frame-parameters))))))))
922 (defun set-border-color (color-name)
923 "Set the color of the border of the selected frame to COLOR-NAME.
924 When called interactively, prompt for the name of the color to use.
925 To get the frame's current border color, use `frame-parameters'."
926 (interactive (list (facemenu-read-color "Border color: ")))
927 (modify-frame-parameters (selected-frame)
928 (list (cons 'border-color color-name
))))
930 (defun auto-raise-mode (arg)
931 "Toggle whether or not the selected frame should auto-raise.
932 With arg, turn auto-raise mode on if and only if arg is positive.
933 Note that this controls Emacs's own auto-raise feature.
934 Some window managers allow you to enable auto-raise for certain windows.
935 You can use that for Emacs windows if you wish, but if you do,
936 that is beyond the control of Emacs and this command has no effect on it."
940 (if (cdr (assq 'auto-raise
(frame-parameters (selected-frame))))
943 (raise-frame (selected-frame)))
944 (modify-frame-parameters (selected-frame)
945 (list (cons 'auto-raise
(> arg
0)))))
947 (defun auto-lower-mode (arg)
948 "Toggle whether or not the selected frame should auto-lower.
949 With arg, turn auto-lower mode on if and only if arg is positive.
950 Note that this controls Emacs's own auto-lower feature.
951 Some window managers allow you to enable auto-lower for certain windows.
952 You can use that for Emacs windows if you wish, but if you do,
953 that is beyond the control of Emacs and this command has no effect on it."
957 (if (cdr (assq 'auto-lower
(frame-parameters (selected-frame))))
959 (modify-frame-parameters (selected-frame)
960 (list (cons 'auto-lower
(> arg
0)))))
961 (defun set-frame-name (name)
962 "Set the name of the selected frame to NAME.
963 When called interactively, prompt for the name of the frame.
964 The frame name is displayed on the modeline if the terminal displays only
965 one frame, otherwise the name is displayed on the frame's caption bar."
966 (interactive "sFrame name: ")
967 (modify-frame-parameters (selected-frame)
968 (list (cons 'name name
))))
970 (defun frame-current-scroll-bars (&optional frame
)
971 "Return the current scroll-bar settings in frame FRAME.
972 Value is a cons (VERTICAL . HORIZ0NTAL) where VERTICAL specifies the
973 current location of the vertical scroll-bars (left, right, or nil),
974 and HORIZONTAL specifies the current location of the horizontal scroll
975 bars (top, bottom, or nil)."
976 (let ((vert (frame-parameter frame
'vertical-scroll-bars
))
978 (unless (memq vert
'(left right nil
))
979 (setq vert default-frame-scroll-bars
))
982 ;;;; Frame/display capabilities.
983 (defun display-mouse-p (&optional display
)
984 "Return non-nil if DISPLAY has a mouse available.
985 DISPLAY can be a display name, a frame, or nil (meaning the selected
987 (let ((frame-type (framep-on-display display
)))
991 ((eq system-type
'windows-nt
)
993 (> w32-num-mouse-buttons
0)))
994 ((memq frame-type
'(x mac
))
995 t
) ;; We assume X and Mac *always* have a pointing device
997 (or (and (featurep 'xt-mouse
)
999 ;; t-mouse is distributed with the GPM package. It doesn't have
1001 (featurep 't-mouse
))))))
1003 (defun display-popup-menus-p (&optional display
)
1004 "Return non-nil if popup menus are supported on DISPLAY.
1005 DISPLAY can be a display name, a frame, or nil (meaning the selected
1007 Support for popup menus requires that the mouse be available."
1009 (let ((frame-type (framep-on-display display
)))
1010 (memq frame-type
'(x w32 pc mac
)))
1011 (display-mouse-p display
)))
1013 (defun display-graphic-p (&optional display
)
1014 "Return non-nil if DISPLAY is a graphic display.
1015 Graphical displays are those which are capable of displaying several
1016 frames and several different fonts at once. This is true for displays
1017 that use a window system such as X, and false for text-only terminals.
1018 DISPLAY can be a display name, a frame, or nil (meaning the selected
1020 (not (null (memq (framep-on-display display
) '(x w32 mac
)))))
1022 (defun display-images-p (&optional display
)
1023 "Return non-nil if DISPLAY can display images.
1025 DISPLAY can be a display name, a frame, or nil (meaning the selected
1027 (and (display-graphic-p display
)
1028 (fboundp 'image-mask-p
)
1029 (fboundp 'image-size
)))
1031 (defalias 'display-multi-frame-p
'display-graphic-p
)
1032 (defalias 'display-multi-font-p
'display-graphic-p
)
1034 (defun display-selections-p (&optional display
)
1035 "Return non-nil if DISPLAY supports selections.
1036 A selection is a way to transfer text or other data between programs
1037 via special system buffers called `selection' or `cut buffer' or
1039 DISPLAY can be a display name, a frame, or nil (meaning the selected
1041 (let ((frame-type (framep-on-display display
)))
1043 ((eq frame-type
'pc
)
1044 ;; MS-DOG frames support selections when Emacs runs inside
1045 ;; the Windows' DOS Box.
1047 (not (null dos-windows-version
))))
1048 ((memq frame-type
'(x w32 mac
))
1053 (defun display-screens (&optional display
)
1054 "Return the number of screens associated with DISPLAY."
1055 (let ((frame-type (framep-on-display display
)))
1057 ((memq frame-type
'(x w32 mac
))
1058 (x-display-screens display
))
1062 (defun display-pixel-height (&optional display
)
1063 "Return the height of DISPLAY's screen in pixels.
1064 For character terminals, each character counts as a single pixel."
1065 (let ((frame-type (framep-on-display display
)))
1067 ((memq frame-type
'(x w32 mac
))
1068 (x-display-pixel-height display
))
1070 (frame-height (if (framep display
) display
(selected-frame)))))))
1072 (defun display-pixel-width (&optional display
)
1073 "Return the width of DISPLAY's screen in pixels.
1074 For character terminals, each character counts as a single pixel."
1075 (let ((frame-type (framep-on-display display
)))
1077 ((memq frame-type
'(x w32 mac
))
1078 (x-display-pixel-width display
))
1080 (frame-width (if (framep display
) display
(selected-frame)))))))
1082 (defcustom display-mm-dimensions-alist nil
1083 "Alist for specifying screen dimensions in millimeters.
1084 The dimensions will be used for `display-mm-height' and
1085 `display-mm-width' if defined for the respective display.
1087 Each element of the alist has the form (display . (width . height)),
1088 e.g. (\":0.0\" . (287 . 215)).
1090 If `display' equals t, it specifies dimensions for all graphical
1091 displays not explicitely specified."
1093 :type
'(alist :key-type
(choice (string :tag
"Display name")
1094 (const :tag
"Default" t
))
1095 :value-type
(cons :tag
"Dimensions"
1096 (integer :tag
"Width")
1097 (integer :tag
"Height")))
1100 (defun display-mm-height (&optional display
)
1101 "Return the height of DISPLAY's screen in millimeters.
1102 System values can be overriden by `display-mm-dimensions-alist'.
1103 If the information is unavailable, value is nil."
1104 (and (memq (framep-on-display display
) '(x w32 mac
))
1105 (or (cddr (assoc (or display
(frame-parameter nil
'display
))
1106 display-mm-dimensions-alist
))
1107 (cddr (assoc t display-mm-dimensions-alist
))
1108 (x-display-mm-height display
))))
1110 (defun display-mm-width (&optional display
)
1111 "Return the width of DISPLAY's screen in millimeters.
1112 System values can be overriden by `display-mm-dimensions-alist'.
1113 If the information is unavailable, value is nil."
1114 (and (memq (framep-on-display display
) '(x w32 mac
))
1115 (or (cadr (assoc (or display
(frame-parameter nil
'display
))
1116 display-mm-dimensions-alist
))
1117 (cadr (assoc t display-mm-dimensions-alist
))
1118 (x-display-mm-width display
))))
1120 (defun display-backing-store (&optional display
)
1121 "Return the backing store capability of DISPLAY's screen.
1122 The value may be `always', `when-mapped', `not-useful', or nil if
1123 the question is inapplicable to a certain kind of display."
1124 (let ((frame-type (framep-on-display display
)))
1126 ((memq frame-type
'(x w32 mac
))
1127 (x-display-backing-store display
))
1131 (defun display-save-under (&optional display
)
1132 "Return non-nil if DISPLAY's screen supports the SaveUnder feature."
1133 (let ((frame-type (framep-on-display display
)))
1135 ((memq frame-type
'(x w32 mac
))
1136 (x-display-save-under display
))
1140 (defun display-planes (&optional display
)
1141 "Return the number of planes supported by DISPLAY."
1142 (let ((frame-type (framep-on-display display
)))
1144 ((memq frame-type
'(x w32 mac
))
1145 (x-display-planes display
))
1146 ((eq frame-type
'pc
)
1149 (truncate (log (length (tty-color-alist)) 2))))))
1151 (defun display-color-cells (&optional display
)
1152 "Return the number of color cells supported by DISPLAY."
1153 (let ((frame-type (framep-on-display display
)))
1155 ((memq frame-type
'(x w32 mac
))
1156 (x-display-color-cells display
))
1157 ((eq frame-type
'pc
)
1160 (tty-display-color-cells)))))
1162 (defun display-visual-class (&optional display
)
1163 "Returns the visual class of DISPLAY.
1164 The value is one of the symbols `static-gray', `gray-scale',
1165 `static-color', `pseudo-color', `true-color', or `direct-color'."
1166 (let ((frame-type (framep-on-display display
)))
1168 ((memq frame-type
'(x w32 mac
))
1169 (x-display-visual-class display
))
1170 ((and (memq frame-type
'(pc t
))
1171 (tty-display-color-p display
))
1177 ;;;; Aliases for backward compatibility with Emacs 18.
1178 (define-obsolete-function-alias 'screen-height
'frame-height
) ;before 19.15
1179 (define-obsolete-function-alias 'screen-width
'frame-width
) ;before 19.15
1181 (defun set-screen-width (cols &optional pretend
)
1182 "Change the size of the screen to COLS columns.
1183 Optional second arg non-nil means that redisplay should use COLS columns
1184 but that the idea of the actual width of the frame should not be changed.
1185 This function is provided only for compatibility with Emacs 18."
1186 (set-frame-width (selected-frame) cols pretend
))
1188 (defun set-screen-height (lines &optional pretend
)
1189 "Change the height of the screen to LINES lines.
1190 Optional second arg non-nil means that redisplay should use LINES lines
1191 but that the idea of the actual height of the screen should not be changed.
1192 This function is provided only for compatibility with Emacs 18."
1193 (set-frame-height (selected-frame) lines pretend
))
1195 (defun delete-other-frames (&optional frame
)
1196 "Delete all frames except FRAME.
1197 If FRAME uses another frame's minibuffer, the minibuffer frame is
1198 left untouched. FRAME nil or omitted means use the selected frame."
1201 (setq frame
(selected-frame)))
1202 (let* ((mini-frame (window-frame (minibuffer-window frame
)))
1203 (frames (delq mini-frame
(delq frame
(frame-list)))))
1204 ;; Delete mon-minibuffer-only frames first, because `delete-frame'
1205 ;; signals an error when trying to delete a mini-frame that's
1206 ;; still in use by another frame.
1207 (dolist (frame frames
)
1208 (unless (eq (frame-parameter frame
'minibuffer
) 'only
)
1209 (delete-frame frame
)))
1210 ;; Delete minibuffer-only frames.
1211 (dolist (frame frames
)
1212 (when (eq (frame-parameter frame
'minibuffer
) 'only
)
1213 (delete-frame frame
)))))
1215 (make-obsolete 'set-screen-width
'set-frame-width
) ;before 19.15
1216 (make-obsolete 'set-screen-height
'set-frame-height
) ;before 19.15
1218 ;; miscellaneous obsolescence declarations
1219 (define-obsolete-variable-alias 'delete-frame-hook
1220 'delete-frame-functions
"22.1")
1223 ;; Highlighting trailing whitespace.
1225 (make-variable-buffer-local 'show-trailing-whitespace
)
1227 (defcustom show-trailing-whitespace nil
1228 "*Non-nil means highlight trailing whitespace.
1229 This is done in the face `trailing-whitespace'."
1231 :group
'whitespace-faces
)
1237 (defgroup scrolling nil
1238 "Scrolling windows."
1242 (defcustom auto-hscroll-mode t
1243 "*Allow or disallow automatic scrolling windows horizontally.
1244 If non-nil, windows are automatically scrolled horizontally to make
1249 (defvaralias 'automatic-hscrolling
'auto-hscroll-mode
)
1254 (defgroup cursor nil
1255 "Displaying text cursors."
1259 (defcustom blink-cursor-delay
0.5
1260 "*Seconds of idle time after which cursor starts to blink."
1264 (defcustom blink-cursor-interval
0.5
1265 "*Length of cursor blink interval in seconds."
1269 (defvar blink-cursor-idle-timer nil
1270 "Timer started after `blink-cursor-delay' seconds of Emacs idle time.
1271 The function `blink-cursor-start' is called when the timer fires.")
1273 (defvar blink-cursor-timer nil
1274 "Timer started from `blink-cursor-start'.
1275 This timer calls `blink-cursor-timer-function' every
1276 `blink-cursor-interval' seconds.")
1278 (defun blink-cursor-start ()
1279 "Timer function called from the timer `blink-cursor-idle-timer'.
1280 This starts the timer `blink-cursor-timer', which makes the cursor blink
1281 if appropriate. It also arranges to cancel that timer when the next
1282 command starts, by installing a pre-command hook."
1283 (when (null blink-cursor-timer
)
1284 ;; Set up the timer first, so that if this signals an error,
1285 ;; blink-cursor-end is not added to pre-command-hook.
1286 (setq blink-cursor-timer
1287 (run-with-timer blink-cursor-interval blink-cursor-interval
1288 'blink-cursor-timer-function
))
1289 (add-hook 'pre-command-hook
'blink-cursor-end
)
1290 (internal-show-cursor nil nil
)))
1292 (defun blink-cursor-timer-function ()
1293 "Timer function of timer `blink-cursor-timer'."
1294 (internal-show-cursor nil
(not (internal-show-cursor-p))))
1296 (defun blink-cursor-end ()
1297 "Stop cursor blinking.
1298 This is installed as a pre-command hook by `blink-cursor-start'.
1299 When run, it cancels the timer `blink-cursor-timer' and removes
1300 itself as a pre-command hook."
1301 (remove-hook 'pre-command-hook
'blink-cursor-end
)
1302 (internal-show-cursor nil t
)
1303 (when blink-cursor-timer
1304 (cancel-timer blink-cursor-timer
)
1305 (setq blink-cursor-timer nil
)))
1307 (define-minor-mode blink-cursor-mode
1308 "Toggle blinking cursor mode.
1309 With a numeric argument, turn blinking cursor mode on if ARG is positive,
1310 otherwise turn it off. When blinking cursor mode is enabled, the
1311 cursor of the selected window blinks.
1313 Note that this command is effective only when Emacs
1314 displays through a window system, because then Emacs does its own
1315 cursor display. On a text-only terminal, this is not implemented."
1316 :init-value
(not (or noninteractive
1318 (eq system-type
'ms-dos
)
1319 (not (memq window-system
'(x w32 mac
)))))
1320 :initialize
'custom-initialize-safe-default
1323 (if blink-cursor-idle-timer
(cancel-timer blink-cursor-idle-timer
))
1324 (setq blink-cursor-idle-timer nil
)
1326 (when blink-cursor-mode
1328 ;;(internal-show-cursor nil nil)
1329 (setq blink-cursor-idle-timer
1330 (run-with-idle-timer blink-cursor-delay
1332 'blink-cursor-start
))))
1334 (define-obsolete-variable-alias 'blink-cursor
'blink-cursor-mode
"22.1")
1336 ;; Hourglass pointer
1338 (defcustom display-hourglass t
1339 "*Non-nil means show an hourglass pointer, when Emacs is busy.
1340 This feature only works when on a window system that can change
1345 (defcustom hourglass-delay
1
1346 "*Seconds to wait before displaying an hourglass pointer when Emacs is busy."
1351 (defcustom cursor-in-non-selected-windows t
1352 "*Non-nil means show a hollow box cursor in non-selected windows.
1353 If nil, don't show a cursor except in the selected window.
1354 If t, display a cursor related to the usual cursor type
1355 \(a solid box becomes hollow, a bar becomes a narrower bar).
1356 You can also specify the cursor type as in the `cursor-type' variable.
1357 Use Custom to set this variable to get the display updated."
1358 :tag
"Cursor In Non-selected Windows"
1361 :set
#'(lambda (symbol value
)
1362 (set-default symbol value
)
1363 (force-mode-line-update t
)))
1368 (define-key ctl-x-5-map
"2" 'make-frame-command
)
1369 (define-key ctl-x-5-map
"1" 'delete-other-frames
)
1370 (define-key ctl-x-5-map
"0" 'delete-frame
)
1371 (define-key ctl-x-5-map
"o" 'other-frame
)
1375 ;; arch-tag: 82979c70-b8f2-4306-b2ad-ddbd6b328b56
1376 ;;; frame.el ends here