1 ;;; frame.el --- multi-frame management independent of window systems
3 ;; Copyright (C) 1993, 1994, 1996, 1997, 2000, 2001, 2003
4 ;; 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 2, 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., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
30 (defvar frame-creation-function-alist
32 (if (fboundp 'tty-create-frame-with-faces)
33 'tty-create-frame-with-faces
36 (error "Can't create multiple frames without a window system"))))))
37 "Alist of window-system dependent functions to call to create a new frame.
38 The window system startup file should add its frame creation
39 function to this list, which should take an alist of parameters
42 ;; The initial value given here used to ask for a minibuffer.
43 ;; But that's not necessary, because the default is to have one.
44 ;; By not specifying it here, we let an X resource specify it.
45 (defcustom initial-frame-alist nil
46 "*Alist of frame parameters for creating the initial X window frame.
47 You can set this in your `.emacs' file; for example,
48 (setq initial-frame-alist '((top . 1) (left . 1) (width . 80) (height . 55)))
49 Parameters specified here supersede the values given in `default-frame-alist'.
51 If the value calls for a frame without a minibuffer, and you have not created
52 a minibuffer frame on your own, one is created according to
53 `minibuffer-frame-alist'.
55 You can specify geometry-related options for just the initial frame
56 by setting this variable in your `.emacs' file; however, they won't
57 take effect until Emacs reads `.emacs', which happens after first creating
58 the frame. If you want the frame to have the proper geometry as soon
59 as it appears, you need to use this three-step process:
60 * Specify X resources to give the geometry you want.
61 * Set `default-frame-alist' to override these options so that they
62 don't affect subsequent frames.
63 * Set `initial-frame-alist' in a way that matches the X resources,
64 to override what you put in `default-frame-alist'."
65 :type '(repeat (cons :format "%v"
66 (symbol :tag "Parameter")
70 (defcustom minibuffer-frame-alist '((width . 80) (height . 2))
71 "*Alist of frame parameters for initially creating a minibuffer frame.
72 You can set this in your `.emacs' file; for example,
73 (setq minibuffer-frame-alist
74 '((top . 1) (left . 1) (width . 80) (height . 2)))
75 Parameters specified here supersede the values given in
76 `default-frame-alist', for a minibuffer frame."
77 :type '(repeat (cons :format "%v"
78 (symbol :tag "Parameter")
82 (defcustom pop-up-frame-alist nil
83 "*Alist of frame parameters used when creating pop-up frames.
84 Pop-up frames are used for completions, help, and the like.
85 This variable can be set in your init file, like this:
86 (setq pop-up-frame-alist '((width . 80) (height . 20)))
87 These supersede the values given in `default-frame-alist',
89 :type '(repeat (cons :format "%v"
90 (symbol :tag "Parameter")
94 (setq pop-up-frame-function
95 ;; Using `function' here caused some sort of problem.
97 (make-frame pop-up-frame-alist)))
99 (defcustom special-display-frame-alist
100 '((height . 14) (width . 80) (unsplittable . t))
101 "*Alist of frame parameters used when creating special frames.
102 Special frames are used for buffers whose names are in
103 `special-display-buffer-names' and for buffers whose names match
104 one of the regular expressions in `special-display-regexps'.
105 This variable can be set in your init file, like this:
106 (setq special-display-frame-alist '((width . 80) (height . 20)))
107 These supersede the values given in `default-frame-alist'."
108 :type '(repeat (cons :format "%v"
109 (symbol :tag "Parameter")
110 (sexp :tag "Value")))
113 (defun special-display-popup-frame (buffer &optional args)
114 "Display BUFFER in its own frame, reusing an existing window if any.
115 Return the window chosen.
116 Currently we do not insist on selecting the window within its frame.
117 If ARGS is an alist, use it as a list of frame parameter specs.
118 If ARGS is a list whose car is a symbol,
119 use (car ARGS) as a function to do the work.
120 Pass it BUFFER as first arg, and (cdr ARGS) gives the rest of the args."
121 (if (and args (symbolp (car args)))
122 (apply (car args) buffer (cdr args))
123 (let ((window (get-buffer-window buffer t)))
125 ;; If we have a window already, make it visible.
127 (let ((frame (window-frame window)))
128 (make-frame-visible frame)
131 ;; Reuse the current window if the user requested it.
132 (when (cdr (assq 'same-window args))
134 (progn (switch-to-buffer buffer) (selected-window))
136 ;; Stay on the same frame if requested.
137 (when (or (cdr (assq 'same-frame args)) (cdr (assq 'same-window args)))
138 (let* ((pop-up-frames nil) (pop-up-windows t)
139 special-display-regexps special-display-buffer-names
140 (window (display-buffer buffer)))
141 ;; (set-window-dedicated-p window t)
143 ;; If no window yet, make one in a new frame.
144 (let ((frame (make-frame (append args special-display-frame-alist))))
145 (set-window-buffer (frame-selected-window frame) buffer)
146 (set-window-dedicated-p (frame-selected-window frame) t)
147 (frame-selected-window frame))))))
149 (defun handle-delete-frame (event)
150 "Handle delete-frame events from the X server."
152 (let ((frame (posn-window (event-start event)))
156 (and (frame-visible-p (car tail))
157 (not (eq (car tail) frame))
159 (setq tail (cdr tail)))
161 (delete-frame frame t)
162 ;; Gildea@x.org says it is ok to ask questions before terminating.
163 (save-buffers-kill-emacs))))
165 ;;;; Arrangement of frames at startup
167 ;; 1) Load the window system startup file from the lisp library and read the
168 ;; high-priority arguments (-q and the like). The window system startup
169 ;; file should create any frames specified in the window system defaults.
171 ;; 2) If no frames have been opened, we open an initial text frame.
173 ;; 3) Once the init file is done, we apply any newly set parameters
174 ;; in initial-frame-alist to the frame.
176 ;; These are now called explicitly at the proper times,
177 ;; since that is easier to understand.
178 ;; Actually using hooks within Emacs is bad for future maintenance. --rms.
179 ;; (add-hook 'before-init-hook 'frame-initialize)
180 ;; (add-hook 'window-setup-hook 'frame-notice-user-settings)
182 ;; If we create the initial frame, this is it.
183 (defvar frame-initial-frame nil)
185 ;; Record the parameters used in frame-initialize to make the initial frame.
186 (defvar frame-initial-frame-alist)
188 (defvar frame-initial-geometry-arguments nil)
190 ;; startup.el calls this function before loading the user's init
191 ;; file - if there is no frame with a minibuffer open now, create
192 ;; one to display messages while loading the init file.
193 (defun frame-initialize ()
194 "Create an initial frame if necessary."
195 ;; Are we actually running under a window system at all?
196 (if (and initial-window-system
198 (not (eq initial-window-system 'pc)))
200 ;; Turn on special-display processing only if there's a window system.
201 (setq special-display-function 'special-display-popup-frame)
203 ;; If there is no frame with a minibuffer besides the terminal
204 ;; frame, then we need to create the opening frame. Make sure
205 ;; it has a minibuffer, but let initial-frame-alist omit the
207 (or (delq terminal-frame (minibuffer-frame-list))
209 (setq frame-initial-frame-alist
210 (append initial-frame-alist default-frame-alist nil))
211 (or (assq 'horizontal-scroll-bars frame-initial-frame-alist)
212 (setq frame-initial-frame-alist
213 (cons '(horizontal-scroll-bars . t)
214 frame-initial-frame-alist)))
215 (setq frame-initial-frame-alist
216 (cons (cons 'window-system initial-window-system)
217 frame-initial-frame-alist))
218 (setq default-minibuffer-frame
219 (setq frame-initial-frame
220 (make-frame frame-initial-frame-alist)))
221 ;; Delete any specifications for window geometry parameters
222 ;; so that we won't reapply them in frame-notice-user-settings.
223 ;; It would be wrong to reapply them then,
224 ;; because that would override explicit user resizing.
225 (setq initial-frame-alist
226 (frame-remove-geometry-params initial-frame-alist))))
227 ;; At this point, we know that we have a frame open, so we
228 ;; can delete the terminal frame.
229 (delete-frame terminal-frame)
230 (setq terminal-frame nil))))
232 (defvar frame-notice-user-settings t
233 "Non-nil means function `frame-notice-user-settings' wasn't run yet.")
235 ;; startup.el calls this function after loading the user's init
236 ;; file. Now default-frame-alist and initial-frame-alist contain
237 ;; information to which we must react; do what needs to be done.
238 (defun frame-notice-user-settings ()
239 "Act on user's init file settings of frame parameters.
240 React to settings of `default-frame-alist', `initial-frame-alist' there."
241 ;; Make menu-bar-mode and default-frame-alist consistent.
242 (when (boundp 'menu-bar-mode)
243 (let ((default (assq 'menu-bar-lines default-frame-alist)))
245 (setq menu-bar-mode (not (eq (cdr default) 0)))
246 (setq default-frame-alist
247 (cons (cons 'menu-bar-lines (if menu-bar-mode 1 0))
248 default-frame-alist)))))
250 ;; Make tool-bar-mode and default-frame-alist consistent. Don't do
251 ;; it in batch mode since that would leave a tool-bar-lines
252 ;; parameter in default-frame-alist in a dumped Emacs, which is not
254 (when (and (boundp 'tool-bar-mode)
255 (not noninteractive))
256 (let ((default (assq 'tool-bar-lines default-frame-alist)))
258 (setq tool-bar-mode (not (eq (cdr default) 0)))
259 (setq default-frame-alist
260 (cons (cons 'tool-bar-lines (if tool-bar-mode 1 0))
261 default-frame-alist)))))
263 ;; Creating and deleting frames may shift the selected frame around,
264 ;; and thus the current buffer. Protect against that. We don't
265 ;; want to use save-excursion here, because that may also try to set
266 ;; the buffer of the selected window, which fails when the selected
267 ;; window is the minibuffer.
268 (let ((old-buffer (current-buffer)))
270 (when (and frame-notice-user-settings
271 (null frame-initial-frame))
272 ;; This case happens when we don't have a window system, and
273 ;; also for MS-DOS frames.
274 (let ((parms (frame-parameters frame-initial-frame)))
275 ;; Don't change the frame names.
276 (setq parms (delq (assq 'name parms) parms))
277 ;; Can't modify the minibuffer parameter, so don't try.
278 (setq parms (delq (assq 'minibuffer parms) parms))
279 (modify-frame-parameters nil
280 (if (null initial-window-system)
281 (append initial-frame-alist
285 ;; initial-frame-alist and
286 ;; default-frame-alist were already
287 ;; applied in pc-win.el.
289 (if (null initial-window-system) ;; MS-DOS does this differently in pc-win.el
290 (let ((newparms (frame-parameters))
291 (frame (selected-frame)))
292 (tty-handle-reverse-video frame newparms)
293 ;; If we changed the background color, we need to update
294 ;; the background-mode parameter, and maybe some faces,
296 (when (assq 'background-color newparms)
297 (unless (or (assq 'background-mode initial-frame-alist)
298 (assq 'background-mode default-frame-alist))
299 (frame-set-background-mode frame))
300 (face-set-after-frame-default frame))))))
302 ;; If the initial frame is still around, apply initial-frame-alist
303 ;; and default-frame-alist to it.
304 (when (frame-live-p frame-initial-frame)
306 ;; When tool-bar has been switched off, correct the frame size
307 ;; by the lines added in x-create-frame for the tool-bar and
308 ;; switch `tool-bar-mode' off.
309 (when (display-graphic-p)
310 (let ((tool-bar-lines (or (assq 'tool-bar-lines initial-frame-alist)
311 (assq 'tool-bar-lines default-frame-alist))))
312 (when (and tool-bar-originally-present
313 (or (null tool-bar-lines)
314 (null (cdr tool-bar-lines))
315 (eq 0 (cdr tool-bar-lines))))
316 (let* ((char-height (frame-char-height frame-initial-frame))
317 (image-height tool-bar-images-pixel-height)
318 (margin (cond ((and (consp tool-bar-button-margin)
319 (integerp (cdr tool-bar-button-margin))
320 (> tool-bar-button-margin 0))
321 (cdr tool-bar-button-margin))
322 ((and (integerp tool-bar-button-margin)
323 (> tool-bar-button-margin 0))
324 tool-bar-button-margin)
326 (relief (if (and (integerp tool-bar-button-relief)
327 (> tool-bar-button-relief 0))
328 tool-bar-button-relief 3))
329 (lines (/ (+ image-height
334 (height (frame-parameter frame-initial-frame 'height))
335 (newparms (list (cons 'height (- height lines))))
336 (initial-top (cdr (assq 'top
337 frame-initial-geometry-arguments)))
338 (top (frame-parameter frame-initial-frame 'top)))
339 (when (and (consp initial-top) (eq '- (car initial-top)))
341 (cond ((and (consp top)
345 (* lines char-height))))
350 (* lines char-height))))
351 (t (+ top (* lines char-height))))))
354 `((top . ,adjusted-top))
356 (modify-frame-parameters frame-initial-frame newparms)
357 (tool-bar-mode -1)))))
359 ;; The initial frame we create above always has a minibuffer.
360 ;; If the user wants to remove it, or make it a minibuffer-only
361 ;; frame, then we'll have to delete the current frame and make a
362 ;; new one; you can't remove or add a root window to/from an
365 ;; NOTE: default-frame-alist was nil when we created the
366 ;; existing frame. We need to explicitly include
367 ;; default-frame-alist in the parameters of the screen we
368 ;; create here, so that its new value, gleaned from the user's
369 ;; .emacs file, will be applied to the existing screen.
370 (if (not (eq (cdr (or (assq 'minibuffer initial-frame-alist)
371 (assq 'minibuffer default-frame-alist)
374 ;; Create the new frame.
376 ;; If the frame isn't visible yet, wait till it is.
377 ;; If the user has to position the window,
378 ;; Emacs doesn't know its real position until
379 ;; the frame is seen to be visible.
380 (while (not (cdr (assq 'visibility
381 (frame-parameters frame-initial-frame))))
383 (setq parms (frame-parameters frame-initial-frame))
385 ;; Get rid of `name' unless it was specified explicitly before.
386 (or (assq 'name frame-initial-frame-alist)
387 (setq parms (delq (assq 'name parms) parms)))
389 (setq parms (append initial-frame-alist
394 ;; Get rid of `reverse', because that was handled
395 ;; when we first made the frame.
396 (setq parms (cons '(reverse) (delq (assq 'reverse parms) parms)))
398 (if (assq 'height frame-initial-geometry-arguments)
399 (setq parms (assq-delete-all 'height parms)))
400 (if (assq 'width frame-initial-geometry-arguments)
401 (setq parms (assq-delete-all 'width parms)))
402 (if (assq 'left frame-initial-geometry-arguments)
403 (setq parms (assq-delete-all 'left parms)))
404 (if (assq 'top frame-initial-geometry-arguments)
405 (setq parms (assq-delete-all 'top parms)))
408 ;; Use the geometry args that created the existing
409 ;; frame, rather than the parms we get for it.
410 (append frame-initial-geometry-arguments
411 '((user-size . t) (user-position . t))
413 ;; The initial frame, which we are about to delete, may be
414 ;; the only frame with a minibuffer. If it is, create a
416 (or (delq frame-initial-frame (minibuffer-frame-list))
417 (make-initial-minibuffer-frame nil))
419 ;; If the initial frame is serving as a surrogate
420 ;; minibuffer frame for any frames, we need to wean them
421 ;; onto a new frame. The default-minibuffer-frame
422 ;; variable must be handled similarly.
423 (let ((users-of-initial
425 (function (lambda (frame)
426 (and (not (eq frame frame-initial-frame))
428 (minibuffer-window frame))
429 frame-initial-frame)))))))
430 (if (or users-of-initial
431 (eq default-minibuffer-frame frame-initial-frame))
433 ;; Choose an appropriate frame. Prefer frames which
434 ;; are only minibuffers.
435 (let* ((new-surrogate
437 (or (filtered-frame-list
440 (eq (cdr (assq 'minibuffer
441 (frame-parameters frame)))
443 (minibuffer-frame-list))))
444 (new-minibuffer (minibuffer-window new-surrogate)))
446 (if (eq default-minibuffer-frame frame-initial-frame)
447 (setq default-minibuffer-frame new-surrogate))
449 ;; Wean the frames using frame-initial-frame as
450 ;; their minibuffer frame.
454 (modify-frame-parameters
455 frame (list (cons 'minibuffer new-minibuffer)))))
458 ;; Redirect events enqueued at this frame to the new frame.
459 ;; Is this a good idea?
460 (redirect-frame-focus frame-initial-frame new)
462 ;; Finally, get rid of the old frame.
463 (delete-frame frame-initial-frame t))
465 ;; Otherwise, we don't need all that rigamarole; just apply
466 ;; the new parameters.
467 (let (newparms allparms tail)
468 (setq allparms (append initial-frame-alist
469 default-frame-alist nil))
470 (if (assq 'height frame-initial-geometry-arguments)
471 (setq allparms (assq-delete-all 'height allparms)))
472 (if (assq 'width frame-initial-geometry-arguments)
473 (setq allparms (assq-delete-all 'width allparms)))
474 (if (assq 'left frame-initial-geometry-arguments)
475 (setq allparms (assq-delete-all 'left allparms)))
476 (if (assq 'top frame-initial-geometry-arguments)
477 (setq allparms (assq-delete-all 'top allparms)))
479 ;; Find just the parms that have changed since we first
480 ;; made this frame. Those are the ones actually set by
481 ;; the init file. For those parms whose values we already knew
482 ;; (such as those spec'd by command line options)
483 ;; it is undesirable to specify the parm again
484 ;; once the user has seen the frame and been able to alter it
488 (setq oldval (assq (car (car tail))
489 frame-initial-frame-alist))
490 (setq newval (cdr (assq (car (car tail)) allparms)))
491 (or (and oldval (eq (cdr oldval) newval))
493 (cons (cons (car (car tail)) newval) newparms))))
494 (setq tail (cdr tail)))
495 (setq newparms (nreverse newparms))
496 (modify-frame-parameters frame-initial-frame
498 ;; If we changed the background color,
499 ;; we need to update the background-mode parameter
500 ;; and maybe some faces too.
501 (when (assq 'background-color newparms)
502 (unless (assq 'background-mode newparms)
503 (frame-set-background-mode frame-initial-frame))
504 (face-set-after-frame-default frame-initial-frame)))))
506 ;; Restore the original buffer.
507 (set-buffer old-buffer)
509 ;; Make sure the initial frame can be GC'd if it is ever deleted.
510 ;; Make sure frame-notice-user-settings does nothing if called twice.
511 (setq frame-notice-user-settings nil)
512 (setq frame-initial-frame nil)))
514 (defun make-initial-minibuffer-frame (display)
515 (let ((parms (append minibuffer-frame-alist '((minibuffer . only)))))
517 (make-frame-on-display display parms)
518 (make-frame parms))))
520 ;;;; Creation of additional frames, and other frame miscellanea
522 (defun modify-all-frames-parameters (alist)
523 "modify all current and future frames parameters according to ALIST.
524 This changes `default-frame-alist' and possibly `initial-frame-alist'.
525 See help of `modify-frame-parameters' for more information."
526 (let (element) ;; temp
527 (dolist (frame (frame-list))
528 (modify-frame-parameters frame alist))
530 (dolist (pair alist) ;; conses to add/replace
531 ;; initial-frame-alist needs setting only when
532 ;; frame-notice-user-settings is true
533 (and frame-notice-user-settings
534 (setq element (assoc (car pair) initial-frame-alist))
535 (setq initial-frame-alist (delq element initial-frame-alist)))
536 (and (setq element (assoc (car pair) default-frame-alist))
537 (setq default-frame-alist (delq element default-frame-alist)))))
538 (and frame-notice-user-settings
539 (setq initial-frame-alist (append initial-frame-alist alist)))
540 (setq default-frame-alist (append default-frame-alist alist)))
542 (defun get-other-frame ()
543 "Return some frame other than the current frame.
544 Create one if necessary. Note that the minibuffer frame, if separate,
545 is not considered (see `next-frame')."
546 (let ((s (if (equal (next-frame (selected-frame)) (selected-frame))
548 (next-frame (selected-frame)))))
551 (defun next-multiframe-window ()
552 "Select the next window, regardless of which frame it is on."
554 (select-window (next-window (selected-window)
555 (> (minibuffer-depth) 0)
557 (select-frame-set-input-focus (selected-frame)))
559 (defun previous-multiframe-window ()
560 "Select the previous window, regardless of which frame it is on."
562 (select-window (previous-window (selected-window)
563 (> (minibuffer-depth) 0)
565 (select-frame-set-input-focus (selected-frame)))
567 (defun make-frame-on-display (display &optional parameters)
568 "Make a frame on display DISPLAY.
569 The optional second argument PARAMETERS specifies additional frame parameters."
570 (interactive "sMake frame on display: ")
571 (or (string-match "\\`[^:]*:[0-9]+\\(\\.[0-9]+\\)?\\'" display)
572 (error "Invalid display, not HOST:SERVER or HOST:SERVER.SCREEN"))
573 (unless x-initialized
574 (setq x-display-name display)
575 (x-initialize-window-system))
576 (make-frame `((window-system . x) (display . ,display) . ,parameters)))
578 (defun make-frame-on-tty (device type &optional parameters)
579 "Make a frame on terminal DEVICE which is of type TYPE (e.g., \"xterm\").
580 The optional third argument PARAMETERS specifies additional frame parameters."
581 (interactive "fOpen frame on tty device: \nsTerminal type of %s: ")
583 (error "Invalid terminal device"))
585 (error "Invalid terminal type"))
586 (make-frame `((window-system . nil) (tty . ,device) (tty-type . ,type) . ,parameters)))
588 (defun make-frame-command ()
589 "Make a new frame, and select it if the terminal displays only one frame."
591 (if (and window-system (not (eq window-system 'pc)))
593 (select-frame (make-frame))))
595 (defvar before-make-frame-hook nil
596 "Functions to run before a frame is created.")
598 (defvar after-make-frame-functions nil
599 "Functions to run after a frame is created.
600 The functions are run with one arg, the newly created frame.")
602 (defvar after-setting-font-hook nil
603 "Functions to run after a frame's font has been changed.")
605 ;; Alias, kept temporarily.
606 (defalias 'new-frame 'make-frame)
607 (make-obsolete 'new-frame 'make-frame "21.4")
609 (defun make-frame (&optional parameters)
610 "Return a newly created frame displaying the current buffer.
611 Optional argument PARAMETERS is an alist of parameters for the new frame.
612 Each element of PARAMETERS should have the form (NAME . VALUE), for example:
614 (name . STRING) The frame should be named STRING.
616 (width . NUMBER) The frame should be NUMBER characters in width.
617 (height . NUMBER) The frame should be NUMBER text lines high.
619 You cannot specify either `width' or `height', you must use neither or both.
621 (minibuffer . t) The frame should have a minibuffer.
622 (minibuffer . nil) The frame should have no minibuffer.
623 (minibuffer . only) The frame should contain only a minibuffer.
624 (minibuffer . WINDOW) The frame should use WINDOW as its minibuffer window.
626 (window-system . nil) The frame should be displayed on a terminal device.
627 (window-system . x) The frame should be displayed in an X window.
629 Before the frame is created (via `frame-creation-function-alist'), functions on the
630 hook `before-make-frame-hook' are run. After the frame is created, functions
631 on `after-make-frame-functions' are run with one arg, the newly created frame."
633 (let* ((w (if (assq 'window-system parameters)
634 (cdr (assq 'window-system parameters))
636 (frame-creation-function (cdr (assq w frame-creation-function-alist)))
638 (unless frame-creation-function
639 (error "Don't know how to create a frame on window system %s" w))
640 (run-hooks 'before-make-frame-hook)
641 (setq frame (funcall frame-creation-function parameters))
642 (run-hook-with-args 'after-make-frame-functions frame)
645 (defun filtered-frame-list (predicate)
646 "Return a list of all live frames which satisfy PREDICATE."
647 (let* ((frames (frame-list))
649 (while (consp frames)
650 (unless (funcall predicate (car frames))
652 (setq frames (cdr frames)))
655 (defun minibuffer-frame-list ()
656 "Return a list of all frames with their own minibuffers."
658 (function (lambda (frame)
659 (eq frame (window-frame (minibuffer-window frame)))))))
661 (defun frames-on-display-list (&optional display)
662 "Return a list of all frames on DISPLAY.
663 DISPLAY is a name of a display, a string of the form HOST:SERVER.SCREEN.
664 If DISPLAY is omitted or nil, it defaults to the selected frame's display."
665 (let* ((display (or display (frame-parameter nil 'display)))
666 (func #'(lambda (frame)
667 (equal (frame-parameter frame 'display) display))))
668 (filtered-frame-list func)))
670 (defun framep-on-display (&optional display)
671 "Return the type of frames on DISPLAY.
672 DISPLAY may be a display name or a frame. If it is a frame, its type is
674 If DISPLAY is omitted or nil, it defaults to the selected frame's display.
675 All frames on a given display are of the same type."
677 (framep (car (frames-on-display-list display)))))
679 (defun frame-remove-geometry-params (param-list)
680 "Return the parameter list PARAM-LIST, but with geometry specs removed.
681 This deletes all bindings in PARAM-LIST for `top', `left', `width',
682 `height', `user-size' and `user-position' parameters.
683 Emacs uses this to avoid overriding explicit moves and resizings from
684 the user during startup."
685 (setq param-list (cons nil param-list))
686 (let ((tail param-list))
687 (while (consp (cdr tail))
688 (if (and (consp (car (cdr tail)))
689 (memq (car (car (cdr tail)))
690 '(height width top left user-position user-size)))
692 (setq frame-initial-geometry-arguments
693 (cons (car (cdr tail)) frame-initial-geometry-arguments))
694 (setcdr tail (cdr (cdr tail))))
695 (setq tail (cdr tail)))))
696 (setq frame-initial-geometry-arguments
697 (nreverse frame-initial-geometry-arguments))
700 (defcustom focus-follows-mouse t
701 "*Non-nil if window system changes focus when you move the mouse.
702 You should set this variable to tell Emacs how your window manager
703 handles focus, since there is no way in general for Emacs to find out
709 (defun select-frame-set-input-focus (frame)
710 "Select FRAME, raise it, and set input focus, if possible."
713 ;; Ensure, if possible, that frame gets input focus.
714 (cond ((eq (window-system frame) 'x)
715 (x-focus-frame frame))
716 ((eq (window-system frame) 'w32)
717 (w32-focus-frame frame)))
718 (cond (focus-follows-mouse
719 (set-mouse-position (selected-frame) (1- (frame-width)) 0))))
721 (defun other-frame (arg)
722 "Select the ARG'th different visible frame on current display, and raise it.
723 All frames are arranged in a cyclic order.
724 This command selects the frame ARG steps away in that order.
725 A negative ARG moves in the opposite order.
727 To make this command work properly, you must tell Emacs
728 how the system (or the window manager) generally handles
729 focus-switching between windows. If moving the mouse onto a window
730 selects it (gives it focus), set `focus-follows-mouse' to t.
731 Otherwise, that variable should be nil."
733 (let ((frame (selected-frame)))
735 (setq frame (next-frame frame))
736 (while (not (eq (frame-visible-p frame) t))
737 (setq frame (next-frame frame)))
740 (setq frame (previous-frame frame))
741 (while (not (eq (frame-visible-p frame) t))
742 (setq frame (previous-frame frame)))
744 (select-frame-set-input-focus frame)))
746 (defun iconify-or-deiconify-frame ()
747 "Iconify the selected frame, or deiconify if it's currently an icon."
749 (if (eq (cdr (assq 'visibility (frame-parameters))) t)
751 (make-frame-visible)))
753 (defun suspend-frame ()
754 "Do whatever is right to suspend the current frame.
755 Calls `suspend-emacs' if invoked from the controlling terminal,
756 `suspend-tty' from a secondary terminal, and
757 `iconify-or-deiconify-frame' from an X frame."
759 (let ((type (framep (selected-frame))))
761 ((eq type 'x) (iconify-or-deiconify-frame))
766 (t (suspend-emacs)))))
769 (defun make-frame-names-alist ()
770 (let* ((current-frame (selected-frame))
773 (cons (frame-parameter current-frame 'name) current-frame) nil))
774 (frame (next-frame nil t)))
775 (while (not (eq frame current-frame))
777 (setq falist (cons (cons (frame-parameter frame 'name) frame) falist))
778 (setq frame (next-frame frame t))))
781 (defvar frame-name-history nil)
782 (defun select-frame-by-name (name)
783 "Select the frame on the current terminal whose name is NAME and raise it.
784 If there is no frame by that name, signal an error."
786 (let* ((frame-names-alist (make-frame-names-alist))
787 (default (car (car frame-names-alist)))
788 (input (completing-read
789 (format "Select Frame (default %s): " default)
790 frame-names-alist nil t nil 'frame-name-history)))
791 (if (= (length input) 0)
794 (let* ((frame-names-alist (make-frame-names-alist))
795 (frame (cdr (assoc name frame-names-alist))))
797 (error "There is no frame named `%s'" name))
798 (make-frame-visible frame)
801 ;; Ensure, if possible, that frame gets input focus.
802 (cond ((eq (window-system frame) 'x)
803 (x-focus-frame frame))
804 ((eq (window-system frame) 'w32)
805 (w32-focus-frame frame)))
806 (when focus-follows-mouse
807 (set-mouse-position frame (1- (frame-width frame)) 0))))
809 ;;;; Frame configurations
811 (defun current-frame-configuration ()
812 "Return a list describing the positions and states of all frames.
813 Its car is `frame-configuration'.
814 Each element of the cdr is a list of the form (FRAME ALIST WINDOW-CONFIG),
816 FRAME is a frame object,
817 ALIST is an association list specifying some of FRAME's parameters, and
818 WINDOW-CONFIG is a window configuration object for FRAME."
819 (cons 'frame-configuration
823 (frame-parameters frame)
824 (current-window-configuration frame))))
827 (defun set-frame-configuration (configuration &optional nodelete)
828 "Restore the frames to the state described by CONFIGURATION.
829 Each frame listed in CONFIGURATION has its position, size, window
830 configuration, and other parameters set as specified in CONFIGURATION.
831 Ordinarily, this function deletes all existing frames not
832 listed in CONFIGURATION. But if optional second argument NODELETE
833 is given and non-nil, the unwanted frames are iconified instead."
834 (or (frame-configuration-p configuration)
835 (signal 'wrong-type-argument
836 (list 'frame-configuration-p configuration)))
837 (let ((config-alist (cdr configuration))
841 (let ((parameters (assq frame config-alist)))
844 (modify-frame-parameters
846 ;; Since we can't set a frame's minibuffer status,
847 ;; we might as well omit the parameter altogether.
848 (let* ((parms (nth 1 parameters))
849 (mini (assq 'minibuffer parms)))
850 (if mini (setq parms (delq mini parms)))
852 (set-window-configuration (nth 2 parameters)))
853 (setq frames-to-delete (cons frame frames-to-delete))))))
856 ;; Note: making frames invisible here was tried
857 ;; but led to some strange behavior--each time the frame
858 ;; was made visible again, the window manager asked afresh
859 ;; for where to put it.
860 (mapcar 'iconify-frame frames-to-delete)
861 (mapcar 'delete-frame frames-to-delete))))
863 ;;;; Convenience functions for accessing and interactively changing
864 ;;;; frame parameters.
866 (defun frame-height (&optional frame)
867 "Return number of lines available for display on FRAME.
868 If FRAME is omitted, describe the currently selected frame."
869 (cdr (assq 'height (frame-parameters frame))))
871 (defun frame-width (&optional frame)
872 "Return number of columns available for display on FRAME.
873 If FRAME is omitted, describe the currently selected frame."
874 (cdr (assq 'width (frame-parameters frame))))
876 (defalias 'set-default-font 'set-frame-font)
877 (defun set-frame-font (font-name &optional keep-size)
878 "Set the font of the selected frame to FONT-NAME.
879 When called interactively, prompt for the name of the font to use.
880 To get the frame's current default font, use `frame-parameters'.
882 The default behavior is to keep the numbers of lines and columns in
883 the frame, thus may change its pixel size. If optional KEEP-SIZE is
884 non-nil (interactively, prefix argument) the current frame size (in
885 pixels) is kept by adjusting the numbers of the lines and columns."
887 (let* ((completion-ignore-case t)
888 (font (completing-read "Font name: "
890 ;; x-list-fonts will fail with an error
891 ;; if this frame doesn't support fonts.
892 (x-list-fonts "*" nil (selected-frame)))
894 (frame-parameter nil 'font))))
895 (list font current-prefix-arg)))
898 (setq fht (* (frame-parameter nil 'height) (frame-char-height))
899 fwd (* (frame-parameter nil 'width) (frame-char-width))))
900 (modify-frame-parameters (selected-frame)
901 (list (cons 'font font-name)))
903 (modify-frame-parameters
905 (list (cons 'height (round fht (frame-char-height)))
906 (cons 'width (round fwd (frame-char-width)))))))
907 (run-hooks 'after-setting-font-hook 'after-setting-font-hooks))
909 (defun set-frame-parameter (frame parameter value)
910 (modify-frame-parameters frame (list (cons parameter value))))
912 (defun set-background-color (color-name)
913 "Set the background color of the selected frame to COLOR-NAME.
914 When called interactively, prompt for the name of the color to use.
915 To get the frame's current background color, use `frame-parameters'."
916 (interactive (list (facemenu-read-color)))
917 (modify-frame-parameters (selected-frame)
918 (list (cons 'background-color color-name)))
920 (face-set-after-frame-default (selected-frame))))
922 (defun set-foreground-color (color-name)
923 "Set the foreground color 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 foreground color, use `frame-parameters'."
926 (interactive (list (facemenu-read-color)))
927 (modify-frame-parameters (selected-frame)
928 (list (cons 'foreground-color color-name)))
930 (face-set-after-frame-default (selected-frame))))
932 (defun set-cursor-color (color-name)
933 "Set the text cursor color of the selected frame to COLOR-NAME.
934 When called interactively, prompt for the name of the color to use.
935 To get the frame's current cursor color, use `frame-parameters'."
936 (interactive (list (facemenu-read-color)))
937 (modify-frame-parameters (selected-frame)
938 (list (cons 'cursor-color color-name))))
940 (defun set-mouse-color (color-name)
941 "Set the color of the mouse pointer of the selected frame to COLOR-NAME.
942 When called interactively, prompt for the name of the color to use.
943 To get the frame's current mouse color, use `frame-parameters'."
944 (interactive (list (facemenu-read-color)))
945 (modify-frame-parameters (selected-frame)
946 (list (cons 'mouse-color
948 (cdr (assq 'mouse-color
949 (frame-parameters))))))))
951 (defun set-border-color (color-name)
952 "Set the color of the border of the selected frame to COLOR-NAME.
953 When called interactively, prompt for the name of the color to use.
954 To get the frame's current border color, use `frame-parameters'."
955 (interactive (list (facemenu-read-color)))
956 (modify-frame-parameters (selected-frame)
957 (list (cons 'border-color color-name))))
959 (defun auto-raise-mode (arg)
960 "Toggle whether or not the selected frame should auto-raise.
961 With arg, turn auto-raise mode on if and only if arg is positive.
962 Note that this controls Emacs's own auto-raise feature.
963 Some window managers allow you to enable auto-raise for certain windows.
964 You can use that for Emacs windows if you wish, but if you do,
965 that is beyond the control of Emacs and this command has no effect on it."
969 (if (cdr (assq 'auto-raise (frame-parameters (selected-frame))))
972 (raise-frame (selected-frame)))
973 (modify-frame-parameters (selected-frame)
974 (list (cons 'auto-raise (> arg 0)))))
976 (defun auto-lower-mode (arg)
977 "Toggle whether or not the selected frame should auto-lower.
978 With arg, turn auto-lower mode on if and only if arg is positive.
979 Note that this controls Emacs's own auto-lower feature.
980 Some window managers allow you to enable auto-lower for certain windows.
981 You can use that for Emacs windows if you wish, but if you do,
982 that is beyond the control of Emacs and this command has no effect on it."
986 (if (cdr (assq 'auto-lower (frame-parameters (selected-frame))))
988 (modify-frame-parameters (selected-frame)
989 (list (cons 'auto-lower (> arg 0)))))
990 (defun set-frame-name (name)
991 "Set the name of the selected frame to NAME.
992 When called interactively, prompt for the name of the frame.
993 The frame name is displayed on the modeline if the terminal displays only
994 one frame, otherwise the name is displayed on the frame's caption bar."
995 (interactive "sFrame name: ")
996 (modify-frame-parameters (selected-frame)
997 (list (cons 'name name))))
999 (defun frame-current-scroll-bars (&optional frame)
1000 "Return the current scroll-bar settings in frame FRAME.
1001 Value is a cons (VERTICAL . HORISONTAL) where VERTICAL specifies the
1002 current location of the vertical scroll-bars (left, right, or nil),
1003 and HORISONTAL specifies the current location of the horisontal scroll
1004 bars (top, bottom, or nil)."
1005 (let ((vert (frame-parameter frame 'vertical-scroll-bars))
1007 (unless (memq vert '(left right nil))
1008 (setq vert default-frame-scroll-bars))
1011 ;;;; Frame/display capabilities.
1012 (defun display-mouse-p (&optional display)
1013 "Return non-nil if DISPLAY has a mouse available.
1014 DISPLAY can be a display name, a frame, or nil (meaning the selected
1016 (let ((frame-type (framep-on-display display)))
1018 ((eq frame-type 'pc)
1020 ((eq system-type 'windows-nt)
1021 (> w32-num-mouse-buttons 0))
1022 ((memq frame-type '(x mac))
1023 t) ;; We assume X and Mac *always* have a pointing device
1025 (or (and (featurep 'xt-mouse)
1027 ;; t-mouse is distributed with the GPM package. It doesn't have
1029 (featurep 't-mouse))))))
1031 (defun display-popup-menus-p (&optional display)
1032 "Return non-nil if popup menus are supported on DISPLAY.
1033 DISPLAY can be a display name, a frame, or nil (meaning the selected
1035 Support for popup menus requires that the mouse be available."
1037 (let ((frame-type (framep-on-display display)))
1038 (memq frame-type '(x w32 pc mac)))
1039 (display-mouse-p display)))
1041 (defun display-graphic-p (&optional display)
1042 "Return non-nil if DISPLAY is a graphic display.
1043 Graphical displays are those which are capable of displaying several
1044 frames and several different fonts at once. This is true for displays
1045 that use a window system such as X, and false for text-only terminals.
1046 DISPLAY can be a display name, a frame, or nil (meaning the selected
1048 (not (null (memq (framep-on-display display) '(x w32 mac)))))
1050 (defun display-images-p (&optional display)
1051 "Return non-nil if DISPLAY can display images.
1053 DISPLAY can be a display name, a frame, or nil (meaning the selected
1055 (and (display-graphic-p display)
1056 (fboundp 'image-mask-p)
1057 (fboundp 'image-size)))
1059 (defalias 'display-multi-frame-p 'display-graphic-p)
1060 (defalias 'display-multi-font-p 'display-graphic-p)
1062 (defun display-selections-p (&optional display)
1063 "Return non-nil if DISPLAY supports selections.
1064 A selection is a way to transfer text or other data between programs
1065 via special system buffers called `selection' or `cut buffer' or
1067 DISPLAY can be a display name, a frame, or nil (meaning the selected
1069 (let ((frame-type (framep-on-display display)))
1071 ((eq frame-type 'pc)
1072 ;; MS-DOG frames support selections when Emacs runs inside
1073 ;; the Windows' DOS Box.
1074 (not (null dos-windows-version)))
1075 ((memq frame-type '(x w32 mac))
1080 (defun display-screens (&optional display)
1081 "Return the number of screens associated with DISPLAY."
1082 (let ((frame-type (framep-on-display display)))
1084 ((memq frame-type '(x w32))
1085 (x-display-screens display))
1086 (t ;; FIXME: is this correct for the Mac?
1089 (defun display-pixel-height (&optional display)
1090 "Return the height of DISPLAY's screen in pixels.
1091 For character terminals, each character counts as a single pixel."
1092 (let ((frame-type (framep-on-display display)))
1094 ((memq frame-type '(x w32 mac))
1095 (x-display-pixel-height display))
1097 (frame-height (if (framep display) display (selected-frame)))))))
1099 (defun display-pixel-width (&optional display)
1100 "Return the width of DISPLAY's screen in pixels.
1101 For character terminals, each character counts as a single pixel."
1102 (let ((frame-type (framep-on-display display)))
1104 ((memq frame-type '(x w32 mac))
1105 (x-display-pixel-width display))
1107 (frame-width (if (framep display) display (selected-frame)))))))
1109 (defun display-mm-height (&optional display)
1110 "Return the height of DISPLAY's screen in millimeters.
1111 If the information is unavailable, value is nil."
1112 (and (memq (framep-on-display display) '(x w32 mac))
1113 (x-display-mm-height display)))
1115 (defun display-mm-width (&optional display)
1116 "Return the width of DISPLAY's screen in millimeters.
1117 If the information is unavailable, value is nil."
1118 (and (memq (framep-on-display display) '(x w32 mac))
1119 (x-display-mm-width display)))
1121 (defun display-backing-store (&optional display)
1122 "Return the backing store capability of DISPLAY's screen.
1123 The value may be `always', `when-mapped', `not-useful', or nil if
1124 the question is inapplicable to a certain kind of display."
1125 (let ((frame-type (framep-on-display display)))
1127 ((memq frame-type '(x w32 mac))
1128 (x-display-backing-store display))
1132 (defun display-save-under (&optional display)
1133 "Return non-nil if DISPLAY's screen supports the SaveUnder feature."
1134 (let ((frame-type (framep-on-display display)))
1136 ((memq frame-type '(x w32 mac))
1137 (x-display-save-under display))
1141 (defun display-planes (&optional display)
1142 "Return the number of planes supported by DISPLAY."
1143 (let ((frame-type (framep-on-display display)))
1145 ((memq frame-type '(x w32 mac))
1146 (x-display-planes display))
1147 ((eq frame-type 'pc)
1150 (truncate (log (length (tty-color-alist)) 2))))))
1152 (defun display-color-cells (&optional display)
1153 "Return the number of color cells supported by DISPLAY."
1154 (let ((frame-type (framep-on-display display)))
1156 ((memq frame-type '(x w32 mac))
1157 (x-display-color-cells display))
1158 ((eq frame-type 'pc)
1161 (tty-display-color-cells display)))))
1163 (defun display-visual-class (&optional display)
1164 "Returns the visual class of DISPLAY.
1165 The value is one of the symbols `static-gray', `gray-scale',
1166 `static-color', `pseudo-color', `true-color', or `direct-color'."
1167 (let ((frame-type (framep-on-display display)))
1169 ((memq frame-type '(x w32 mac))
1170 (x-display-visual-class display))
1171 ((and (memq frame-type '(pc t))
1172 (tty-display-color-p display))
1178 ;;;; Aliases for backward compatibility with Emacs 18.
1179 (defalias 'screen-height 'frame-height)
1180 (defalias 'screen-width 'frame-width)
1182 (defun set-screen-width (cols &optional pretend)
1183 "Obsolete function to change the size of the screen to COLS columns.
1184 Optional second arg non-nil means that redisplay should use COLS columns
1185 but that the idea of the actual width of the frame should not be changed.
1186 This function is provided only for compatibility with Emacs 18; new code
1187 should use `set-frame-width instead'."
1188 (set-frame-width (selected-frame) cols pretend))
1190 (defun set-screen-height (lines &optional pretend)
1191 "Obsolete function to change the height of the screen to LINES lines.
1192 Optional second arg non-nil means that redisplay should use LINES lines
1193 but that the idea of the actual height of the screen should not be changed.
1194 This function is provided only for compatibility with Emacs 18; new code
1195 should use `set-frame-height' instead."
1196 (set-frame-height (selected-frame) lines pretend))
1198 (defun delete-other-frames (&optional frame)
1199 "Delete all frames except FRAME.
1200 If FRAME uses another frame's minibuffer, the minibuffer frame is
1201 left untouched. FRAME nil or omitted means use the selected frame."
1204 (setq frame (selected-frame)))
1205 (let* ((mini-frame (window-frame (minibuffer-window frame)))
1206 (frames (delq mini-frame (delq frame (frame-list)))))
1207 ;; Delete mon-minibuffer-only frames first, because `delete-frame'
1208 ;; signals an error when trying to delete a mini-frame that's
1209 ;; still in use by another frame.
1210 (dolist (frame frames)
1211 (unless (eq (frame-parameter frame 'minibuffer) 'only)
1212 (delete-frame frame)))
1213 ;; Delete minibuffer-only frames.
1214 (dolist (frame frames)
1215 (when (eq (frame-parameter frame 'minibuffer) 'only)
1216 (delete-frame frame)))))
1218 (make-obsolete 'screen-height 'frame-height) ;before 19.15
1219 (make-obsolete 'screen-width 'frame-width) ;before 19.15
1220 (make-obsolete 'set-screen-width 'set-frame-width) ;before 19.15
1221 (make-obsolete 'set-screen-height 'set-frame-height) ;before 19.15
1223 ;; miscellaneous obsolescence declarations
1224 (defvaralias 'delete-frame-hook 'delete-frame-functions)
1225 (make-obsolete-variable 'delete-frame-hook 'delete-frame-functions "21.4")
1228 ;; Highlighting trailing whitespace.
1230 (make-variable-buffer-local 'show-trailing-whitespace)
1232 (defcustom show-trailing-whitespace nil
1233 "*Non-nil means highlight trailing whitespace in face `trailing-whitespace'.
1235 Setting this variable makes it local to the current buffer."
1236 :tag "Highlight trailing whitespace."
1244 (defgroup scrolling nil
1245 "Scrolling windows."
1249 (defcustom auto-hscroll-mode t
1250 "*Allow or disallow automatic scrolling windows horizontally.
1251 If non-nil, windows are automatically scrolled horizontally to make
1256 (defvaralias 'automatic-hscrolling 'auto-hscroll-mode)
1261 (defgroup cursor nil
1262 "Displaying text cursors."
1266 (defcustom blink-cursor-delay 0.5
1267 "*Seconds of idle time after which cursor starts to blink."
1268 :tag "Delay in seconds."
1272 (defcustom blink-cursor-interval 0.5
1273 "*Length of cursor blink interval in seconds."
1274 :tag "Blink interval in seconds."
1278 (defvar blink-cursor-idle-timer nil
1279 "Timer started after `blink-cursor-delay' seconds of Emacs idle time.
1280 The function `blink-cursor-start' is called when the timer fires.")
1282 (defvar blink-cursor-timer nil
1283 "Timer started from `blink-cursor-start'.
1284 This timer calls `blink-cursor' every `blink-cursor-interval' seconds.")
1286 (defvar blink-cursor-mode nil
1287 "Non-nil means blinking cursor is active.")
1289 (defun blink-cursor-mode (arg)
1290 "Toggle blinking cursor mode.
1291 With a numeric argument, turn blinking cursor mode on iff ARG is positive.
1292 When blinking cursor mode is enabled, the cursor of the selected
1295 Note that this command is effective only when Emacs
1296 displays through a window system, because then Emacs does its own
1297 cursor display. On a text-only terminal, this is not implemented."
1299 (let ((on-p (if (null arg)
1300 (not blink-cursor-mode)
1301 (> (prefix-numeric-value arg) 0))))
1302 (if blink-cursor-idle-timer
1303 (cancel-timer blink-cursor-idle-timer))
1304 (if blink-cursor-timer
1305 (cancel-timer blink-cursor-timer))
1306 (setq blink-cursor-idle-timer nil
1307 blink-cursor-timer nil
1308 blink-cursor-mode nil)
1312 ;(internal-show-cursor nil nil)
1313 (setq blink-cursor-idle-timer
1314 (run-with-idle-timer blink-cursor-delay
1316 'blink-cursor-start))
1317 (setq blink-cursor-mode t))
1318 (internal-show-cursor nil t))))
1320 ;; Note that this is really initialized from startup.el before
1321 ;; the init-file is read.
1323 (defcustom blink-cursor nil
1324 "*Non-nil means blinking cursor mode is active."
1326 :tag "Blinking cursor"
1328 :set #'(lambda (symbol value)
1329 (set-default symbol value)
1330 (blink-cursor-mode (or value 0))))
1332 (defun blink-cursor-start ()
1333 "Timer function called from the timer `blink-cursor-idle-timer'.
1334 This starts the timer `blink-cursor-timer', which makes the cursor blink
1335 if appropriate. It also arranges to cancel that timer when the next
1336 command starts, by installing a pre-command hook."
1337 (when (null blink-cursor-timer)
1338 (add-hook 'pre-command-hook 'blink-cursor-end)
1339 (setq blink-cursor-timer
1340 (run-with-timer blink-cursor-interval blink-cursor-interval
1341 'blink-cursor-timer-function))))
1343 (defun blink-cursor-timer-function ()
1344 "Timer function of timer `blink-cursor-timer'."
1345 (internal-show-cursor nil (not (internal-show-cursor-p))))
1347 (defun blink-cursor-end ()
1348 "Stop cursor blinking.
1349 This is installed as a pre-command hook by `blink-cursor-start'.
1350 When run, it cancels the timer `blink-cursor-timer' and removes
1351 itself as a pre-command hook."
1352 (remove-hook 'pre-command-hook 'blink-cursor-end)
1353 (internal-show-cursor nil t)
1354 (cancel-timer blink-cursor-timer)
1355 (setq blink-cursor-timer nil))
1359 ;; Hourglass pointer
1361 (defcustom display-hourglass t
1362 "*Non-nil means show an hourglass pointer when running under a window system."
1363 :tag "Hourglass pointer"
1367 (defcustom hourglass-delay 1
1368 "*Seconds to wait before displaying an hourglass pointer."
1369 :tag "Hourglass delay"
1374 (defcustom cursor-in-non-selected-windows t
1375 "*Non-nil means show a hollow box cursor in non-selected-windows.
1376 If nil, don't show a cursor except in the selected window.
1377 Use Custom to set this variable to get the display updated."
1378 :tag "Cursor in non-selected windows"
1381 :set #'(lambda (symbol value)
1382 (set-default symbol value)
1383 (force-mode-line-update t)))
1388 (define-key ctl-x-5-map "2" 'make-frame-command)
1389 (define-key ctl-x-5-map "1" 'delete-other-frames)
1390 (define-key ctl-x-5-map "0" 'delete-frame)
1391 (define-key ctl-x-5-map "o" 'other-frame)
1393 (substitute-key-definition 'suspend-emacs 'suspend-frame global-map)
1397 ;;; arch-tag: 82979c70-b8f2-4306-b2ad-ddbd6b328b56
1398 ;;; frame.el ends here