1 ;;; frame.el --- multi-frame management independent of window systems -*- lexical-binding:t -*-
3 ;; Copyright (C) 1993-1994, 1996-1997, 2000-2018 Free Software
6 ;; Maintainer: emacs-devel@gnu.org
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
28 (eval-when-compile (require 'cl-lib
))
30 (cl-defgeneric frame-creation-function
(params)
31 "Method for window-system dependent functions to create a new frame.
32 The window system startup file should add its frame creation
33 function to this method, which should take an alist of parameters
36 (cl-generic-define-context-rewriter window-system
(value)
37 ;; If `value' is a `consp', it's probably an old-style specializer,
38 ;; so just use it, and anyway `eql' isn't very useful on cons cells.
39 `(window-system ,(if (consp value
) value
`(eql ,value
))))
41 (cl-defmethod frame-creation-function (params &context
(window-system nil
))
42 ;; It's tempting to get rid of tty-create-frame-with-faces and turn it into
43 ;; this method (i.e. move this method to faces.el), but faces.el is loaded
44 ;; much earlier from loadup.el (before cl-generic and even before
45 ;; cl-preloaded), so we'd first have to reorder that part.
46 (tty-create-frame-with-faces params
))
48 (defvar window-system-default-frame-alist nil
49 "Window-system dependent default frame parameters.
50 The value should be an alist of elements (WINDOW-SYSTEM . ALIST),
51 where WINDOW-SYSTEM is a window system symbol (as returned by `framep')
52 and ALIST is a frame parameter alist like `default-frame-alist'.
53 Then, for frames on WINDOW-SYSTEM, any parameters specified in
54 ALIST supersede the corresponding parameters specified in
55 `default-frame-alist'.")
57 (defvar display-format-alist nil
58 "Alist of patterns to decode display names.
59 The car of each entry is a regular expression matching a display
60 name string. The cdr is a symbol giving the window-system that
61 handles the corresponding kind of display.")
63 ;; The initial value given here used to ask for a minibuffer.
64 ;; But that's not necessary, because the default is to have one.
65 ;; By not specifying it here, we let an X resource specify it.
66 (defcustom initial-frame-alist nil
67 "Alist of parameters for the initial X window frame.
68 You can set this in your init file; for example,
70 (setq initial-frame-alist
71 \\='((top . 1) (left . 1) (width . 80) (height . 55)))
73 Parameters specified here supersede the values given in
74 `default-frame-alist'.
76 If the value calls for a frame without a minibuffer, and you have
77 not created a minibuffer frame on your own, a minibuffer frame is
78 created according to `minibuffer-frame-alist'.
80 You can specify geometry-related options for just the initial
81 frame by setting this variable in your init file; however, they
82 won't take effect until Emacs reads your init file, which happens
83 after creating the initial frame. If you want the initial frame
84 to have the proper geometry as soon as it appears, you need to
85 use this three-step process:
86 * Specify X resources to give the geometry you want.
87 * Set `default-frame-alist' to override these options so that they
88 don't affect subsequent frames.
89 * Set `initial-frame-alist' in a way that matches the X resources,
90 to override what you put in `default-frame-alist'."
91 :type
'(repeat (cons :format
"%v"
92 (symbol :tag
"Parameter")
96 (defcustom minibuffer-frame-alist
'((width .
80) (height .
2))
97 "Alist of parameters for the initial minibuffer frame.
98 This is the minibuffer frame created if `initial-frame-alist'
99 calls for a frame without a minibuffer. The parameters specified
100 here supersede those given in `default-frame-alist', for the
101 initial minibuffer frame.
103 You can set this in your init file; for example,
105 (setq minibuffer-frame-alist
106 \\='((top . 1) (left . 1) (width . 80) (height . 2)))
108 It is not necessary to include (minibuffer . only); that is
109 appended when the minibuffer frame is created."
110 :type
'(repeat (cons :format
"%v"
111 (symbol :tag
"Parameter")
112 (sexp :tag
"Value")))
115 (defun handle-delete-frame (event)
116 "Handle delete-frame events from the X server."
118 (let* ((frame (posn-window (event-start event
))))
119 (if (catch 'other-frame
120 (dolist (frame-1 (frame-list))
121 ;; A valid "other" frame is visible, has its `delete-before'
122 ;; parameter unset and is not a child frame.
123 (when (and (not (eq frame-1 frame
))
124 (frame-visible-p frame-1
)
125 (not (frame-parent frame-1
))
126 (not (frame-parameter frame-1
'delete-before
)))
127 (throw 'other-frame t
))))
128 (delete-frame frame t
)
129 ;; Gildea@x.org says it is ok to ask questions before terminating.
130 (save-buffers-kill-emacs))))
132 (defun handle-focus-in (_event)
133 "Handle a focus-in event.
134 Focus-in events are usually bound to this function.
135 Focus-in events occur when a frame has focus, but a switch-frame event
137 This function runs the hook `focus-in-hook'."
139 (run-hooks 'focus-in-hook
))
141 (defun handle-focus-out (_event)
142 "Handle a focus-out event.
143 Focus-out events are usually bound to this function.
144 Focus-out events occur when no frame has focus.
145 This function runs the hook `focus-out-hook'."
147 (run-hooks 'focus-out-hook
))
149 (defun handle-move-frame (event)
150 "Handle a move-frame event.
151 This function runs the abnormal hook `move-frame-functions'."
153 (let ((frame (posn-window (event-start event
))))
154 (run-hook-with-args 'move-frame-functions frame
)))
156 ;;;; Arrangement of frames at startup
158 ;; 1) Load the window system startup file from the lisp library and read the
159 ;; high-priority arguments (-q and the like). The window system startup
160 ;; file should create any frames specified in the window system defaults.
162 ;; 2) If no frames have been opened, we open an initial text frame.
164 ;; 3) Once the init file is done, we apply any newly set parameters
165 ;; in initial-frame-alist to the frame.
167 ;; If we create the initial frame, this is it.
168 (defvar frame-initial-frame nil
)
170 ;; Record the parameters used in frame-initialize to make the initial frame.
171 (defvar frame-initial-frame-alist
)
173 (defvar frame-initial-geometry-arguments nil
)
175 ;; startup.el calls this function before loading the user's init
176 ;; file - if there is no frame with a minibuffer open now, create
177 ;; one to display messages while loading the init file.
178 (defun frame-initialize ()
179 "Create an initial frame if necessary."
180 ;; Are we actually running under a window system at all?
181 (if (and initial-window-system
183 (not (eq initial-window-system
'pc
)))
185 ;; If there is no frame with a minibuffer besides the terminal
186 ;; frame, then we need to create the opening frame. Make sure
187 ;; it has a minibuffer, but let initial-frame-alist omit the
189 (or (delq terminal-frame
(minibuffer-frame-list))
191 (setq frame-initial-frame-alist
192 (append initial-frame-alist default-frame-alist nil
))
193 (setq frame-initial-frame-alist
194 (cons (cons 'window-system initial-window-system
)
195 frame-initial-frame-alist
))
196 (setq default-minibuffer-frame
197 (setq frame-initial-frame
198 (make-frame frame-initial-frame-alist
)))
199 ;; Delete any specifications for window geometry parameters
200 ;; so that we won't reapply them in frame-notice-user-settings.
201 ;; It would be wrong to reapply them then,
202 ;; because that would override explicit user resizing.
203 (setq initial-frame-alist
204 (frame-remove-geometry-params initial-frame-alist
))))
205 ;; Copy the environment of the Emacs process into the new frame.
206 (set-frame-parameter frame-initial-frame
'environment
207 (frame-parameter terminal-frame
'environment
))
208 ;; At this point, we know that we have a frame open, so we
209 ;; can delete the terminal frame.
210 (delete-frame terminal-frame
)
211 (setq terminal-frame nil
))))
213 (defvar frame-notice-user-settings t
214 "Non-nil means function `frame-notice-user-settings' wasn't run yet.")
216 (declare-function tool-bar-mode
"tool-bar" (&optional arg
))
217 (declare-function tool-bar-height
"xdisp.c" (&optional frame pixelwise
))
219 (defalias 'tool-bar-lines-needed
'tool-bar-height
)
221 ;; startup.el calls this function after loading the user's init
222 ;; file. Now default-frame-alist and initial-frame-alist contain
223 ;; information to which we must react; do what needs to be done.
224 (defun frame-notice-user-settings ()
225 "Act on user's init file settings of frame parameters.
226 React to settings of `initial-frame-alist',
227 `window-system-default-frame-alist' and `default-frame-alist'
228 there (in decreasing order of priority)."
229 ;; Creating and deleting frames may shift the selected frame around,
230 ;; and thus the current buffer. Protect against that. We don't
231 ;; want to use save-excursion here, because that may also try to set
232 ;; the buffer of the selected window, which fails when the selected
233 ;; window is the minibuffer.
234 (let ((old-buffer (current-buffer))
235 (window-system-frame-alist
236 (cdr (assq initial-window-system
237 window-system-default-frame-alist
))))
239 (when (and frame-notice-user-settings
240 (null frame-initial-frame
))
241 ;; This case happens when we don't have a window system, and
242 ;; also for MS-DOS frames.
243 (let ((parms (frame-parameters)))
244 ;; Don't change the frame names.
245 (setq parms
(delq (assq 'name parms
) parms
))
246 ;; Can't modify the minibuffer parameter, so don't try.
247 (setq parms
(delq (assq 'minibuffer parms
) parms
))
248 (modify-frame-parameters
250 (if initial-window-system
252 ;; initial-frame-alist and default-frame-alist were already
253 ;; applied in pc-win.el.
254 (append initial-frame-alist window-system-frame-alist
255 default-frame-alist parms nil
)))
256 (if (null initial-window-system
) ;; MS-DOS does this differently in pc-win.el
257 (let ((newparms (frame-parameters))
258 (frame (selected-frame)))
259 (tty-handle-reverse-video frame newparms
)
260 ;; tty-handle-reverse-video might change the frame's
261 ;; color parameters, and we need to use the updated
263 (setq newparms
(frame-parameters))
264 ;; If we changed the background color, we need to update
265 ;; the background-mode parameter, and maybe some faces,
267 (when (assq 'background-color newparms
)
268 (unless (or (assq 'background-mode initial-frame-alist
)
269 (assq 'background-mode default-frame-alist
))
270 (frame-set-background-mode frame
))
271 (face-set-after-frame-default frame newparms
))))))
273 ;; If the initial frame is still around, apply initial-frame-alist
274 ;; and default-frame-alist to it.
275 (when (frame-live-p frame-initial-frame
)
276 ;; When tool-bar has been switched off, correct the frame size
277 ;; by the lines added in x-create-frame for the tool-bar and
278 ;; switch `tool-bar-mode' off.
279 (when (display-graphic-p)
281 (assq 'tool-bar-lines initial-frame-alist
))
283 (or (assq 'tool-bar-lines window-system-frame-alist
)
284 (assq 'tool-bar-lines default-frame-alist
)))
285 (lines (or init-lines other-lines
))
286 (height (tool-bar-height frame-initial-frame t
)))
287 ;; Adjust frame top if either zero (nil) tool bar lines have
288 ;; been requested in the most relevant of the frame's alists
289 ;; or tool bar mode has been explicitly turned off in the
291 (when (and (> height
0)
293 (or (null (cdr lines
))
295 (not tool-bar-mode
)))
297 (cdr (assq 'top frame-initial-geometry-arguments
)))
298 (top (frame-parameter frame-initial-frame
'top
)))
299 (when (and (consp initial-top
) (eq '-
(car initial-top
)))
302 ((and (consp top
) (eq '+ (car top
)))
303 (list '+ (+ (cadr top
) height
)))
304 ((and (consp top
) (eq '-
(car top
)))
305 (list '-
(- (cadr top
) height
)))
306 (t (+ top height
)))))
307 (modify-frame-parameters
308 frame-initial-frame
`((top .
,adjusted-top
))))))
309 ;; Reset `tool-bar-mode' when zero tool bar lines have been
310 ;; requested for the window-system or default frame alists.
311 (when (and tool-bar-mode
313 (or (null (cdr other-lines
))
314 (eq 0 (cdr other-lines
)))))
315 (tool-bar-mode -
1)))))
317 ;; The initial frame we create above always has a minibuffer.
318 ;; If the user wants to remove it, or make it a minibuffer-only
319 ;; frame, then we'll have to delete the current frame and make a
320 ;; new one; you can't remove or add a root window to/from an
323 ;; NOTE: default-frame-alist was nil when we created the
324 ;; existing frame. We need to explicitly include
325 ;; default-frame-alist in the parameters of the screen we
326 ;; create here, so that its new value, gleaned from the user's
327 ;; init file, will be applied to the existing screen.
328 (if (not (eq (cdr (or (assq 'minibuffer initial-frame-alist
)
329 (assq 'minibuffer window-system-frame-alist
)
330 (assq 'minibuffer default-frame-alist
)
333 ;; Create the new frame.
335 ;; MS-Windows needs this to avoid inflooping below.
336 (if (eq system-type
'windows-nt
)
338 ;; If the frame isn't visible yet, wait till it is.
339 ;; If the user has to position the window,
340 ;; Emacs doesn't know its real position until
341 ;; the frame is seen to be visible.
342 (while (not (cdr (assq 'visibility
343 (frame-parameters frame-initial-frame
))))
345 (setq parms
(frame-parameters frame-initial-frame
))
347 ;; Get rid of `name' unless it was specified explicitly before.
348 (or (assq 'name frame-initial-frame-alist
)
349 (setq parms
(delq (assq 'name parms
) parms
)))
350 ;; An explicit parent-id is a request to XEmbed the frame.
351 (or (assq 'parent-id frame-initial-frame-alist
)
352 (setq parms
(delq (assq 'parent-id parms
) parms
)))
354 (setq parms
(append initial-frame-alist
355 window-system-frame-alist
360 ;; Get rid of `reverse', because that was handled
361 ;; when we first made the frame.
362 (setq parms
(cons '(reverse) (delq (assq 'reverse parms
) parms
)))
364 (if (assq 'height frame-initial-geometry-arguments
)
365 (setq parms
(assq-delete-all 'height parms
)))
366 (if (assq 'width frame-initial-geometry-arguments
)
367 (setq parms
(assq-delete-all 'width parms
)))
368 (if (assq 'left frame-initial-geometry-arguments
)
369 (setq parms
(assq-delete-all 'left parms
)))
370 (if (assq 'top frame-initial-geometry-arguments
)
371 (setq parms
(assq-delete-all 'top parms
)))
374 ;; Use the geometry args that created the existing
375 ;; frame, rather than the parms we get for it.
376 (append frame-initial-geometry-arguments
377 '((user-size . t
) (user-position . t
))
379 ;; The initial frame, which we are about to delete, may be
380 ;; the only frame with a minibuffer. If it is, create a
382 (or (delq frame-initial-frame
(minibuffer-frame-list))
383 (make-initial-minibuffer-frame nil
))
385 ;; If the initial frame is serving as a surrogate
386 ;; minibuffer frame for any frames, we need to wean them
387 ;; onto a new frame. The default-minibuffer-frame
388 ;; variable must be handled similarly.
389 (let ((users-of-initial
392 (and (not (eq frame frame-initial-frame
))
394 (minibuffer-window frame
))
395 frame-initial-frame
))))))
396 (if (or users-of-initial
397 (eq default-minibuffer-frame frame-initial-frame
))
399 ;; Choose an appropriate frame. Prefer frames which
400 ;; are only minibuffers.
401 (let* ((new-surrogate
403 (or (filtered-frame-list
405 (eq (cdr (assq 'minibuffer
406 (frame-parameters frame
)))
408 (minibuffer-frame-list))))
409 (new-minibuffer (minibuffer-window new-surrogate
)))
411 (if (eq default-minibuffer-frame frame-initial-frame
)
412 (setq default-minibuffer-frame new-surrogate
))
414 ;; Wean the frames using frame-initial-frame as
415 ;; their minibuffer frame.
416 (dolist (frame users-of-initial
)
417 (modify-frame-parameters
418 frame
(list (cons 'minibuffer new-minibuffer
)))))))
420 ;; Redirect events enqueued at this frame to the new frame.
421 ;; Is this a good idea?
422 (redirect-frame-focus frame-initial-frame new
)
424 ;; Finally, get rid of the old frame.
425 (delete-frame frame-initial-frame t
))
427 ;; Otherwise, we don't need all that rigmarole; just apply
428 ;; the new parameters.
429 (let (newparms allparms tail
)
430 (setq allparms
(append initial-frame-alist
431 window-system-frame-alist
432 default-frame-alist nil
))
433 (if (assq 'height frame-initial-geometry-arguments
)
434 (setq allparms
(assq-delete-all 'height allparms
)))
435 (if (assq 'width frame-initial-geometry-arguments
)
436 (setq allparms
(assq-delete-all 'width allparms
)))
437 (if (assq 'left frame-initial-geometry-arguments
)
438 (setq allparms
(assq-delete-all 'left allparms
)))
439 (if (assq 'top frame-initial-geometry-arguments
)
440 (setq allparms
(assq-delete-all 'top allparms
)))
442 ;; Find just the parms that have changed since we first
443 ;; made this frame. Those are the ones actually set by
444 ;; the init file. For those parms whose values we already knew
445 ;; (such as those spec'd by command line options)
446 ;; it is undesirable to specify the parm again
447 ;; once the user has seen the frame and been able to alter it
451 (setq oldval
(assq (car entry
) frame-initial-frame-alist
))
452 (setq newval
(cdr (assq (car entry
) allparms
)))
453 (or (and oldval
(eq (cdr oldval
) newval
))
455 (cons (cons (car entry
) newval
) newparms
)))))
456 (setq newparms
(nreverse newparms
))
458 (let ((new-bg (assq 'background-color newparms
)))
459 ;; If the `background-color' parameter is changed, apply
460 ;; it first, then make sure that the `background-mode'
461 ;; parameter and other faces are updated, before applying
462 ;; the other parameters.
464 (modify-frame-parameters frame-initial-frame
466 (unless (assq 'background-mode newparms
)
467 (frame-set-background-mode frame-initial-frame
))
468 (face-set-after-frame-default frame-initial-frame
)
469 (setq newparms
(delq new-bg newparms
)))
471 (when (numberp (car frame-size-history
))
472 (setq frame-size-history
473 (cons (1- (car frame-size-history
))
475 (list frame-initial-frame
478 (cdr frame-size-history
)))))
480 (modify-frame-parameters frame-initial-frame newparms
)))))
482 ;; Restore the original buffer.
483 (set-buffer old-buffer
)
485 ;; Make sure the initial frame can be GC'd if it is ever deleted.
486 ;; Make sure frame-notice-user-settings does nothing if called twice.
487 (setq frame-notice-user-settings nil
)
488 (setq frame-initial-frame nil
)))
490 (defun make-initial-minibuffer-frame (display)
491 (let ((parms (append minibuffer-frame-alist
'((minibuffer . only
)))))
493 (make-frame-on-display display parms
)
494 (make-frame parms
))))
496 ;;;; Creation of additional frames, and other frame miscellanea
498 (defun modify-all-frames-parameters (alist)
499 "Modify all current and future frames' parameters according to ALIST.
500 This changes `default-frame-alist' and possibly `initial-frame-alist'.
501 Furthermore, this function removes all parameters in ALIST from
502 `window-system-default-frame-alist'.
503 See help of `modify-frame-parameters' for more information."
504 (dolist (frame (frame-list))
505 (modify-frame-parameters frame alist
))
507 (dolist (pair alist
) ;; conses to add/replace
508 ;; initial-frame-alist needs setting only when
509 ;; frame-notice-user-settings is true.
510 (and frame-notice-user-settings
511 (setq initial-frame-alist
512 (assq-delete-all (car pair
) initial-frame-alist
)))
513 (setq default-frame-alist
514 (assq-delete-all (car pair
) default-frame-alist
))
515 ;; Remove any similar settings from the window-system specific
516 ;; parameters---they would override default-frame-alist.
517 (dolist (w window-system-default-frame-alist
)
518 (setcdr w
(assq-delete-all (car pair
) (cdr w
)))))
520 (and frame-notice-user-settings
521 (setq initial-frame-alist
(append initial-frame-alist alist
)))
522 (setq default-frame-alist
(append default-frame-alist alist
)))
524 (defun get-other-frame ()
525 "Return some frame other than the current frame.
526 Create one if necessary. Note that the minibuffer frame, if separate,
527 is not considered (see `next-frame')."
528 (if (equal (next-frame) (selected-frame)) (make-frame) (next-frame)))
530 (defun next-multiframe-window ()
531 "Select the next window, regardless of which frame it is on."
533 (select-window (next-window (selected-window)
534 (> (minibuffer-depth) 0)
536 (select-frame-set-input-focus (selected-frame)))
538 (defun previous-multiframe-window ()
539 "Select the previous window, regardless of which frame it is on."
541 (select-window (previous-window (selected-window)
542 (> (minibuffer-depth) 0)
544 (select-frame-set-input-focus (selected-frame)))
546 (defun window-system-for-display (display)
547 "Return the window system for DISPLAY.
548 Return nil if we don't know how to interpret DISPLAY."
549 ;; MS-Windows doesn't know how to create a GUI frame in a -nw session.
550 (if (and (eq system-type
'windows-nt
)
551 (null (window-system))
554 (cl-loop for descriptor in display-format-alist
555 for pattern
= (car descriptor
)
556 for system
= (cdr descriptor
)
557 when
(string-match-p pattern display
) return system
)))
559 (defun make-frame-on-display (display &optional parameters
)
560 "Make a frame on display DISPLAY.
561 The optional argument PARAMETERS specifies additional frame parameters."
562 (interactive "sMake frame on display: ")
563 (make-frame (cons (cons 'display display
) parameters
)))
565 (declare-function x-close-connection
"xfns.c" (terminal))
567 (defun close-display-connection (display)
568 "Close the connection to a display, deleting all its associated frames.
569 For DISPLAY, specify either a frame or a display name (a string).
570 If DISPLAY is nil, that stands for the selected frame's display."
573 (let* ((default (frame-parameter nil
'display
))
574 (display (completing-read
575 (format "Close display (default %s): " default
)
577 (mapcar (lambda (frame)
578 (frame-parameter frame
'display
))
582 (if (zerop (length display
)) default display
))))
583 (let ((frames (delq nil
584 (mapcar (lambda (frame)
586 (frame-parameter frame
'display
))
589 (if (and (consp frames
)
590 (not (y-or-n-p (if (cdr frames
)
591 (format "Delete %s frames? " (length frames
))
592 (format "Delete %s ? " (car frames
))))))
594 (mapc 'delete-frame frames
)
595 (x-close-connection display
))))
597 (defun make-frame-command ()
598 "Make a new frame, on the same terminal as the selected frame.
599 If the terminal is a text-only terminal, this also selects the
602 (if (display-graphic-p)
604 (select-frame (make-frame))))
606 (defvar before-make-frame-hook nil
607 "Functions to run before `make-frame' creates a new frame.")
609 (defvar after-make-frame-functions nil
610 "Functions to run after `make-frame' created a new frame.
611 The functions are run with one argument, the newly created
614 (defvar after-setting-font-hook nil
615 "Functions to run after a frame's font has been changed.")
617 (defvar frame-inherited-parameters
'()
618 "Parameters `make-frame' copies from the selected to the new frame.")
620 (defvar x-display-name
)
622 (defun make-frame (&optional parameters
)
623 "Return a newly created frame displaying the current buffer.
624 Optional argument PARAMETERS is an alist of frame parameters for
625 the new frame. Each element of PARAMETERS should have the
626 form (NAME . VALUE), for example:
628 (name . STRING) The frame should be named STRING.
630 (width . NUMBER) The frame should be NUMBER characters in width.
631 (height . NUMBER) The frame should be NUMBER text lines high.
633 (minibuffer . t) The frame should have a minibuffer.
634 (minibuffer . nil) The frame should have no minibuffer.
635 (minibuffer . only) The frame should contain only a minibuffer.
636 (minibuffer . WINDOW) The frame should use WINDOW as its minibuffer window.
638 (window-system . nil) The frame should be displayed on a terminal device.
639 (window-system . x) The frame should be displayed in an X window.
641 (display . \":0\") The frame should appear on display :0.
643 (terminal . TERMINAL) The frame should use the terminal object TERMINAL.
645 In addition, any parameter specified in `default-frame-alist',
646 but not present in PARAMETERS, is applied.
648 Before creating the frame (via `frame-creation-function'), this
649 function runs the hook `before-make-frame-hook'. After creating
650 the frame, it runs the hook `after-make-frame-functions' with one
651 argument, the newly created frame.
653 If a display parameter is supplied and a window-system is not,
654 guess the window-system from the display.
656 On graphical displays, this function does not itself make the new
657 frame the selected frame. However, the window system may select
658 the new frame according to its own rules."
660 (let* ((display (cdr (assq 'display parameters
)))
662 ((assq 'terminal parameters
)
663 (let ((type (terminal-live-p
664 (cdr (assq 'terminal parameters
)))))
667 ((null type
) (error "Terminal %s does not exist"
668 (cdr (assq 'terminal parameters
))))
670 ((assq 'window-system parameters
)
671 (cdr (assq 'window-system parameters
)))
673 (or (window-system-for-display display
)
674 (error "Don't know how to interpret display %S"
677 (oldframe (selected-frame))
681 (unless (get w
'window-system-initialized
)
682 (let ((window-system w
)) ;Hack attack!
683 (window-system-initialization display
))
684 (setq x-display-name display
)
685 (put w
'window-system-initialized t
))
687 ;; Add parameters from `window-system-default-frame-alist'.
688 (dolist (p (cdr (assq w window-system-default-frame-alist
)))
689 (unless (assq (car p
) params
)
691 ;; Add parameters from `default-frame-alist'.
692 (dolist (p default-frame-alist
)
693 (unless (assq (car p
) params
)
695 ;; Now make the frame.
696 (run-hooks 'before-make-frame-hook
)
698 ;; (setq frame-size-history '(1000))
700 (setq frame
(let ((window-system w
)) ;Hack attack!
701 (frame-creation-function params
)))
702 (normal-erase-is-backspace-setup-frame frame
)
703 ;; Inherit the original frame's parameters.
704 (dolist (param frame-inherited-parameters
)
705 (unless (assq param parameters
) ;Overridden by explicit parameters.
706 (let ((val (frame-parameter oldframe param
)))
707 (when val
(set-frame-parameter frame param val
)))))
709 (when (numberp (car frame-size-history
))
710 (setq frame-size-history
711 (cons (1- (car frame-size-history
))
712 (cons (list frame
"MAKE-FRAME")
713 (cdr frame-size-history
)))))
715 ;; We can run `window-configuration-change-hook' for this frame now.
716 (frame-after-make-frame frame t
)
717 (run-hook-with-args 'after-make-frame-functions frame
)
720 (defun filtered-frame-list (predicate)
721 "Return a list of all live frames which satisfy PREDICATE."
722 (let* ((frames (frame-list))
724 (while (consp frames
)
725 (unless (funcall predicate
(car frames
))
727 (setq frames
(cdr frames
)))
730 (defun minibuffer-frame-list ()
731 "Return a list of all frames with their own minibuffers."
734 (eq frame
(window-frame (minibuffer-window frame
))))))
736 ;; Used to be called `terminal-id' in termdev.el.
737 (defun get-device-terminal (device)
738 "Return the terminal corresponding to DEVICE.
739 DEVICE can be a terminal, a frame, nil (meaning the selected frame's terminal),
740 the name of an X display device (HOST.SERVER.SCREEN) or a tty device file."
742 ((or (null device
) (framep device
))
743 (frame-terminal device
))
745 (let ((f (car (filtered-frame-list
747 (or (equal (frame-parameter frame
'display
) device
)
748 (equal (frame-parameter frame
'tty
) device
)))))))
749 (or f
(error "Display %s does not exist" device
))
751 ((terminal-live-p device
) device
)
753 (error "Invalid argument %s in `get-device-terminal'" device
))))
755 (defun frames-on-display-list (&optional device
)
756 "Return a list of all frames on DEVICE.
758 DEVICE should be a terminal, a frame,
759 or a name of an X display or tty (a string of the form
762 If DEVICE is omitted or nil, it defaults to the selected
763 frame's terminal device."
764 (let* ((terminal (get-device-terminal device
))
765 (func #'(lambda (frame)
766 (eq (frame-terminal frame
) terminal
))))
767 (filtered-frame-list func
)))
769 (defun framep-on-display (&optional terminal
)
770 "Return the type of frames on TERMINAL.
771 TERMINAL may be a terminal id, a display name or a frame. If it
772 is a frame, its type is returned. If TERMINAL is omitted or nil,
773 it defaults to the selected frame's terminal device. All frames
774 on a given display are of the same type."
775 (or (terminal-live-p terminal
)
777 (framep (car (frames-on-display-list terminal
)))))
779 (defun frame-remove-geometry-params (param-list)
780 "Return the parameter list PARAM-LIST, but with geometry specs removed.
781 This deletes all bindings in PARAM-LIST for `top', `left', `width',
782 `height', `user-size' and `user-position' parameters.
783 Emacs uses this to avoid overriding explicit moves and resizings from
784 the user during startup."
785 (setq param-list
(cons nil param-list
))
786 (let ((tail param-list
))
787 (while (consp (cdr tail
))
788 (if (and (consp (car (cdr tail
)))
789 (memq (car (car (cdr tail
)))
790 '(height width top left user-position user-size
)))
792 (setq frame-initial-geometry-arguments
793 (cons (car (cdr tail
)) frame-initial-geometry-arguments
))
794 (setcdr tail
(cdr (cdr tail
))))
795 (setq tail
(cdr tail
)))))
796 (setq frame-initial-geometry-arguments
797 (nreverse frame-initial-geometry-arguments
))
800 (declare-function x-focus-frame
"frame.c" (frame &optional noactivate
))
802 (defun select-frame-set-input-focus (frame &optional norecord
)
803 "Select FRAME, raise it, and set input focus, if possible.
804 If `mouse-autoselect-window' is non-nil, also move mouse pointer
805 to FRAME's selected window. Otherwise, if `focus-follows-mouse'
806 is non-nil, move mouse cursor to FRAME.
808 Optional argument NORECORD means to neither change the order of
809 recently selected windows nor the buffer list."
810 (select-frame frame norecord
)
812 ;; Ensure, if possible, that FRAME gets input focus.
813 (when (memq (window-system frame
) '(x w32 ns
))
814 (x-focus-frame frame
))
815 ;; Move mouse cursor if necessary.
817 (mouse-autoselect-window
818 (let ((edges (window-inside-edges (frame-selected-window frame
))))
819 ;; Move mouse cursor into FRAME's selected window to avoid that
820 ;; Emacs mouse-autoselects another window.
821 (set-mouse-position frame
(nth 2 edges
) (nth 1 edges
))))
823 ;; Move mouse cursor into FRAME to avoid that another frame gets
824 ;; selected by the window manager.
825 (set-mouse-position frame
(1- (frame-width frame
)) 0))))
827 (defun other-frame (arg)
828 "Select the ARGth different visible frame on current display, and raise it.
829 All frames are arranged in a cyclic order.
830 This command selects the frame ARG steps away in that order.
831 A negative ARG moves in the opposite order.
833 To make this command work properly, you must tell Emacs how the
834 system (or the window manager) generally handles focus-switching
835 between windows. If moving the mouse onto a window selects
836 it (gives it focus), set `focus-follows-mouse' to t. Otherwise,
837 that variable should be nil."
839 (let ((sframe (selected-frame))
840 (frame (selected-frame)))
842 (setq frame
(next-frame frame
))
843 (while (and (not (eq frame sframe
))
844 (not (eq (frame-visible-p frame
) t
)))
845 (setq frame
(next-frame frame
)))
848 (setq frame
(previous-frame frame
))
849 (while (and (not (eq frame sframe
))
850 (not (eq (frame-visible-p frame
) t
)))
851 (setq frame
(previous-frame frame
)))
853 (select-frame-set-input-focus frame
)))
855 (defun iconify-or-deiconify-frame ()
856 "Iconify the selected frame, or deiconify if it's currently an icon."
858 (if (eq (cdr (assq 'visibility
(frame-parameters))) t
)
860 (make-frame-visible)))
862 (defun suspend-frame ()
863 "Do whatever is right to suspend the current frame.
864 Calls `suspend-emacs' if invoked from the controlling tty device,
865 `suspend-tty' from a secondary tty device, and
866 `iconify-or-deiconify-frame' from an X frame."
868 (let ((type (framep (selected-frame))))
870 ((memq type
'(x ns w32
)) (iconify-or-deiconify-frame))
872 (if (controlling-tty-p)
875 (t (suspend-emacs)))))
877 (defun make-frame-names-alist ()
878 ;; Only consider the frames on the same display.
879 (let* ((current-frame (selected-frame))
882 (cons (frame-parameter current-frame
'name
) current-frame
) nil
))
883 (frame (next-frame nil
0)))
884 (while (not (eq frame current-frame
))
886 (push (cons (frame-parameter frame
'name
) frame
) falist
)
887 (setq frame
(next-frame frame
0))))
890 (defvar frame-name-history nil
)
891 (defun select-frame-by-name (name)
892 "Select the frame whose name is NAME and raise it.
893 Frames on the current terminal are checked first.
894 If there is no frame by that name, signal an error."
896 (let* ((frame-names-alist (make-frame-names-alist))
897 (default (car (car frame-names-alist
)))
898 (input (completing-read
899 (format "Select Frame (default %s): " default
)
900 frame-names-alist nil t nil
'frame-name-history
)))
901 (if (= (length input
) 0)
904 (select-frame-set-input-focus
905 ;; Prefer frames on the current display.
906 (or (cdr (assoc name
(make-frame-names-alist)))
908 (dolist (frame (frame-list))
909 (when (equal (frame-parameter frame
'name
) name
)
910 (throw 'done frame
))))
911 (error "There is no frame named `%s'" name
))))
914 ;;;; Background mode.
916 (defcustom frame-background-mode nil
917 "The brightness of the background.
918 Set this to the symbol `dark' if your background color is dark,
919 `light' if your background is light, or nil (automatic by default)
920 if you want Emacs to examine the brightness for you.
922 If you change this without using customize, you should use
923 `frame-set-background-mode' to update existing frames;
924 e.g. (mapc \\='frame-set-background-mode (frame-list))."
926 :set
#'(lambda (var value
)
927 (set-default var value
)
928 (mapc 'frame-set-background-mode
(frame-list)))
929 :initialize
'custom-initialize-changed
930 :type
'(choice (const dark
)
932 (const :tag
"automatic" nil
)))
934 (declare-function x-get-resource
"frame.c"
935 (attribute class
&optional component subclass
))
937 ;; Only used if window-system is not null.
938 (declare-function x-display-grayscale-p
"xfns.c" (&optional terminal
))
940 (defvar inhibit-frame-set-background-mode nil
)
942 (defun frame-set-background-mode (frame &optional keep-face-specs
)
943 "Set up display-dependent faces on FRAME.
944 Display-dependent faces are those which have different definitions
945 according to the `background-mode' and `display-type' frame parameters.
947 If optional arg KEEP-FACE-SPECS is non-nil, don't recalculate
948 face specs for the new background mode."
949 (unless inhibit-frame-set-background-mode
950 (let* ((frame-default-bg-mode (frame-terminal-default-bg-mode frame
))
951 (bg-color (frame-parameter frame
'background-color
))
952 (tty-type (tty-type frame
))
954 (if (or (window-system frame
)
956 (string-match "^\\(xterm\\|\\rxvt\\|dtterm\\|eterm\\)"
960 (non-default-bg-mode (if (eq default-bg-mode
'light
) 'dark
'light
))
962 (cond (frame-default-bg-mode)
963 ((equal bg-color
"unspecified-fg") ; inverted colors
965 ((not (color-values bg-color frame
))
967 ((>= (apply '+ (color-values bg-color frame
))
968 ;; Just looking at the screen, colors whose
969 ;; values add up to .6 of the white total
970 ;; still look dark to me.
971 (* (apply '+ (color-values "white" frame
)) .6))
975 (cond ((null (window-system frame
))
976 (if (tty-display-color-p frame
) 'color
'mono
))
977 ((display-color-p frame
)
979 ((x-display-grayscale-p frame
)
983 (frame-parameter frame
'background-mode
))
985 (frame-parameter frame
'display-type
)))
987 (unless (and (eq bg-mode old-bg-mode
) (eq display-type old-display-type
))
988 (let ((locally-modified-faces nil
)
989 ;; Prevent face-spec-recalc from calling this function
990 ;; again, resulting in a loop (bug#911).
991 (inhibit-frame-set-background-mode t
)
992 (params (list (cons 'background-mode bg-mode
)
993 (cons 'display-type display-type
))))
995 (modify-frame-parameters frame params
)
996 ;; If we are recomputing face specs, first collect a list
997 ;; of faces that don't match their face-specs. These are
998 ;; the faces modified on FRAME, and we avoid changing them
999 ;; below. Use a negative list to avoid consing (we assume
1000 ;; most faces are unmodified).
1001 (dolist (face (face-list))
1002 (and (not (get face
'face-override-spec
))
1003 (not (face-spec-match-p face
1004 (face-user-default-spec face
)
1006 (push face locally-modified-faces
)))
1007 ;; Now change to the new frame parameters
1008 (modify-frame-parameters frame params
)
1009 ;; For all unmodified named faces, choose face specs
1010 ;; matching the new frame parameters.
1011 (dolist (face (face-list))
1012 (unless (memq face locally-modified-faces
)
1013 (face-spec-recalc face frame
)))))))))
1015 (defun frame-terminal-default-bg-mode (frame)
1016 "Return the default background mode of FRAME.
1017 This checks the `frame-background-mode' variable, the X resource
1018 named \"backgroundMode\" (if FRAME is an X frame), and finally
1019 the `background-mode' terminal parameter."
1020 (or frame-background-mode
1022 (and (window-system frame
)
1023 (x-get-resource "backgroundMode" "BackgroundMode"))))
1025 (intern (downcase bg-resource
))))
1026 (terminal-parameter frame
'background-mode
)))
1029 ;;;; Frame configurations
1031 (defun current-frame-configuration ()
1032 "Return a list describing the positions and states of all frames.
1033 Its car is `frame-configuration'.
1034 Each element of the cdr is a list of the form (FRAME ALIST WINDOW-CONFIG),
1036 FRAME is a frame object,
1037 ALIST is an association list specifying some of FRAME's parameters, and
1038 WINDOW-CONFIG is a window configuration object for FRAME."
1039 (cons 'frame-configuration
1040 (mapcar (lambda (frame)
1042 (frame-parameters frame
)
1043 (current-window-configuration frame
)))
1046 (defun set-frame-configuration (configuration &optional nodelete
)
1047 "Restore the frames to the state described by CONFIGURATION.
1048 Each frame listed in CONFIGURATION has its position, size, window
1049 configuration, and other parameters set as specified in CONFIGURATION.
1050 However, this function does not restore deleted frames.
1052 Ordinarily, this function deletes all existing frames not
1053 listed in CONFIGURATION. But if optional second argument NODELETE
1054 is given and non-nil, the unwanted frames are iconified instead."
1055 (or (frame-configuration-p configuration
)
1056 (signal 'wrong-type-argument
1057 (list 'frame-configuration-p configuration
)))
1058 (let ((config-alist (cdr configuration
))
1060 (dolist (frame (frame-list))
1061 (let ((parameters (assq frame config-alist
)))
1064 (modify-frame-parameters
1066 ;; Since we can't set a frame's minibuffer status,
1067 ;; we might as well omit the parameter altogether.
1068 (let* ((parms (nth 1 parameters
))
1069 (mini (assq 'minibuffer parms
))
1070 (name (assq 'name parms
))
1071 (explicit-name (cdr (assq 'explicit-name parms
))))
1072 (when mini
(setq parms
(delq mini parms
)))
1073 ;; Leave name in iff it was set explicitly.
1074 ;; This should fix the behavior reported in
1075 ;; https://lists.gnu.org/r/emacs-devel/2007-08/msg01632.html
1076 (when (and name
(not explicit-name
))
1077 (setq parms
(delq name parms
)))
1079 (set-window-configuration (nth 2 parameters
)))
1080 (setq frames-to-delete
(cons frame frames-to-delete
)))))
1082 ;; Note: making frames invisible here was tried
1083 ;; but led to some strange behavior--each time the frame
1084 ;; was made visible again, the window manager asked afresh
1085 ;; for where to put it.
1090 ;;;; Convenience functions for accessing and interactively changing
1091 ;;;; frame parameters.
1093 (defun frame-height (&optional frame
)
1094 "Return number of lines available for display on FRAME.
1095 If FRAME is omitted, describe the currently selected frame.
1096 Exactly what is included in the return value depends on the
1097 window-system and toolkit in use - see `frame-pixel-height' for
1098 more details. The lines are in units of the default font height.
1100 The result is roughly related to the frame pixel height via
1101 height in pixels = height in lines * `frame-char-height'.
1102 However, this is only approximate, and is complicated e.g. by the
1103 fact that individual window lines and menu bar lines can have
1104 differing font heights."
1105 (cdr (assq 'height
(frame-parameters frame
))))
1107 (defun frame-width (&optional frame
)
1108 "Return number of columns available for display on FRAME.
1109 If FRAME is omitted, describe the currently selected frame."
1110 (cdr (assq 'width
(frame-parameters frame
))))
1112 (defalias 'frame-border-width
'frame-internal-border-width
)
1113 (defalias 'frame-pixel-width
'frame-native-width
)
1114 (defalias 'frame-pixel-height
'frame-native-height
)
1116 (defun frame-inner-width (&optional frame
)
1117 "Return inner width of FRAME in pixels.
1118 FRAME defaults to the selected frame."
1119 (setq frame
(window-normalize-frame frame
))
1120 (- (frame-native-width frame
)
1121 (* 2 (frame-internal-border-width frame
))))
1123 (defun frame-inner-height (&optional frame
)
1124 "Return inner height of FRAME in pixels.
1125 FRAME defaults to the selected frame."
1126 (setq frame
(window-normalize-frame frame
))
1127 (- (frame-native-height frame
)
1128 (* 2 (frame-internal-border-width frame
))))
1130 (defun frame-outer-width (&optional frame
)
1131 "Return outer width of FRAME in pixels.
1132 FRAME defaults to the selected frame."
1133 (setq frame
(window-normalize-frame frame
))
1134 (let ((edges (frame-edges frame
'outer-edges
)))
1135 (- (nth 2 edges
) (nth 0 edges
))))
1137 (defun frame-outer-height (&optional frame
)
1138 "Return outer height of FRAME in pixels.
1139 FRAME defaults to the selected frame."
1140 (setq frame
(window-normalize-frame frame
))
1141 (let ((edges (frame-edges frame
'outer-edges
)))
1142 (- (nth 3 edges
) (nth 1 edges
))))
1144 (declare-function x-list-fonts
"xfaces.c"
1145 (pattern &optional face frame maximum width
))
1147 (defun set-frame-font (font &optional keep-size frames
)
1148 "Set the default font to FONT.
1149 When called interactively, prompt for the name of a font, and use
1150 that font on the selected frame. When called from Lisp, FONT
1151 should be a font name (a string), a font object, font entity, or
1154 If KEEP-SIZE is nil, keep the number of frame lines and columns
1155 fixed. If KEEP-SIZE is non-nil (or with a prefix argument), try
1156 to keep the current frame size fixed (in pixels) by adjusting the
1157 number of lines and columns.
1159 If FRAMES is nil, apply the font to the selected frame only.
1160 If FRAMES is non-nil, it should be a list of frames to act upon,
1161 or t meaning all existing graphical frames.
1162 Also, if FRAMES is non-nil, alter the user's Customization settings
1163 as though the font-related attributes of the `default' face had been
1164 \"set in this session\", so that the font is applied to future frames."
1166 (let* ((completion-ignore-case t
)
1167 (font (completing-read "Font name: "
1168 ;; x-list-fonts will fail with an error
1169 ;; if this frame doesn't support fonts.
1170 (x-list-fonts "*" nil
(selected-frame))
1172 (frame-parameter nil
'font
))))
1173 (list font current-prefix-arg nil
)))
1174 (when (or (stringp font
) (fontp font
))
1175 (let* ((this-frame (selected-frame))
1176 ;; FRAMES nil means affect the selected frame.
1177 (frame-list (cond ((null frames
)
1183 (dolist (f frame-list
)
1184 (when (display-multi-font-p f
)
1186 (setq height
(* (frame-parameter f
'height
)
1187 (frame-char-height f
))
1188 width
(* (frame-parameter f
'width
)
1189 (frame-char-width f
))))
1190 ;; When set-face-attribute is called for :font, Emacs
1191 ;; guesses the best font according to other face attributes
1192 ;; (:width, :weight, etc.) so reset them too (Bug#2476).
1193 (set-face-attribute 'default f
1194 :width
'normal
:weight
'normal
1195 :slant
'normal
:font font
)
1197 (modify-frame-parameters
1199 (list (cons 'height
(round height
(frame-char-height f
)))
1200 (cons 'width
(round width
(frame-char-width f
))))))))
1202 ;; Alter the user's Custom setting of the `default' face, but
1203 ;; only for font-related attributes.
1204 (let ((specs (cadr (assq 'user
(get 'default
'theme-face
))))
1205 (attrs '(:family
:foundry
:slant
:weight
:height
:width
))
1207 (if (null specs
) (setq specs
'((t nil
))))
1208 (dolist (spec specs
)
1209 ;; Each SPEC has the form (DISPLAY ATTRIBUTE-PLIST)
1210 (let ((display (nth 0 spec
))
1211 (plist (copy-tree (nth 1 spec
))))
1212 ;; Alter only DISPLAY conditions matching this frame.
1213 (when (or (memq display
'(t default
))
1214 (face-spec-set-match-display display this-frame
))
1215 (dolist (attr attrs
)
1216 (setq plist
(plist-put plist attr
1217 (face-attribute 'default attr
)))))
1218 (push (list display plist
) new-specs
)))
1219 (setq new-specs
(nreverse new-specs
))
1220 (put 'default
'customized-face new-specs
)
1221 (custom-push-theme 'theme-face
'default
'user
'set new-specs
)
1222 (put 'default
'face-modified nil
))))
1223 (run-hooks 'after-setting-font-hook
'after-setting-font-hooks
)))
1225 (defun set-frame-parameter (frame parameter value
)
1226 "Set frame parameter PARAMETER to VALUE on FRAME.
1227 If FRAME is nil, it defaults to the selected frame.
1228 See `modify-frame-parameters'."
1229 (modify-frame-parameters frame
(list (cons parameter value
))))
1231 (defun set-background-color (color-name)
1232 "Set the background color of the selected frame to COLOR-NAME.
1233 When called interactively, prompt for the name of the color to use.
1234 To get the frame's current background color, use `frame-parameters'."
1235 (interactive (list (read-color "Background color: ")))
1236 (modify-frame-parameters (selected-frame)
1237 (list (cons 'background-color color-name
)))
1239 (face-set-after-frame-default (selected-frame)
1241 (cons 'background-color color-name
)
1242 ;; Pass the foreground-color as
1243 ;; well, if defined, to avoid
1244 ;; losing it when faces are reset
1245 ;; to their defaults.
1246 (assq 'foreground-color
1247 (frame-parameters))))))
1249 (defun set-foreground-color (color-name)
1250 "Set the foreground color of the selected frame to COLOR-NAME.
1251 When called interactively, prompt for the name of the color to use.
1252 To get the frame's current foreground color, use `frame-parameters'."
1253 (interactive (list (read-color "Foreground color: ")))
1254 (modify-frame-parameters (selected-frame)
1255 (list (cons 'foreground-color color-name
)))
1257 (face-set-after-frame-default (selected-frame)
1259 (cons 'foreground-color color-name
)
1260 ;; Pass the background-color as
1261 ;; well, if defined, to avoid
1262 ;; losing it when faces are reset
1263 ;; to their defaults.
1264 (assq 'background-color
1265 (frame-parameters))))))
1267 (defun set-cursor-color (color-name)
1268 "Set the text cursor color of the selected frame to COLOR-NAME.
1269 When called interactively, prompt for the name of the color to use.
1270 This works by setting the `cursor-color' frame parameter on the
1273 You can also set the text cursor color, for all frames, by
1274 customizing the `cursor' face."
1275 (interactive (list (read-color "Cursor color: ")))
1276 (modify-frame-parameters (selected-frame)
1277 (list (cons 'cursor-color color-name
))))
1279 (defun set-mouse-color (color-name)
1280 "Set the color of the mouse pointer of the selected frame to COLOR-NAME.
1281 When called interactively, prompt for the name of the color to use.
1282 To get the frame's current mouse color, use `frame-parameters'."
1283 (interactive (list (read-color "Mouse color: ")))
1284 (modify-frame-parameters (selected-frame)
1285 (list (cons 'mouse-color
1287 (cdr (assq 'mouse-color
1288 (frame-parameters))))))))
1290 (defun set-border-color (color-name)
1291 "Set the color of the border of the selected frame to COLOR-NAME.
1292 When called interactively, prompt for the name of the color to use.
1293 To get the frame's current border color, use `frame-parameters'."
1294 (interactive (list (read-color "Border color: ")))
1295 (modify-frame-parameters (selected-frame)
1296 (list (cons 'border-color color-name
))))
1298 (define-minor-mode auto-raise-mode
1299 "Toggle whether or not selected frames should auto-raise.
1300 With a prefix argument ARG, enable Auto Raise mode if ARG is
1301 positive, and disable it otherwise. If called from Lisp, enable
1302 the mode if ARG is omitted or nil.
1304 Auto Raise mode does nothing under most window managers, which
1305 switch focus on mouse clicks. It only has an effect if your
1306 window manager switches focus on mouse movement (in which case
1307 you should also change `focus-follows-mouse' to t). Then,
1308 enabling Auto Raise mode causes any graphical Emacs frame which
1309 acquires focus to be automatically raised.
1311 Note that this minor mode controls Emacs's own auto-raise
1312 feature. Window managers that switch focus on mouse movement
1313 often have their own auto-raise feature."
1314 :variable
(frame-parameter nil
'auto-raise
)
1315 (if (frame-parameter nil
'auto-raise
)
1318 (define-minor-mode auto-lower-mode
1319 "Toggle whether or not the selected frame should auto-lower.
1320 With a prefix argument ARG, enable Auto Lower mode if ARG is
1321 positive, and disable it otherwise. If called from Lisp, enable
1322 the mode if ARG is omitted or nil.
1324 Auto Lower mode does nothing under most window managers, which
1325 switch focus on mouse clicks. It only has an effect if your
1326 window manager switches focus on mouse movement (in which case
1327 you should also change `focus-follows-mouse' to t). Then,
1328 enabling Auto Lower Mode causes any graphical Emacs frame which
1329 loses focus to be automatically lowered.
1331 Note that this minor mode controls Emacs's own auto-lower
1332 feature. Window managers that switch focus on mouse movement
1333 often have their own features for raising or lowering frames."
1334 :variable
(frame-parameter nil
'auto-lower
))
1336 (defun set-frame-name (name)
1337 "Set the name of the selected frame to NAME.
1338 When called interactively, prompt for the name of the frame.
1339 On text terminals, the frame name is displayed on the mode line.
1340 On graphical displays, it is displayed on the frame's title bar."
1341 (interactive "sFrame name: ")
1342 (modify-frame-parameters (selected-frame)
1343 (list (cons 'name name
))))
1345 (defun frame-current-scroll-bars (&optional frame
)
1346 "Return the current scroll-bar types for frame FRAME.
1347 Value is a cons (VERTICAL . HORIZ0NTAL) where VERTICAL specifies
1348 the current location of the vertical scroll-bars (`left', `right'
1349 or nil), and HORIZONTAL specifies the current location of the
1350 horizontal scroll bars (`bottom' or nil). FRAME must specify a
1351 live frame and defaults to the selected one."
1352 (let* ((frame (window-normalize-frame frame
))
1353 (vertical (frame-parameter frame
'vertical-scroll-bars
))
1354 (horizontal (frame-parameter frame
'horizontal-scroll-bars
)))
1355 (unless (memq vertical
'(left right nil
))
1356 (setq vertical default-frame-scroll-bars
))
1357 (cons vertical
(and horizontal
'bottom
))))
1359 (declare-function x-frame-geometry
"xfns.c" (&optional frame
))
1360 (declare-function w32-frame-geometry
"w32fns.c" (&optional frame
))
1361 (declare-function ns-frame-geometry
"nsfns.m" (&optional frame
))
1363 (defun frame-geometry (&optional frame
)
1364 "Return geometric attributes of FRAME.
1365 FRAME must be a live frame and defaults to the selected one. The return
1366 value is an association list of the attributes listed below. All height
1367 and width values are in pixels.
1369 `outer-position' is a cons of the outer left and top edges of FRAME
1370 relative to the origin - the position (0, 0) - of FRAME's display.
1372 `outer-size' is a cons of the outer width and height of FRAME. The
1373 outer size includes the title bar and the external borders as well as
1374 any menu and/or tool bar of frame.
1376 `external-border-size' is a cons of the horizontal and vertical width of
1377 FRAME's external borders as supplied by the window manager.
1379 `title-bar-size' is a cons of the width and height of the title bar of
1380 FRAME as supplied by the window manager. If both of them are zero,
1381 FRAME has no title bar. If only the width is zero, Emacs was not
1382 able to retrieve the width information.
1384 `menu-bar-external', if non-nil, means the menu bar is external (never
1385 included in the inner edges of FRAME).
1387 `menu-bar-size' is a cons of the width and height of the menu bar of
1390 `tool-bar-external', if non-nil, means the tool bar is external (never
1391 included in the inner edges of FRAME).
1393 `tool-bar-position' tells on which side the tool bar on FRAME is and can
1394 be one of `left', `top', `right' or `bottom'. If this is nil, FRAME
1397 `tool-bar-size' is a cons of the width and height of the tool bar of
1400 `internal-border-width' is the width of the internal border of
1402 (let* ((frame (window-normalize-frame frame
))
1403 (frame-type (framep-on-display frame
)))
1406 (x-frame-geometry frame
))
1407 ((eq frame-type
'w32
)
1408 (w32-frame-geometry frame
))
1409 ((eq frame-type
'ns
)
1410 (ns-frame-geometry frame
))
1413 '(outer-position 0 .
0)
1414 (cons 'outer-size
(cons (frame-width frame
) (frame-height frame
)))
1415 '(external-border-size 0 .
0)
1416 '(outer-border-width .
0)
1417 '(title-bar-size 0 .
0)
1418 '(menu-bar-external . nil
)
1419 (let ((menu-bar-lines (frame-parameter frame
'menu-bar-lines
)))
1420 (cons 'menu-bar-size
1422 (cons (frame-width frame
) 1)
1424 '(tool-bar-external . nil
)
1425 '(tool-bar-position . nil
)
1426 '(tool-bar-size 0 .
0)
1427 (cons 'internal-border-width
1428 (frame-parameter frame
'internal-border-width
)))))))
1430 (defun frame--size-history (&optional frame
)
1431 "Print history of resize operations for FRAME.
1432 Print prettified version of `frame-size-history' into a buffer
1433 called *frame-size-history*. Optional argument FRAME denotes the
1434 frame whose history will be printed. FRAME defaults to the
1436 (let ((history (reverse frame-size-history
))
1438 (setq frame
(window-normalize-frame frame
))
1439 (with-current-buffer (get-buffer-create "*frame-size-history*")
1441 (insert (format "Frame size history of %s\n" frame
))
1442 (while (listp (setq entry
(pop history
)))
1443 (when (eq (car entry
) frame
)
1445 (insert (format "%s" (pop entry
)))
1446 (move-to-column 24 t
)
1448 (insert (format " %s" (pop entry
))))
1451 (declare-function x-frame-edges
"xfns.c" (&optional frame type
))
1452 (declare-function w32-frame-edges
"w32fns.c" (&optional frame type
))
1453 (declare-function ns-frame-edges
"nsfns.m" (&optional frame type
))
1455 (defun frame-edges (&optional frame type
)
1456 "Return coordinates of FRAME's edges.
1457 FRAME must be a live frame and defaults to the selected one. The
1458 list returned has the form (LEFT TOP RIGHT BOTTOM) where all
1459 values are in pixels relative to the origin - the position (0, 0)
1460 - of FRAME's display. For terminal frames all values are
1461 relative to LEFT and TOP which are both zero.
1463 Optional argument TYPE specifies the type of the edges. TYPE
1464 `outer-edges' means to return the outer edges of FRAME. TYPE
1465 `native-edges' (or nil) means to return the native edges of
1466 FRAME. TYPE `inner-edges' means to return the inner edges of
1468 (let* ((frame (window-normalize-frame frame
))
1469 (frame-type (framep-on-display frame
)))
1472 (x-frame-edges frame type
))
1473 ((eq frame-type
'w32
)
1474 (w32-frame-edges frame type
))
1475 ((eq frame-type
'ns
)
1476 (ns-frame-edges frame type
))
1478 (list 0 0 (frame-width frame
) (frame-height frame
))))))
1480 (declare-function w32-mouse-absolute-pixel-position
"w32fns.c")
1481 (declare-function x-mouse-absolute-pixel-position
"xfns.c")
1482 (declare-function ns-mouse-absolute-pixel-position
"nsfns.m")
1484 (defun mouse-absolute-pixel-position ()
1485 "Return absolute position of mouse cursor in pixels.
1486 The position is returned as a cons cell (X . Y) of the
1487 coordinates of the mouse cursor position in pixels relative to a
1488 position (0, 0) of the selected frame's terminal."
1489 (let ((frame-type (framep-on-display)))
1492 (x-mouse-absolute-pixel-position))
1493 ((eq frame-type
'w32
)
1494 (w32-mouse-absolute-pixel-position))
1495 ((eq frame-type
'ns
)
1496 (ns-mouse-absolute-pixel-position))
1500 (declare-function ns-set-mouse-absolute-pixel-position
"nsfns.m" (x y
))
1501 (declare-function w32-set-mouse-absolute-pixel-position
"w32fns.c" (x y
))
1502 (declare-function x-set-mouse-absolute-pixel-position
"xfns.c" (x y
))
1504 (defun set-mouse-absolute-pixel-position (x y
)
1505 "Move mouse pointer to absolute pixel position (X, Y).
1506 The coordinates X and Y are interpreted in pixels relative to a
1507 position (0, 0) of the selected frame's terminal."
1508 (let ((frame-type (framep-on-display)))
1510 ((eq frame-type
'ns
)
1511 (ns-set-mouse-absolute-pixel-position x y
))
1513 (x-set-mouse-absolute-pixel-position x y
))
1514 ((eq frame-type
'w32
)
1515 (w32-set-mouse-absolute-pixel-position x y
)))))
1517 (defun frame-monitor-attributes (&optional frame
)
1518 "Return the attributes of the physical monitor dominating FRAME.
1519 If FRAME is omitted or nil, describe the currently selected frame.
1521 A frame is dominated by a physical monitor when either the
1522 largest area of the frame resides in the monitor, or the monitor
1523 is the closest to the frame if the frame does not intersect any
1526 See `display-monitor-attributes-list' for the list of attribute
1527 keys and their meanings."
1528 (or frame
(setq frame
(selected-frame)))
1529 (cl-loop for attributes in
(display-monitor-attributes-list frame
)
1530 for frames
= (cdr (assq 'frames attributes
))
1531 if
(memq frame frames
) return attributes
))
1533 (defun frame-monitor-attribute (attribute &optional frame x y
)
1534 "Return the value of ATTRIBUTE on FRAME's monitor.
1535 If FRAME is omitted or nil, use currently selected frame.
1537 By default, the current monitor is the physical monitor
1538 dominating the selected frame. A frame is dominated by a
1539 physical monitor when either the largest area of the frame
1540 resides in the monitor, or the monitor is the closest to the
1541 frame if the frame does not intersect any physical monitors.
1543 If X and Y are both numbers, then ignore the value of FRAME; the
1544 monitor is determined to be the physical monitor that contains
1545 the pixel coordinate (X, Y).
1547 See `display-monitor-attributes-list' for the list of attribute
1548 keys and their meanings."
1549 (if (and (numberp x
)
1551 (cl-loop for monitor in
(display-monitor-attributes-list)
1552 for geometry
= (alist-get 'geometry monitor
)
1553 for min-x
= (pop geometry
)
1554 for min-y
= (pop geometry
)
1555 for max-x
= (+ min-x
(pop geometry
))
1556 for max-y
= (+ min-y
(car geometry
))
1557 when
(and (<= min-x x
)
1561 return
(alist-get attribute monitor
))
1562 (alist-get attribute
(frame-monitor-attributes frame
))))
1564 (defun frame-monitor-geometry (&optional frame x y
)
1565 "Return the geometry of FRAME's monitor.
1566 FRAME can be a frame name, a terminal name, or a frame.
1567 If FRAME is omitted or nil, use the currently selected frame.
1569 By default, the current monitor is said to be the physical
1570 monitor dominating the selected frame. A frame is dominated by
1571 a physical monitor when either the largest area of the frame resides
1572 in the monitor, or the monitor is the closest to the frame if the
1573 frame does not intersect any physical monitors.
1575 If X and Y are both numbers, then ignore the value of FRAME; the
1576 monitor is determined to be the physical monitor that contains
1577 the pixel coordinate (X, Y).
1579 See `display-monitor-attributes-list' for information on the
1580 geometry attribute."
1581 (frame-monitor-attribute 'geometry frame x y
))
1583 (defun frame-monitor-workarea (&optional frame x y
)
1584 "Return the workarea of FRAME's monitor.
1585 FRAME can be a frame name, a terminal name, or a frame.
1586 If FRAME is omitted or nil, use currently selected frame.
1588 By default, the current monitor is said to be the physical
1589 monitor dominating the selected frame. A frame is dominated by
1590 a physical monitor when either the largest area of the frame resides
1591 in the monitor, or the monitor is the closest to the frame if the
1592 frame does not intersect any physical monitors.
1594 If X and Y are both numbers, then ignore the value of FRAME; the
1595 monitor is determined to be the physical monitor that contains
1596 the pixel coordinate (X, Y).
1598 See `display-monitor-attributes-list' for information on the
1599 workarea attribute."
1600 (frame-monitor-attribute 'workarea frame x y
))
1602 (declare-function x-frame-list-z-order
"xfns.c" (&optional display
))
1603 (declare-function w32-frame-list-z-order
"w32fns.c" (&optional display
))
1604 (declare-function ns-frame-list-z-order
"nsfns.m" (&optional display
))
1606 (defun frame-list-z-order (&optional display
)
1607 "Return list of Emacs' frames, in Z (stacking) order.
1608 The optional argument DISPLAY specifies which display to poll.
1609 DISPLAY should be either a frame or a display name (a string).
1610 If omitted or nil, that stands for the selected frame's display.
1612 Frames are listed from topmost (first) to bottommost (last). As
1613 a special case, if DISPLAY is non-nil and specifies a live frame,
1614 return the child frames of that frame in Z (stacking) order.
1616 Return nil if DISPLAY contains no Emacs frame."
1617 (let ((frame-type (framep-on-display display
)))
1620 (x-frame-list-z-order display
))
1621 ((eq frame-type
'w32
)
1622 (w32-frame-list-z-order display
))
1623 ((eq frame-type
'ns
)
1624 (ns-frame-list-z-order display
)))))
1626 (declare-function x-frame-restack
"xfns.c" (frame1 frame2
&optional above
))
1627 (declare-function w32-frame-restack
"w32fns.c" (frame1 frame2
&optional above
))
1628 (declare-function ns-frame-restack
"nsfns.m" (frame1 frame2
&optional above
))
1630 (defun frame-restack (frame1 frame2
&optional above
)
1631 "Restack FRAME1 below FRAME2.
1632 This implies that if both frames are visible and the display
1633 areas of these frames overlap, FRAME2 will (partially) obscure
1634 FRAME1. If the optional third argument ABOVE is non-nil, restack
1635 FRAME1 above FRAME2. This means that if both frames are visible
1636 and the display areas of these frames overlap, FRAME1 will
1637 \(partially) obscure FRAME2.
1639 This may be thought of as an atomic action performed in two
1640 steps: The first step removes FRAME1's window-system window from
1641 the display. The second step reinserts FRAME1's window
1642 below (above if ABOVE is true) that of FRAME2. Hence the
1643 position of FRAME2 in its display's Z (stacking) order relative
1644 to all other frames excluding FRAME1 remains unaltered.
1646 Some window managers may refuse to restack windows. "
1647 (if (and (frame-live-p frame1
)
1648 (frame-live-p frame2
)
1649 (equal (frame-parameter frame1
'display
)
1650 (frame-parameter frame2
'display
)))
1651 (let ((frame-type (framep-on-display frame1
)))
1654 (x-frame-restack frame1 frame2 above
))
1655 ((eq frame-type
'w32
)
1656 (w32-frame-restack frame1 frame2 above
))
1657 ((eq frame-type
'ns
)
1658 (ns-frame-restack frame1 frame2 above
))))
1659 (error "Cannot restack frames")))
1661 (defun frame-size-changed-p (&optional frame
)
1662 "Return non-nil when the size of FRAME has changed.
1663 More precisely, return non-nil when the inner width or height of
1664 FRAME has changed since `window-size-change-functions' was run
1666 (let* ((frame (window-normalize-frame frame
))
1667 (root (frame-root-window frame
))
1668 (mini (minibuffer-window frame
))
1669 (mini-height-before-size-change 0)
1671 ;; FRAME's minibuffer window counts iff it's on FRAME and FRAME is
1672 ;; not a minibuffer-only frame.
1673 (when (and (eq (window-frame mini
) frame
) (not (eq mini root
)))
1674 (setq mini-height-before-size-change
1675 (window-pixel-height-before-size-change mini
))
1676 (setq mini-height
(window-pixel-height mini
)))
1677 ;; Return non-nil when either the width of the root or the sum of
1678 ;; the heights of root and minibuffer window changed.
1679 (or (/= (window-pixel-width-before-size-change root
)
1680 (window-pixel-width root
))
1681 (/= (+ (window-pixel-height-before-size-change root
)
1682 mini-height-before-size-change
)
1683 (+ (window-pixel-height root
) mini-height
)))))
1685 ;;;; Frame/display capabilities.
1687 (declare-function msdos-mouse-p
"dosfns.c")
1689 (defun display-mouse-p (&optional display
)
1690 "Return non-nil if DISPLAY has a mouse available.
1691 DISPLAY can be a display name, a frame, or nil (meaning the selected
1693 (let ((frame-type (framep-on-display display
)))
1695 ((eq frame-type
'pc
)
1697 ((eq frame-type
'w32
)
1699 (> w32-num-mouse-buttons
0)))
1700 ((memq frame-type
'(x ns
))
1701 t
) ;; We assume X and NeXTstep *always* have a pointing device
1703 (or (and (featurep 'xt-mouse
)
1705 ;; t-mouse is distributed with the GPM package. It doesn't have
1708 ;; No way to check whether a w32 console has a mouse, assume
1710 (boundp 'w32-use-full-screen-buffer
))))))
1712 (defun display-popup-menus-p (&optional display
)
1713 "Return non-nil if popup menus are supported on DISPLAY.
1714 DISPLAY can be a display name, a frame, or nil (meaning the selected
1716 Support for popup menus requires that the mouse be available."
1717 (display-mouse-p display
))
1719 (defun display-graphic-p (&optional display
)
1720 "Return non-nil if DISPLAY is a graphic display.
1721 Graphical displays are those which are capable of displaying several
1722 frames and several different fonts at once. This is true for displays
1723 that use a window system such as X, and false for text-only terminals.
1724 DISPLAY can be a display name, a frame, or nil (meaning the selected
1726 (not (null (memq (framep-on-display display
) '(x w32 ns
)))))
1728 (defun display-images-p (&optional display
)
1729 "Return non-nil if DISPLAY can display images.
1731 DISPLAY can be a display name, a frame, or nil (meaning the selected
1733 (and (display-graphic-p display
)
1734 (fboundp 'image-mask-p
)
1735 (fboundp 'image-size
)))
1737 (defalias 'display-multi-frame-p
'display-graphic-p
)
1738 (defalias 'display-multi-font-p
'display-graphic-p
)
1740 (defun display-selections-p (&optional display
)
1741 "Return non-nil if DISPLAY supports selections.
1742 A selection is a way to transfer text or other data between programs
1743 via special system buffers called `selection' or `clipboard'.
1744 DISPLAY can be a display name, a frame, or nil (meaning the selected
1746 (let ((frame-type (framep-on-display display
)))
1748 ((eq frame-type
'pc
)
1749 ;; MS-DOS frames support selections when Emacs runs inside
1750 ;; a Windows DOS Box.
1752 (not (null dos-windows-version
))))
1753 ((memq frame-type
'(x w32 ns
))
1758 (declare-function x-display-screens
"xfns.c" (&optional terminal
))
1760 (defun display-screens (&optional display
)
1761 "Return the number of screens associated with DISPLAY.
1762 DISPLAY should be either a frame or a display name (a string).
1763 If DISPLAY is omitted or nil, it defaults to the selected frame's display."
1764 (let ((frame-type (framep-on-display display
)))
1766 ((memq frame-type
'(x w32 ns
))
1767 (x-display-screens display
))
1771 (declare-function x-display-pixel-height
"xfns.c" (&optional terminal
))
1773 (defun display-pixel-height (&optional display
)
1774 "Return the height of DISPLAY's screen in pixels.
1775 DISPLAY can be a display name or a frame.
1776 If DISPLAY is omitted or nil, it defaults to the selected frame's display.
1778 For character terminals, each character counts as a single pixel.
1780 For graphical terminals, note that on \"multi-monitor\" setups this
1781 refers to the pixel height for all physical monitors associated
1782 with DISPLAY. To get information for each physical monitor, use
1783 `display-monitor-attributes-list'."
1784 (let ((frame-type (framep-on-display display
)))
1786 ((memq frame-type
'(x w32 ns
))
1787 (x-display-pixel-height display
))
1789 (frame-height (if (framep display
) display
(selected-frame)))))))
1791 (declare-function x-display-pixel-width
"xfns.c" (&optional terminal
))
1793 (defun display-pixel-width (&optional display
)
1794 "Return the width of DISPLAY's screen in pixels.
1795 DISPLAY can be a display name or a frame.
1796 If DISPLAY is omitted or nil, it defaults to the selected frame's display.
1798 For character terminals, each character counts as a single pixel.
1800 For graphical terminals, note that on \"multi-monitor\" setups this
1801 refers to the pixel width for all physical monitors associated
1802 with DISPLAY. To get information for each physical monitor, use
1803 `display-monitor-attributes-list'."
1804 (let ((frame-type (framep-on-display display
)))
1806 ((memq frame-type
'(x w32 ns
))
1807 (x-display-pixel-width display
))
1809 (frame-width (if (framep display
) display
(selected-frame)))))))
1811 (defcustom display-mm-dimensions-alist nil
1812 "Alist for specifying screen dimensions in millimeters.
1813 The functions `display-mm-height' and `display-mm-width' consult
1814 this list before asking the system.
1816 Each element has the form (DISPLAY . (WIDTH . HEIGHT)), e.g.
1817 \(\":0.0\" . (287 . 215)).
1819 If `display' is t, it specifies dimensions for all graphical displays
1820 not explicitly specified."
1822 :type
'(alist :key-type
(choice (string :tag
"Display name")
1823 (const :tag
"Default" t
))
1824 :value-type
(cons :tag
"Dimensions"
1825 (integer :tag
"Width")
1826 (integer :tag
"Height")))
1829 (declare-function x-display-mm-height
"xfns.c" (&optional terminal
))
1831 (defun display-mm-height (&optional display
)
1832 "Return the height of DISPLAY's screen in millimeters.
1833 If the information is unavailable, this function returns nil.
1834 DISPLAY can be a display name or a frame.
1835 If DISPLAY is omitted or nil, it defaults to the selected frame's display.
1837 You can override what the system thinks the result should be by
1838 adding an entry to `display-mm-dimensions-alist'.
1840 For graphical terminals, note that on \"multi-monitor\" setups this
1841 refers to the height in millimeters for all physical monitors
1842 associated with DISPLAY. To get information for each physical
1843 monitor, use `display-monitor-attributes-list'."
1844 (and (memq (framep-on-display display
) '(x w32 ns
))
1845 (or (cddr (assoc (or display
(frame-parameter nil
'display
))
1846 display-mm-dimensions-alist
))
1847 (cddr (assoc t display-mm-dimensions-alist
))
1848 (x-display-mm-height display
))))
1850 (declare-function x-display-mm-width
"xfns.c" (&optional terminal
))
1852 (defun display-mm-width (&optional display
)
1853 "Return the width of DISPLAY's screen in millimeters.
1854 If the information is unavailable, this function returns nil.
1855 DISPLAY can be a display name or a frame.
1856 If DISPLAY is omitted or nil, it defaults to the selected frame's display.
1858 You can override what the system thinks the result should be by
1859 adding an entry to `display-mm-dimensions-alist'.
1861 For graphical terminals, note that on \"multi-monitor\" setups this
1862 refers to the width in millimeters for all physical monitors
1863 associated with DISPLAY. To get information for each physical
1864 monitor, use `display-monitor-attributes-list'."
1865 (and (memq (framep-on-display display
) '(x w32 ns
))
1866 (or (cadr (assoc (or display
(frame-parameter nil
'display
))
1867 display-mm-dimensions-alist
))
1868 (cadr (assoc t display-mm-dimensions-alist
))
1869 (x-display-mm-width display
))))
1871 (declare-function x-display-backing-store
"xfns.c" (&optional terminal
))
1873 ;; In NS port, the return value may be `buffered', `retained', or
1874 ;; `non-retained'. See src/nsfns.m.
1875 (defun display-backing-store (&optional display
)
1876 "Return the backing store capability of DISPLAY's screen.
1877 The value may be `always', `when-mapped', `not-useful', or nil if
1878 the question is inapplicable to a certain kind of display.
1879 DISPLAY can be a display name or a frame.
1880 If DISPLAY is omitted or nil, it defaults to the selected frame's display."
1881 (let ((frame-type (framep-on-display display
)))
1883 ((memq frame-type
'(x w32 ns
))
1884 (x-display-backing-store display
))
1888 (declare-function x-display-save-under
"xfns.c" (&optional terminal
))
1890 (defun display-save-under (&optional display
)
1891 "Return non-nil if DISPLAY's screen supports the SaveUnder feature.
1892 DISPLAY can be a display name or a frame.
1893 If DISPLAY is omitted or nil, it defaults to the selected frame's display."
1894 (let ((frame-type (framep-on-display display
)))
1896 ((memq frame-type
'(x w32 ns
))
1897 (x-display-save-under display
))
1901 (declare-function x-display-planes
"xfns.c" (&optional terminal
))
1903 (defun display-planes (&optional display
)
1904 "Return the number of planes supported by DISPLAY.
1905 DISPLAY can be a display name or a frame.
1906 If DISPLAY is omitted or nil, it defaults to the selected frame's display."
1907 (let ((frame-type (framep-on-display display
)))
1909 ((memq frame-type
'(x w32 ns
))
1910 (x-display-planes display
))
1911 ((eq frame-type
'pc
)
1914 (truncate (log (length (tty-color-alist)) 2))))))
1916 (declare-function x-display-color-cells
"xfns.c" (&optional terminal
))
1918 (defun display-color-cells (&optional display
)
1919 "Return the number of color cells supported by DISPLAY.
1920 DISPLAY can be a display name or a frame.
1921 If DISPLAY is omitted or nil, it defaults to the selected frame's display."
1922 (let ((frame-type (framep-on-display display
)))
1924 ((memq frame-type
'(x w32 ns
))
1925 (x-display-color-cells display
))
1926 ((eq frame-type
'pc
)
1929 (tty-display-color-cells display
)))))
1931 (declare-function x-display-visual-class
"xfns.c" (&optional terminal
))
1933 (defun display-visual-class (&optional display
)
1934 "Return the visual class of DISPLAY.
1935 The value is one of the symbols `static-gray', `gray-scale',
1936 `static-color', `pseudo-color', `true-color', or `direct-color'.
1937 DISPLAY can be a display name or a frame.
1938 If DISPLAY is omitted or nil, it defaults to the selected frame's display."
1939 (let ((frame-type (framep-on-display display
)))
1941 ((memq frame-type
'(x w32 ns
))
1942 (x-display-visual-class display
))
1943 ((and (memq frame-type
'(pc t
))
1944 (tty-display-color-p display
))
1949 (declare-function x-display-monitor-attributes-list
"xfns.c"
1950 (&optional terminal
))
1951 (declare-function w32-display-monitor-attributes-list
"w32fns.c"
1952 (&optional display
))
1953 (declare-function ns-display-monitor-attributes-list
"nsfns.m"
1954 (&optional terminal
))
1956 (defun display-monitor-attributes-list (&optional display
)
1957 "Return a list of physical monitor attributes on DISPLAY.
1958 DISPLAY can be a display name, a terminal name, or a frame.
1959 If DISPLAY is omitted or nil, it defaults to the selected frame's display.
1960 Each element of the list represents the attributes of a physical
1961 monitor. The first element corresponds to the primary monitor.
1963 The attributes for a physical monitor are represented as an alist
1964 of attribute keys and values as follows:
1966 geometry -- Position and size in pixels in the form of (X Y WIDTH HEIGHT)
1967 workarea -- Position and size of the work area in pixels in the
1968 form of (X Y WIDTH HEIGHT)
1969 mm-size -- Width and height in millimeters in the form of
1971 frames -- List of frames dominated by the physical monitor
1972 name (*) -- Name of the physical monitor as a string
1973 source (*) -- Source of multi-monitor information as a string
1975 where X, Y, WIDTH, and HEIGHT are integers. X and Y are coordinates
1976 of the top-left corner, and might be negative for monitors other than
1977 the primary one. Keys labeled with (*) are optional.
1979 The \"work area\" is a measure of the \"usable\" display space.
1980 It may be less than the total screen size, owing to space taken up
1981 by window manager features (docks, taskbars, etc.). The precise
1982 details depend on the platform and environment.
1984 The `source' attribute describes the source from which the information
1985 was obtained. On X, this may be one of: \"Gdk\", \"XRandr\", \"Xinerama\",
1988 A frame is dominated by a physical monitor when either the
1989 largest area of the frame resides in the monitor, or the monitor
1990 is the closest to the frame if the frame does not intersect any
1991 physical monitors. Every (non-tooltip) frame (including invisible ones)
1992 in a graphical display is dominated by exactly one physical
1993 monitor at a time, though it can span multiple (or no) physical
1995 (let ((frame-type (framep-on-display display
)))
1998 (x-display-monitor-attributes-list display
))
1999 ((eq frame-type
'w32
)
2000 (w32-display-monitor-attributes-list display
))
2001 ((eq frame-type
'ns
)
2002 (ns-display-monitor-attributes-list display
))
2004 (let ((geometry (list 0 0 (display-pixel-width display
)
2005 (display-pixel-height display
))))
2006 `(((geometry .
,geometry
)
2007 (workarea .
,geometry
)
2008 (mm-size .
(,(display-mm-width display
)
2009 ,(display-mm-height display
)))
2010 (frames .
,(frames-on-display-list display
)))))))))
2013 ;;;; Frame geometry values
2015 (defun frame-geom-value-cons (type value
&optional frame
)
2016 "Return equivalent geometry value for FRAME as a cons with car `+'.
2017 A geometry value equivalent to VALUE for FRAME is returned,
2018 where the value is a cons with car `+', not numeric.
2019 TYPE is the car of the original geometry spec (TYPE . VALUE).
2020 It is `top' or `left', depending on which edge VALUE is related to.
2021 VALUE is the cdr of a frame geometry spec: (left/top . VALUE).
2022 If VALUE is a number, then it is converted to a cons value, perhaps
2023 relative to the opposite frame edge from that in the original spec.
2024 FRAME defaults to the selected frame.
2026 Examples (measures in pixels) -
2027 Assuming display height/width=1024, frame height/width=600:
2028 300 inside display edge: 300 => (+ 300)
2030 300 inside opposite display edge: (- 300) => (+ 124)
2032 300 beyond display edge
2033 (= 724 inside opposite display edge): (+ -300) => (+ -300)
2034 300 beyond display edge
2035 (= 724 inside opposite display edge): (- -300) => (+ 724)
2037 In the 3rd, 4th, and 6th examples, the returned value is relative to
2038 the opposite frame edge from the edge indicated in the input spec."
2039 (cond ((and (consp value
) (eq '+ (car value
))) ; e.g. (+ 300), (+ -300)
2041 ((natnump value
) (list '+ value
)) ; e.g. 300 => (+ 300)
2042 (t ; e.g. -300, (- 300), (- -300)
2043 (list '+ (- (if (eq 'left type
) ; => (+ 124), (+ 124), (+ 724)
2044 (x-display-pixel-width)
2045 (x-display-pixel-height))
2046 (if (integerp value
) (- value
) (cadr value
))
2048 (frame-pixel-width frame
)
2049 (frame-pixel-height frame
)))))))
2051 (defun frame-geom-spec-cons (spec &optional frame
)
2052 "Return equivalent geometry spec for FRAME as a cons with car `+'.
2053 A geometry specification equivalent to SPEC for FRAME is returned,
2054 where the value is a cons with car `+', not numeric.
2055 SPEC is a frame geometry spec: (left . VALUE) or (top . VALUE).
2056 If VALUE is a number, then it is converted to a cons value, perhaps
2057 relative to the opposite frame edge from that in the original spec.
2058 FRAME defaults to the selected frame.
2060 Examples (measures in pixels) -
2061 Assuming display height=1024, frame height=600:
2062 top 300 below display top: (top . 300) => (top + 300)
2063 (top + 300) => (top + 300)
2064 bottom 300 above display bottom: (top - 300) => (top + 124)
2065 (top . -300) => (top + 124)
2066 top 300 above display top
2067 (= bottom 724 above display bottom): (top + -300) => (top + -300)
2068 bottom 300 below display bottom
2069 (= top 724 below display top): (top - -300) => (top + 724)
2071 In the 3rd, 4th, and 6th examples, the returned value is relative to
2072 the opposite frame edge from the edge indicated in the input spec."
2073 (cons (car spec
) (frame-geom-value-cons (car spec
) (cdr spec
) frame
)))
2075 (defun delete-other-frames (&optional frame
)
2076 "Delete all frames on FRAME's terminal, except FRAME.
2077 If FRAME uses another frame's minibuffer, the minibuffer frame is
2078 left untouched. Do not delete any of FRAME's child frames. If
2079 FRAME is a child frame, delete its siblings only. FRAME must be
2080 a live frame and defaults to the selected one."
2082 (setq frame
(window-normalize-frame frame
))
2083 (let ((minibuffer-frame (window-frame (minibuffer-window frame
)))
2084 (this (next-frame frame t
))
2085 (parent (frame-parent frame
))
2087 ;; In a first round consider minibuffer-less frames only.
2088 (while (not (eq this frame
))
2089 (setq next
(next-frame this t
))
2090 (unless (or (eq (window-frame (minibuffer-window this
)) this
)
2091 ;; When FRAME is a child frame, delete its siblings
2093 (and parent
(not (eq (frame-parent this
) parent
)))
2094 ;; Do not delete a child frame of FRAME.
2095 (eq (frame-parent this
) frame
))
2096 (delete-frame this
))
2098 ;; In a second round consider all remaining frames.
2099 (setq this
(next-frame frame t
))
2100 (while (not (eq this frame
))
2101 (setq next
(next-frame this t
))
2102 (unless (or (eq this minibuffer-frame
)
2103 ;; When FRAME is a child frame, delete its siblings
2105 (and parent
(not (eq (frame-parent this
) parent
)))
2106 ;; Do not delete a child frame of FRAME.
2107 (eq (frame-parent this
) frame
))
2108 (delete-frame this
))
2112 ;;; Window dividers.
2113 (defgroup window-divider nil
2119 (defcustom window-divider-default-places
'right-only
2120 "Default positions of window dividers.
2121 Possible values are `bottom-only' (dividers on the bottom of each
2122 window only), `right-only' (dividers on the right of each window
2123 only), and t (dividers on the bottom and on the right of each
2124 window). The default is `right-only'.
2126 The value takes effect if and only if dividers are enabled by
2127 `window-divider-mode'.
2129 To position dividers on frames individually, use the frame
2130 parameters `bottom-divider-width' and `right-divider-width'."
2131 :type
'(choice (const :tag
"Bottom only" bottom-only
)
2132 (const :tag
"Right only" right-only
)
2133 (const :tag
"Bottom and right" t
))
2134 :initialize
'custom-initialize-default
2135 :set
(lambda (symbol value
)
2136 (set-default symbol value
)
2137 (when window-divider-mode
2138 (window-divider-mode-apply t
)))
2141 (defun window-divider-width-valid-p (value)
2142 "Return non-nil if VALUE is a positive number."
2143 (and (numberp value
) (> value
0)))
2145 (defcustom window-divider-default-bottom-width
6
2146 "Default width of dividers on bottom of windows.
2147 The value must be a positive integer and takes effect when bottom
2148 dividers are displayed by `window-divider-mode'.
2150 To adjust bottom dividers for frames individually, use the frame
2151 parameter `bottom-divider-width'."
2152 :type
'(restricted-sexp
2153 :tag
"Default width of bottom dividers"
2154 :match-alternatives
(window-divider-width-valid-p))
2155 :initialize
'custom-initialize-default
2156 :set
(lambda (symbol value
)
2157 (set-default symbol value
)
2158 (when window-divider-mode
2159 (window-divider-mode-apply t
)))
2162 (defcustom window-divider-default-right-width
6
2163 "Default width of dividers on the right of windows.
2164 The value must be a positive integer and takes effect when right
2165 dividers are displayed by `window-divider-mode'.
2167 To adjust right dividers for frames individually, use the frame
2168 parameter `right-divider-width'."
2169 :type
'(restricted-sexp
2170 :tag
"Default width of right dividers"
2171 :match-alternatives
(window-divider-width-valid-p))
2172 :initialize
'custom-initialize-default
2173 :set
(lambda (symbol value
)
2174 (set-default symbol value
)
2175 (when window-divider-mode
2176 (window-divider-mode-apply t
)))
2179 (defun window-divider-mode-apply (enable)
2180 "Apply window divider places and widths to all frames.
2181 If ENABLE is nil, apply default places and widths. Else reset
2182 all divider widths to zero."
2183 (let ((bottom (if (and enable
2184 (memq window-divider-default-places
2186 window-divider-default-bottom-width
2188 (right (if (and enable
2189 (memq window-divider-default-places
2191 window-divider-default-right-width
2193 (modify-all-frames-parameters
2194 (list (cons 'bottom-divider-width bottom
)
2195 (cons 'right-divider-width right
)))
2196 (setq default-frame-alist
2198 'bottom-divider-width default-frame-alist
))
2199 (setq default-frame-alist
2201 'right-divider-width default-frame-alist
))
2203 (setq default-frame-alist
2205 (cons 'bottom-divider-width bottom
)
2206 default-frame-alist
)))
2208 (setq default-frame-alist
2210 (cons 'right-divider-width right
)
2211 default-frame-alist
)))))
2213 (define-minor-mode window-divider-mode
2214 "Display dividers between windows (Window Divider mode).
2215 With a prefix argument ARG, enable Window Divider mode if ARG is
2216 positive, and disable it otherwise. If called from Lisp, enable
2217 the mode if ARG is omitted or nil.
2219 The option `window-divider-default-places' specifies on which
2220 side of a window dividers are displayed. The options
2221 `window-divider-default-bottom-width' and
2222 `window-divider-default-right-width' specify their respective
2224 :group
'window-divider
2226 (window-divider-mode-apply window-divider-mode
))
2230 (defvar blink-cursor-idle-timer nil
2231 "Timer started after `blink-cursor-delay' seconds of Emacs idle time.
2232 The function `blink-cursor-start' is called when the timer fires.")
2234 (defvar blink-cursor-timer nil
2235 "Timer started from `blink-cursor-start'.
2236 This timer calls `blink-cursor-timer-function' every
2237 `blink-cursor-interval' seconds.")
2239 (defgroup cursor nil
2240 "Displaying text cursors."
2244 (defcustom blink-cursor-delay
0.5
2245 "Seconds of idle time before the first blink of the cursor.
2246 Values smaller than 0.2 sec are treated as 0.2 sec."
2249 :set
(lambda (symbol value
)
2250 (set-default symbol value
)
2251 (when blink-cursor-idle-timer
(blink-cursor--start-idle-timer))))
2253 (defcustom blink-cursor-interval
0.5
2254 "Length of cursor blink interval in seconds."
2257 :set
(lambda (symbol value
)
2258 (set-default symbol value
)
2259 (when blink-cursor-timer
(blink-cursor--start-timer))))
2261 (defcustom blink-cursor-blinks
10
2262 "How many times to blink before using a solid cursor on NS, X, and MS-Windows.
2263 Use 0 or negative value to blink forever."
2268 (defvar blink-cursor-blinks-done
1
2269 "Number of blinks done since we started blinking on NS, X, and MS-Windows.")
2271 (defun blink-cursor--start-idle-timer ()
2272 "Start the `blink-cursor-idle-timer'."
2273 (when blink-cursor-idle-timer
(cancel-timer blink-cursor-idle-timer
))
2274 (setq blink-cursor-idle-timer
2275 ;; The 0.2 sec limitation from below is to avoid erratic
2276 ;; behavior (or downright failure to display the cursor
2277 ;; during command execution) if they set blink-cursor-delay
2278 ;; to a very small or even zero value.
2279 (run-with-idle-timer (max 0.2 blink-cursor-delay
)
2280 :repeat
#'blink-cursor-start
)))
2282 (defun blink-cursor--start-timer ()
2283 "Start the `blink-cursor-timer'."
2284 (when blink-cursor-timer
(cancel-timer blink-cursor-timer
))
2285 (setq blink-cursor-timer
2286 (run-with-timer blink-cursor-interval blink-cursor-interval
2287 #'blink-cursor-timer-function
)))
2289 (defun blink-cursor-start ()
2290 "Timer function called from the timer `blink-cursor-idle-timer'.
2291 This starts the timer `blink-cursor-timer', which makes the cursor blink
2292 if appropriate. It also arranges to cancel that timer when the next
2293 command starts, by installing a pre-command hook."
2294 (when (null blink-cursor-timer
)
2295 ;; Set up the timer first, so that if this signals an error,
2296 ;; blink-cursor-end is not added to pre-command-hook.
2297 (setq blink-cursor-blinks-done
1)
2298 (blink-cursor--start-timer)
2299 (add-hook 'pre-command-hook
'blink-cursor-end
)
2300 (internal-show-cursor nil nil
)))
2302 (defun blink-cursor-timer-function ()
2303 "Timer function of timer `blink-cursor-timer'."
2304 (internal-show-cursor nil
(not (internal-show-cursor-p)))
2305 ;; Suspend counting blinks when the w32 menu-bar menu is displayed,
2306 ;; since otherwise menu tooltips will behave erratically.
2307 (or (and (fboundp 'w32--menu-bar-in-use
)
2308 (w32--menu-bar-in-use))
2309 (setq blink-cursor-blinks-done
(1+ blink-cursor-blinks-done
)))
2310 ;; Each blink is two calls to this function.
2311 (when (and (> blink-cursor-blinks
0)
2312 (<= (* 2 blink-cursor-blinks
) blink-cursor-blinks-done
))
2313 (blink-cursor-suspend)
2314 (add-hook 'post-command-hook
'blink-cursor-check
)))
2316 (defun blink-cursor-end ()
2317 "Stop cursor blinking.
2318 This is installed as a pre-command hook by `blink-cursor-start'.
2319 When run, it cancels the timer `blink-cursor-timer' and removes
2320 itself as a pre-command hook."
2321 (remove-hook 'pre-command-hook
'blink-cursor-end
)
2322 (internal-show-cursor nil t
)
2323 (when blink-cursor-timer
2324 (cancel-timer blink-cursor-timer
)
2325 (setq blink-cursor-timer nil
)))
2327 (defun blink-cursor-suspend ()
2328 "Suspend cursor blinking.
2329 This is called when no frame has focus and timers can be suspended.
2330 Timers are restarted by `blink-cursor-check', which is called when a
2331 frame receives focus."
2333 (when blink-cursor-idle-timer
2334 (cancel-timer blink-cursor-idle-timer
)
2335 (setq blink-cursor-idle-timer nil
)))
2337 (defun blink-cursor-check ()
2338 "Check if cursor blinking shall be restarted.
2339 This is done when a frame gets focus. Blink timers may be stopped by
2340 `blink-cursor-suspend'."
2341 (when (and blink-cursor-mode
2342 (not blink-cursor-idle-timer
))
2343 (remove-hook 'post-command-hook
'blink-cursor-check
)
2344 (blink-cursor--start-idle-timer)))
2346 (define-minor-mode blink-cursor-mode
2347 "Toggle cursor blinking (Blink Cursor mode).
2348 With a prefix argument ARG, enable Blink Cursor mode if ARG is
2349 positive, and disable it otherwise. If called from Lisp, enable
2350 the mode if ARG is omitted or nil.
2352 If the value of `blink-cursor-blinks' is positive (10 by default),
2353 the cursor stops blinking after that number of blinks, if Emacs
2354 gets no input during that time.
2356 See also `blink-cursor-interval' and `blink-cursor-delay'.
2358 This command is effective only on graphical frames. On text-only
2359 terminals, cursor blinking is controlled by the terminal."
2360 :init-value
(not (or noninteractive
2362 (eq system-type
'ms-dos
)
2363 (not (memq window-system
'(x w32 ns
)))))
2364 :initialize
'custom-initialize-delay
2367 (blink-cursor-suspend)
2368 (remove-hook 'focus-in-hook
#'blink-cursor-check
)
2369 (remove-hook 'focus-out-hook
#'blink-cursor-suspend
)
2370 (when blink-cursor-mode
2371 (add-hook 'focus-in-hook
#'blink-cursor-check
)
2372 (add-hook 'focus-out-hook
#'blink-cursor-suspend
)
2373 (blink-cursor--start-idle-timer)))
2376 ;; Frame maximization/fullscreen
2378 (defun toggle-frame-maximized (&optional frame
)
2379 "Toggle maximization state of FRAME.
2380 Maximize selected frame or un-maximize if it is already maximized.
2382 If the frame is in fullscreen state, don't change its state, but
2383 set the frame's `fullscreen-restore' parameter to `maximized', so
2384 the frame will be maximized after disabling fullscreen state.
2386 Note that with some window managers you may have to set
2387 `frame-resize-pixelwise' to non-nil in order to make a frame
2388 appear truly maximized. In addition, you may have to set
2389 `x-frame-normalize-before-maximize' in order to enable
2390 transitions from one fullscreen state to another.
2392 See also `toggle-frame-fullscreen'."
2394 (let ((fullscreen (frame-parameter frame
'fullscreen
)))
2396 ((memq fullscreen
'(fullscreen fullboth
))
2397 (set-frame-parameter frame
'fullscreen-restore
'maximized
))
2398 ((eq fullscreen
'maximized
)
2399 (set-frame-parameter frame
'fullscreen nil
))
2401 (set-frame-parameter frame
'fullscreen
'maximized
)))))
2403 (defun toggle-frame-fullscreen (&optional frame
)
2404 "Toggle fullscreen state of FRAME.
2405 Make selected frame fullscreen or restore its previous size
2406 if it is already fullscreen.
2408 Before making the frame fullscreen remember the current value of
2409 the frame's `fullscreen' parameter in the `fullscreen-restore'
2410 parameter of the frame. That value is used to restore the
2411 frame's fullscreen state when toggling fullscreen the next time.
2413 Note that with some window managers you may have to set
2414 `frame-resize-pixelwise' to non-nil in order to make a frame
2415 appear truly fullscreen. In addition, you may have to set
2416 `x-frame-normalize-before-maximize' in order to enable
2417 transitions from one fullscreen state to another.
2419 See also `toggle-frame-maximized'."
2421 (let ((fullscreen (frame-parameter frame
'fullscreen
)))
2422 (if (memq fullscreen
'(fullscreen fullboth
))
2423 (let ((fullscreen-restore (frame-parameter frame
'fullscreen-restore
)))
2424 (if (memq fullscreen-restore
'(maximized fullheight fullwidth
))
2425 (set-frame-parameter frame
'fullscreen fullscreen-restore
)
2426 (set-frame-parameter frame
'fullscreen nil
)))
2427 (modify-frame-parameters
2428 frame
`((fullscreen . fullboth
) (fullscreen-restore .
,fullscreen
))))
2429 ;; Manipulating a frame without waiting for the fullscreen
2430 ;; animation to complete can cause a crash, or other unexpected
2431 ;; behavior, on macOS (bug#28496).
2432 (when (featurep 'cocoa
) (sleep-for 0.5))))
2437 (define-key ctl-x-5-map
"2" 'make-frame-command
)
2438 (define-key ctl-x-5-map
"1" 'delete-other-frames
)
2439 (define-key ctl-x-5-map
"0" 'delete-frame
)
2440 (define-key ctl-x-5-map
"o" 'other-frame
)
2441 (define-key global-map
[f11] 'toggle-frame-fullscreen)
2442 (define-key global-map [(meta f10)] 'toggle-frame-maximized)
2443 (define-key esc-map [f10] 'toggle-frame-maximized)
2448 ;; Only marked as obsolete in 24.3.
2449 (define-obsolete-variable-alias 'automatic-hscrolling
2450 'auto-hscroll-mode "22.1")
2452 (make-variable-buffer-local 'show-trailing-whitespace)
2454 ;; Defined in dispnew.c.
2455 (make-obsolete-variable
2456 'window-system-version "it does not give useful information." "24.3")
2458 ;; Variables whose change of value should trigger redisplay of the
2460 ;; To test whether a given variable needs to be added to this list,
2461 ;; write a simple interactive function that changes the variable's
2462 ;; value and bind that function to a simple key, like F5. If typing
2463 ;; F5 then produces the correct effect, the variable doesn't need
2464 ;; to be in this list; otherwise, it does.
2466 (add-variable-watcher var (symbol-function 'set-buffer-redisplay)))
2472 display-line-numbers
2473 display-line-numbers-width
2474 display-line-numbers-current-absolute
2475 display-line-numbers-widen
2476 bidi-paragraph-direction
2477 bidi-display-reordering))
2481 ;;; frame.el ends here