Function: xterm--init
xterm--init is a byte-compiled function defined in xterm.el.gz.
Signature
(xterm--init)
Documentation
Initialize the terminal for xterm.
Source Code
;; Defined in /usr/src/emacs/lisp/term/xterm.el.gz
(defun xterm--init ()
"Initialize the terminal for xterm."
;; rxvt terminals sometimes set the TERM variable to "xterm", but
;; rxvt's keybindings are incompatible with xterm's. It is
;; better in that case to use rxvt's initialization function.
(if (and (getenv "COLORTERM" (selected-frame))
(string-match "\\`rxvt" (getenv "COLORTERM" (selected-frame))))
(tty-run-terminal-initialization (selected-frame) "rxvt")
(xterm--push-map xterm-alternatives-map local-function-key-map)
(xterm--push-map xterm-function-map input-decode-map))
(xterm-register-default-colors xterm-standard-colors)
(tty-set-up-initial-frame-faces)
(if (eq xterm-extra-capabilities 'check)
(progn
;; Try to find out the type of terminal by sending a "Secondary
;; Device Attributes (DA)" query.
(xterm--query "\e[>0c"
'(("\e[>" . xterm--version-handler)))
;; Check primary DA for OSC-52 support
(xterm--query "\e[c"
'(("\e[?" . xterm--primary-da-handler))))
(when (memq 'reportBackground xterm-extra-capabilities)
(xterm--query "\e]11;?\e\\"
'(("\e]11;" . xterm--report-background-handler)))
(xterm--query "\e]10;?\e\\"
'(("\e]10;" . xterm--report-foreground-handler))))
(when (memq 'modifyOtherKeys xterm-extra-capabilities)
(xterm--init-modify-other-keys))
(when (memq 'getSelection xterm-extra-capabilities)
(xterm--init-activate-get-selection))
(when (memq 'setSelection xterm-extra-capabilities)
(xterm--init-activate-set-selection)))
(when xterm-set-window-title
(xterm--init-frame-title))
(when xterm-update-cursor
(xterm--init-update-cursor))
(let ((bg-color (terminal-parameter nil 'xterm--background-color))
(fg-color (terminal-parameter nil 'xterm--foreground-color)))
(when bg-color
(let ((recompute-faces
(apply #'xterm--set-background-mode bg-color)))
;; Recompute faces here in case the background mode was
;; set to dark. We used to call
;; `tty-set-up-initial-frame-faces' only once, but that
;; caused the light background faces to be computed
;; incorrectly. See:
;; https://lists.gnu.org/r/emacs-devel/2010-01/msg00439.html
(when recompute-faces
(tty-set-up-initial-frame-faces))))
(when (or bg-color fg-color)
(add-hook 'after-make-frame-functions 'xterm--maybe-update-default-face)
;; Manually update, after-make-frame-functions was already called
;; for initial frame.
(xterm--maybe-update-default-face (selected-frame))))
(when (and (not xterm-mouse-mode-called)
;; Only automatically enable xterm mouse on terminals
;; confirmed to still support all critical editing
;; workflows (bug#74833).
(or (string-match-p xterm--auto-xt-mouse-allowed-types
(tty-type (selected-frame)))
(and-let* ((name-and-version (xterm--query-name-and-version)))
(string-match-p xterm--auto-xt-mouse-allowed-names
name-and-version))))
(xterm-mouse-mode 1))
;; Unconditionally enable bracketed paste mode: terminals that don't
;; support it just ignore the sequence.
(xterm--init-bracketed-paste-mode)
;; We likewise unconditionally enable support for focus tracking.
(xterm--init-focus-tracking))