+;; This function is run, by faces.el:tty-create-frame-with-faces, only
+;; for the initial frame (on each terminal, but we have only one).
+;; This works by setting the `terminal-initted' terminal parameter to
+;; this function, the first time `tty-create-frame-with-faces' is
+;; called on that terminal. `tty-create-frame-with-faces' is called
+;; directly from startup.el and also by `make-frame' through
+;; `frame-creation-function-alist'. `make-frame' will call this
+;; function if `msdos-create-frame-with-faces' (see below) is not
+;; found in `frame-creation-function-alist', which means something is
+;; _very_ wrong, because "internal" terminal emulator should not be
+;; turned on if our window-system is not `pc'. Therefore, the only
+;; Right Thing for us to do here is scream bloody murder.
+(defun terminal-init-internal ()
+ "Terminal initialization function for the MS-DOS \"internal\" terminal.
+Errors out because it is not supposed to be called, ever."
+ (error "terminal-init-internal called for window-system `%s'"
+ (window-system)))
+
+(defun msdos-initialize-window-system ()
+ "Initialization function for the `pc' \"window system\"."
+ (or (eq (window-system) 'pc)
+ (error
+ "`msdos-initialize-window-system' called, but window-system is `%s'"
+ (window-system)))
+ ;; First, the keyboard.
+ (msdos-setup-keyboard terminal-frame) ; see internal.el
+ ;; Next, register the default colors.
+ (let* ((colors msdos-color-values)
+ (color (car colors)))
+ (tty-color-clear)
+ (while colors
+ (tty-color-define (car color) (cadr color) (cddr color))
+ (setq colors (cdr colors) color (car colors))))
+ ;; Modifying color mappings means realized faces don't
+ ;; use the right colors, so clear them.
+ (clear-face-cache)
+ ;; Now set up some additional faces.
+ (msdos-face-setup)
+ ;; Set up the initial frame.
+ (msdos-setup-initial-frame)
+ ;; Help echo is displayed in the echo area.
+ (setq show-help-function 'msdos-show-help)
+ ;; We want to delay the codepage-related setup until after user's
+ ;; .emacs is processed, because people might define their
+ ;; `dos-codepage-setup-hook' there.
+ (add-hook 'after-init-hook 'dos-codepage-setup)
+ ;; In multibyte mode, we want unibyte buffers to be displayed
+ ;; using the terminal coding system, so that they display
+ ;; correctly on the DOS terminal; in unibyte mode we want to see
+ ;; all 8-bit characters verbatim. In both cases, we want the
+ ;; entire range of 8-bit characters to arrive at our display code
+ ;; verbatim.
+ (standard-display-8bit 127 255)
+ ;; We are fast enough to make this optimization unnecessary.
+ (setq split-window-keep-point t)
+ ;; Arrange for the kill and yank functions to set and check the
+ ;; clipboard.
+ (setq interprogram-cut-function 'x-select-text)
+ (setq interprogram-paste-function 'x-get-selection-value)
+ (menu-bar-enable-clipboard)
+ (run-hooks 'terminal-init-msdos-hook))
+
+;; frame-creation-function-alist is examined by frame.el:make-frame.
+(add-to-list 'frame-creation-function-alist
+ '(pc . msdos-create-frame-with-faces))
+;; window-system-initialization-alist is examined by startup.el:command-line.
+(add-to-list 'window-system-initialization-alist
+ '(pc . msdos-initialize-window-system))
+;; We don't need anything beyond tty-handle-args for handling
+;; command-line argument; see startup.el.
+(add-to-list 'handle-args-function-alist '(pc . tty-handle-args))
+
+;; ---------------------------------------------------------------------------
+
+(provide 'pc-win)