I.11 Miscellaneous Windows-specific features

This section describes Windows-specific features that don’t fit anywhere else.

The variable w32-use-visible-system-caret is a flag that determines whether to make the system caret visible. The default when no screen reader software is in use is nil, which means Emacs draws its own cursor to indicate the position of point. A non-nil value means Emacs will indicate point location with the system caret; this facilitates use of screen reader software, and is the default when such software is detected when running Emacs. When this variable is non-nil, other variables affecting the cursor display have no effect.

The variable w32-grab-focus-on-raise, if set to a non-nil value causes a frame to grab focus when it is raised. The default is t, which fits well with the Windows default click-to-focus policy.

On Windows 10 (version 1809 and higher) and Windows 11, Emacs title bars and scroll bars by default follow the system’s Light or Dark mode, similar to other programs such as Explorer and Command Prompt. To change the color mode, select Personalization from Windows Settings, then Colors->Choose your color (or Choose your default app mode or Choose your mode); then restart Emacs. On Windows 11, you can select separate default modes for Windows and for applications.

If you don’t want Emacs to follow the system’s Dark mode setting, customize the variable w32-follow-system-dark-mode to a nil value; then Emacs will use the default Light mode regardless of system-wide settings. Changing the value of this variable affects only the Emacs frames created after the change, so you should set its value in your init file (see The Emacs Initialization File), either directly or via M-x customize-variable, which lets you save the customized value, see Saving Customizations.

The implementation of display functionality for Windows Console differs from the implementation for other terminal emulators, because historically, Windows required use of an idiosyncractic API. That API limited Windows Console display of Emacs to 16 basic colors. With the introduction of Windows Terminal, Microsoft implemented support for ANSI control sequences, modelled on the VT100 and Xterm, as well as 24-bit RBG color display.

The functions w32-use-virtual-terminal and w32-use-virtual-terminal-p can be used to set and inspect (respectively) an internal variable which determines whether this newer mechanism is used for display, or the older one. The internal variable is automatically set based on your terminal’s capabilities on startup. By default, 24-bit RGB color will be used, but other (8, 16, 256) color spaces may be used, by passing the --color command line argument, or setting the value of the tty-color-mode frame parameter.

(w32-use-virtual-terminal-p) evaluates to t if and only if the internal variable has a non-zero numerical value, and otherwise to nil. If it evaluates to t, ANSI escape sequences are used for color, otherwise, the older mechanism is used. The internal variable can be set by evaluating (w32-use-virtual-terminal x), where x is t or nil: if x is t and the feature is supported by your terminal, it will be enabled. Otherwise, the feature will be disabled.