Function: tty-run-terminal-initialization

tty-run-terminal-initialization is a byte-compiled function defined in faces.el.gz.

Signature

(tty-run-terminal-initialization FRAME &optional TYPE RUN-HOOK)

Documentation

Run the special initialization code for the terminal type of FRAME.

The optional TYPE parameter may be used to override the autodetected terminal type to a different value.

This consults term-file-aliases to map terminal types to their aliases.

If optional argument RUN-HOOK is non-nil, then as a final step, this runs the hook tty-setup-hook.

If you set term-file-prefix to nil, this function does nothing.

Probably introduced at or before Emacs version 25.1.

Source Code

;; Defined in /usr/src/emacs/lisp/faces.el.gz
(defun tty-run-terminal-initialization (frame &optional type run-hook)
  "Run the special initialization code for the terminal type of FRAME.
The optional TYPE parameter may be used to override the autodetected
terminal type to a different value.

This consults `term-file-aliases' to map terminal types to their aliases.

If optional argument RUN-HOOK is non-nil, then as a final step,
this runs the hook `tty-setup-hook'.

If you set `term-file-prefix' to nil, this function does nothing."
  (setq type (or type (tty-type frame)))
  (let ((alias (tty-find-type
		(lambda (typ) (assoc typ term-file-aliases)) type)))
    (if alias (setq type (cdr (assoc alias term-file-aliases)))))
  ;; Load library for our terminal type.
  ;; User init file can set term-file-prefix to nil to prevent this.
  (with-selected-frame frame
    (unless (null term-file-prefix)
      (let* (term-init-func)
	;; First, load the terminal initialization file, if it is
	;; available and it hasn't been loaded already.
        (tty-find-type (lambda (type)
                         (let ((file (locate-library (concat term-file-prefix type))))
                           (and file
                                (or (assoc file load-history)
                                    (load (replace-regexp-in-string
                                           "\\.el\\(\\.gz\\)?\\'" ""
                                           file)
                                          t t)))))
                       type)
	;; Next, try to find a matching initialization function, and call it.
        (tty-find-type (lambda (type)
                         (fboundp (setq term-init-func
                                        (intern (concat "terminal-init-" type)))))
		       type)
	(when (fboundp term-init-func)
	  (funcall term-init-func))
	(set-terminal-parameter frame 'terminal-initted term-init-func)
	(if run-hook (run-hooks 'tty-setup-hook))))))