changeset 83431:76396de7f50a

Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly. * src/termhooks.h (struct device): Rename to `terminal'. Rename member `next_device' to `next_terminal'. (device_list): Rename to `terminal_list'. (FRAME_DEVICE): Rename to `FRAME_TERMINAL'. (DEVICE_TERMINAL_CODING): Rename to `TERMINAL_TERMINAL_CODING'. (TERMINAL_KEYBOARD_CODING): Rename to `TERMINAL_KEYBOARD_CODING'. (DEVICE_ACTIVE_P): Rename to `TERMINAL_ACTIVE_P'. Update declarations and macro definitions. * src/termchar.h (tty_display_info): Rename member `device' to `terminal'. (FRAME_TTY): Update for renames. * src/xterm.h (x_display_info): Rename member `device' to `terminal'. * src/frame.h (frame): Rename `device' member to `terminal'. (FRAME_KBOARD, FRAME_LIVE_P, Qdevice, Qdisplay_live_p): Update for renames. * src/lisp.h (set_process_environment): Rename to `set_global_environment'. (device): Rename to `terminal'. * src/dispextern.h: Update declarations and macro definitions. * src/terminal.c (device_list): Rename to `terminal_list'. (next_device_id): Rename to `next_terminal_id'. (initial_device): Rename to `initial_terminal'. (get_device): Rename to `get_terminal'. (create_device): Rename to `create_terminal'. (mark_devices): Rename to `mark_terminals'. (delete_device): Rename to `delete_terminal'. (Fdelete_display): Rename to `Fdelete_terminal'. (Fframe_terminal): Move here from frame.c. (Fdisplay_live_p): Rename to `Fterminal_live_p'. (Fdisplay_list): Rename to `Fterminal_list'. (Fdisplay_name): Rename to `Fterminal_name'. (init_initial_device): Rename to `init_initial_terminal'. (delete_initial_device): Rename to `delete_initial_terminal'. (ring_bell, update_begin, update_end, set_terminal_window) (cursor_to, raw_cursor_to, clear_to_end, clear_frame) (clear_end_of_line, write_glyphs, insert_glyphs, delete_glyphs) (ins_del_lines, get_terminal_param, store_terminal_param) (Fterminal_parameters, Fterminal_parameter) (Fmodify_terminal_parameters, Fset_terminal_parameter) (syms_of_terminal): Update for renames. * src/term.c (get_tty_device): Rename to `get_tty_terminal'. Update. (Fdisplay_tty_type): Rename to `Ftty_type'. (Fdisplay_controlling_tty_p): Rename to `Fcontrolling_tty_p'. (delete_tty, tty_set_terminal_modes, tty_reset_terminal_modes) (Ftty_display_color_p, Ftty_display_color_cells, get_named_tty) (Ftty_no_underline, Fsuspend_tty, Fresume_tty, create_tty_output) (init_tty, maybe_fatal, delete_tty, syms_of_term): Update for rename. * src/frame.c (Qdevice): Rename to `Qterminal'. (Qdisplay_live_p): Rename to `Qterminal_live_p'. (terminal_frame_count): Rename to `tty_frame_count'. (Fframe_display): Move to terminal.c, rename to `Fframe_terminal'. (make_frame_without_minibuffer, make_initial_frame) (make_terminal_frame, Fmodify_frame_parameters) (do_switch_frame, Fdelete_frame, Fmouse_position) (Fmouse_pixel_position, Fraise_frame, Flower_frame) (Fredirect_frame_focus, set_term_frame_name, syms_of_frame): Update for renames. * src/xdisp.c (message2_nolog, message3_nolog, redisplay_internal) (set_vertical_scroll_bar, redisplay_window, check_x_display_info) (x_set_scroll_bar_foreground, x_set_scroll_bar_background) (Fx_create_frame, Fxw_display_color_p, Fx_display_grayscale_p) (Fx_display_pixel_width, Fx_display_pixel_height) (Fx_display_planes, Fx_display_color_cells) (Fx_server_max_request_size, Fx_server_vendor, Fx_server_version) (Fx_display_screens, Fx_display_mm_height, Fx_display_mm_width) (Fx_display_backing_store, Fx_display_visual_class) (Fx_display_save_under, Fx_close_connection, x_create_tip_frame): Update for renames. * xterm.c (handle_one_xevent): Initialize `f' to NULL. (x_delete_device): Rename to `x_delete_terminal'. (x_create_device): Rename to `x_create_terminal'. (XTset_terminal_modes, XTreset_terminal_modes) (XTread_socket, x_connection_closed, x_term_init) (x_term_init, x_delete_display): Update for renames. * src/dispnew.c (Fredraw_frame, Fsend_string_to_terminal) (Fsend_string_to_terminal, init_display): Update for renames. * src/keyboard.c (push_frame_kboard, pop_kboard, pop_kboard) (kbd_buffer_get_event, read_avail_input, tty_read_avail_input) (interrupt_signal, Fset_output_flow_control) (Fset_input_meta_mode, Fset_quit_char, delete_kboard) (syms_of_keyboard): Update for renames. * src/alloc.c (mark_devices): Update declaration. (Fgarbage_collect): Update for renames. * src/coding.c (Fset_terminal_coding_system_internal) (Fterminal_coding_system4) (Fset_keyboard_coding_system_internal) (Fkeyboard_coding_system): Update for renames. * src/data.c (Fterminal_local_value, Fset_terminal_local_value): Update for renames. * src/minibuf.c (read_minibuf): Update for renames. * src/sysdep.c (init_sys_modes, reset_sys_modes): Update for renames. * xselect.c (x_handle_selection_clear): Update for renames. * lisp/files.el (save-buffers-kill-display): Rename to `save-buffers-kill-terminal'. (save-buffers-kill-terminal, ctl-x-map): Update for renames. * frame.el (make-frame): Rename 'device frame parameter to 'terminal. Update. (frames-on-display-list, framep-on-display, suspend-frame): Update for renames. (selected-display): Rename to `selected-terminal'. * server.el (server-save-buffers-kill-display): Rename to `server-save-buffers-kill-terminal'. (server-delete-client, server-handle-delete-frame) (server-handle-suspend-tty, server-process-filter) (server-switch-buffer): Update for renames. * startup.el (normal-splash-screen, normal-splash-screen): Update for renames. * talk.el (talk): Update for renames. * termdev.el (terminal-id): Update for renames. * xt-mouse.el (turn-on-xterm-mouse-tracking-on-terminal) (turn-off-xterm-mouse-tracking-on-terminal) (xterm-mouse-handle-delete-frame): Update for renames. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-471
author Karoly Lorentey <lorentey@elte.hu>
date Thu, 29 Dec 2005 18:20:26 +0000
parents 10f26433fe3f
children 33e433ac0b1b
files README.multi-tty lisp/files.el lisp/frame.el lisp/server.el lisp/startup.el lisp/talk.el lisp/termdev.el lisp/xt-mouse.el src/alloc.c src/coding.c src/data.c src/dispextern.h src/dispnew.c src/frame.c src/frame.h src/keyboard.c src/keyboard.h src/lisp.h src/minibuf.c src/sysdep.c src/term.c src/termchar.h src/termhooks.h src/terminal.c src/xdisp.c src/xfns.c src/xselect.c src/xterm.c src/xterm.h
diffstat 29 files changed, 982 insertions(+), 973 deletions(-) [+]
line wrap: on
line diff
--- a/README.multi-tty	Thu Dec 29 04:57:14 2005 +0000
+++ b/README.multi-tty	Thu Dec 29 18:20:26 2005 +0000
@@ -9,7 +9,7 @@
 Emacs is notoriously slow at startup, so most people use another
 editor or emacsclient for quick editing jobs from the console.
 Unfortunately, emacsclient was very awkward to use, because it did not
-support opening a new Emacs frame on the current virtual console.
+support opening a new Emacs frame on the current virtual tty.
 Now, with multi-tty support, it can do that.  (Emacsclient starts up
 faster than vi!)
 
@@ -86,7 +86,7 @@
 still needs to be ported to Windows/Mac/DOS, though.)  Both multiple
 tty device support and simultaneous X and tty frame support works
 fine.  Emacsclient has been extended to support opening new tty and X
-frames.  It has been changed open new Emacs frames by default.
+frames.  It has been changed to open new Emacs frames by default.
 
 The multi-tty branch has been scheduled for inclusion in the next
 major release of Emacs (version 23).  I expect the merge into the
@@ -250,9 +250,8 @@
 devices.
 
 Creating new frames on the same tty with C-x 5 2 (make-frame-command)
-works, and they behave the same way as in previous Emacs versions.  If
-you exit emacs, all terminals should be restored to their previous
-states.
+works, and behaves the same way as in previous Emacs versions.  If you
+exit emacs, all terminals should be restored to their previous states.
 
 This is work in progress, and probably full of bugs.  It is a good
 idea to run emacs from gdb, so that you'll have a live instance to
@@ -350,49 +349,50 @@
 
 For the NEWS file:  (Needs much, much work)
 
-** Support for multiple terminal devices has been added.
+** Support for multiple terminal devices and simultaneous graphical
+   and tty frames has been added.  You can test for the presence of
+   this feature in your Lisp code by testing for the `multi-tty'
+   feature.
+
+*** The `window-system' variable has been made frame-local. The new
+    `initial-window-system' variable contains the `window-system'
+    value for the first frame.
 
 *** You can specify a terminal device (`tty' parameter) and a terminal
     type (`tty-type' parameter) to `make-terminal-frame'.
 
-*** You can test for the presence of multiple terminal support by
-    testing for the `multi-tty' feature.
+*** The new function `make-frame-on-tty' allows you to create a new
+    frame on another tty device interactively.
+
+*** The function `make-frame-on-display' now works during a tty
+    session, and `make-frame-on-tty' works during a graphical session.
 
 *** Emacsclient has been extended to support opening a new terminal
     frame. Its behaviour has been changed to open a new Emacs frame by
     default.  Use the -c option to get the old behavior of opening
     files in the currently selected Emacs frame.
 
-*** A make-frame-on-tty function has been added to make it easier to
-    create frames on new terminals.
+*** C-z now invokes `suspend-frame', C-x C-c now invokes
+    `save-buffers-kill-terminal'.
 
 *** New functions: frame-tty-name, frame-tty-type, delete-tty,
-    terminal-local-value, set-terminal-local-value
-
-    terminal-id, terminal-parameters, terminal-parameter,
-    set-terminal-parameter
+    suspend-tty, resume-tty, terminal-id, terminal-parameters,
+    terminal-parameter, set-terminal-parameter,
+    modify-terminal-parameters, environment, let-environment
 
-*** New variables: global-key-translation-map
-
-*** The keymaps key-translation-map and function-key-map are now
-    terminal-local.
+*** New variables: local-key-translation-map, local-function-key-map
 
-** Support for simultaneous graphical and terminal frames has been
-   added.
+*** The `keyboard-translate-table' variable and the terminal and
+    keyboard coding systems have been made terminal-local.
 
-*** The function `make-frame-on-display' now works during a terminal
-    session, and `make-frame-on-tty' works during a graphical session.
-
-*** The `window-system' variable has been made frame-local.
-
-*** The new `initial-window-system' variable contains the
-    `window-system' value for the first frame.
+*** In addition to the global key-translation-map and
+    function-key-map, Emacs has terminal-local
+    local-key-translation-map and local-function-key-map variables,
+    and uses them instead of the global keymaps to set up translations
+    and function key sequences relevant to a specific terminal device.
 
 *** talk.el has been extended for multiple tty support.
 
-*** C-z now invokes `suspend-frame', C-x C-c now invokes
-    `save-buffers-kill-frame'.
-
 * * *
 
 (The rest of this file consists of my development notes and as such it
@@ -518,15 +518,16 @@
     frames-on-display-list		frames-on-terminal-list
 
    The following functions were introduced in the multi-tty branch, and
-   can be renamed without aliases:
+   were renamed without aliases:
 
-    display-controlling-tty-p           terminal-controlling-tty-p
+    delete-display			delete-terminal
+    display-controlling-tty-p           controlling-tty-p
     display-list                        terminal-list
     display-live-p                      terminal-live-p
     display-name                        terminal-name
-    display-tty-type                    terminal-tty-type
-    frame-display                       terminal-of-frame
-    delete-display			delete-terminal
+    display-tty-type                    tty-type
+    frame-display                       frame-terminal
+    selected-display			selected-terminal
 
 ** The single-keyboard mode of MULTI_KBOARD is extremely confusing
    sometimes; Emacs does not respond to stimuli from other keyboards.
--- a/lisp/files.el	Thu Dec 29 04:57:14 2005 +0000
+++ b/lisp/files.el	Thu Dec 29 18:20:26 2005 +0000
@@ -4879,7 +4879,7 @@
 	   (funcall confirm-kill-emacs "Really exit Emacs? "))
        (kill-emacs)))
 
-(defun save-buffers-kill-display (&optional arg)
+(defun save-buffers-kill-terminal (&optional arg)
   "Offer to save each buffer, then kill the current connection.
 If the current frame has no client, kill Emacs itself.
 
@@ -4892,7 +4892,7 @@
 	(frame (selected-frame)))
     (if (null proc)
 	(save-buffers-kill-emacs)
-      (server-save-buffers-kill-display proc arg))))
+      (server-save-buffers-kill-terminal proc arg))))
 
 
 ;; We use /: as a prefix to "quote" a file name
@@ -4991,7 +4991,7 @@
 (define-key ctl-x-map "i" 'insert-file)
 (define-key esc-map "~" 'not-modified)
 (define-key ctl-x-map "\C-d" 'list-directory)
-(define-key ctl-x-map "\C-c" 'save-buffers-kill-display)
+(define-key ctl-x-map "\C-c" 'save-buffers-kill-terminal)
 (define-key ctl-x-map "\C-q" 'toggle-read-only)
 
 (define-key ctl-x-4-map "f" 'find-file-other-window)
--- a/lisp/frame.el	Thu Dec 29 04:57:14 2005 +0000
+++ b/lisp/frame.el	Thu Dec 29 18:20:26 2005 +0000
@@ -651,7 +651,7 @@
  (window-system . nil)	The frame should be displayed on a terminal device.
  (window-system . x)	The frame should be displayed in an X window.
 
- (device . ID)          The frame should use the display device identified by ID.
+ (terminal . ID)          The frame should use the terminal identified by ID.
 
 Before the frame is created (via `frame-creation-function-alist'), functions on the
 hook `before-make-frame-hook' are run.  After the frame is created, functions
@@ -664,11 +664,11 @@
 setup is for focus to follow the pointer."
   (interactive)
   (let* ((w (cond
-	     ((assq 'device parameters)
-	      (let ((type (display-live-p (cdr (assq 'device parameters)))))
+	     ((assq 'terminal parameters)
+	      (let ((type (terminal-live-p (cdr (assq 'terminal parameters)))))
 		(cond
 		 ((eq type t) nil)
-		 ((eq type nil) (error "Display %s does not exist" (cdr (assq 'device parameters))))
+		 ((eq type nil) (error "Terminal %s does not exist" (cdr (assq 'terminal parameters))))
 		 (t type))))
 	     ((assq 'window-system parameters)
 	      (cdr (assq 'window-system parameters)))
@@ -682,7 +682,7 @@
     (setq frame (funcall frame-creation-function (append parameters (cdr (assq w window-system-default-frame-alist)))))
     (normal-erase-is-backspace-setup-frame frame)
     ;; Set up the frame-local environment, if needed.
-    (when (eq (frame-display frame) (frame-display oldframe))
+    (when (eq (frame-terminal frame) (frame-terminal oldframe))
       (let ((env (frame-parameter oldframe 'environment)))
 	(if (not (framep env))
 	    (setq env oldframe))
@@ -718,7 +718,7 @@
 frame's terminal device."
   (let* ((terminal (terminal-id terminal))
 	 (func #'(lambda (frame)
-		   (eq (frame-display frame) terminal))))
+		   (eq (frame-terminal frame) terminal))))
     (filtered-frame-list func)))
 
 (defun framep-on-display (&optional terminal)
@@ -727,7 +727,7 @@
 is a frame, its type is returned.  If TERMINAL is omitted or nil,
 it defaults to the selected frame's terminal device.  All frames
 on a given display are of the same type."
-  (or (display-live-p terminal)
+  (or (terminal-live-p terminal)
       (framep terminal)
       (framep (car (frames-on-display-list terminal)))))
 
@@ -815,7 +815,7 @@
     (cond
      ((eq type 'x) (iconify-or-deiconify-frame))
      ((eq type t)
-      (if (display-controlling-tty-p)
+      (if (controlling-tty-p)
 	  (suspend-emacs)
 	(suspend-tty)))
      (t (suspend-emacs)))))
@@ -1068,9 +1068,9 @@
     (cons vert hor)))
 
 ;;;; Frame/display capabilities.
-(defun selected-display ()
-  "Return the display that is now selected."
-  (frame-display (selected-frame)))
+(defun selected-terminal ()
+  "Return the terminal that is now selected."
+  (frame-terminal (selected-frame)))
 
 (defun display-mouse-p (&optional display)
   "Return non-nil if DISPLAY has a mouse available.
--- a/lisp/server.el	Thu Dec 29 04:57:14 2005 +0000
+++ b/lisp/server.el	Thu Dec 29 18:20:26 2005 +0000
@@ -247,7 +247,7 @@
 	   (setenv (car ,pair) (cdr ,pair)))))))
 
 (defun server-delete-client (client &optional noframe)
-  "Delete CLIENT, including its buffers, devices and frames.
+  "Delete CLIENT, including its buffers, terminals and frames.
 If NOFRAME is non-nil, let the frames live.  (To be used from
 `delete-frame-functions'."
   ;; Force a new lookup of client (prevents infinite recursion).
@@ -271,9 +271,9 @@
 	      (kill-buffer (current-buffer))))))
 
       ;; Delete the client's tty.
-      (let ((device (server-client-get client 'device)))
-	(when (eq (display-live-p device) t)
-	  (delete-display device)))
+      (let ((terminal (server-client-get client 'terminal)))
+	(when (eq (terminal-live-p terminal) t)
+	  (delete-terminal terminal)))
 
       ;; Delete the client's frames.
       (unless noframe
@@ -323,18 +323,18 @@
 		   ;; there are other frames on it.
 		   (< 0 (let ((frame-num 0))
 			  (mapc (lambda (f)
-				  (when (eq (frame-display f)
-					    (frame-display frame))
+				  (when (eq (frame-terminal f)
+					    (frame-terminal frame))
 				    (setq frame-num (1+ frame-num))))
 				(frame-list))
 			  frame-num))))
       (server-log (format "server-handle-delete-frame, frame %s" frame) proc)
       (server-delete-client proc 'noframe)))) ; Let delete-frame delete the frame later.
 
-(defun server-handle-suspend-tty (device)
+(defun server-handle-suspend-tty (terminal)
   "Notify the emacsclient process to suspend itself when its tty device is suspended."
-  (dolist (proc (server-clients-with 'device device))
-    (server-log (format "server-handle-suspend-tty, device %s" device) proc)
+  (dolist (proc (server-clients-with 'terminal terminal))
+    (server-log (format "server-handle-suspend-tty, terminal %s" terminal) proc)
     (condition-case err
 	(server-send-string proc "-suspend \n")
       (file-error (condition-case nil (server-delete-client proc) (error nil))))))
@@ -618,7 +618,7 @@
 					  ;; Flag frame as client-created, but use a dummy client.
 					  ;; This will prevent the frame from being deleted when
 					  ;; emacsclient quits while also preventing
-					  ;; `server-save-buffers-kill-display' from unexpectedly
+					  ;; `server-save-buffers-kill-terminal' from unexpectedly
 					  ;; killing emacs on that frame.
 					  (list (cons 'client 'nowait) (cons 'environment env))
 					(list (cons 'client proc) (cons 'environment env)))))
@@ -636,7 +636,7 @@
 			  (modify-frame-parameters frame params)
 			  (select-frame frame)
 			  (server-client-set client 'frame frame)
-			  (server-client-set client 'device (frame-display frame))
+			  (server-client-set client 'terminal (frame-terminal frame))
 			  (setq dontkill t))
 		      ;; This emacs does not support X.
 		      (server-log "Window system unsupported" proc)
@@ -645,19 +645,19 @@
 
 		 ;; -resume:  Resume a suspended tty frame.
 		 ((equal "-resume" arg)
-		  (let ((device (server-client-get client 'device)))
+		  (let ((terminal (server-client-get client 'terminal)))
 		    (setq dontkill t)
-		    (when (eq (display-live-p device) t)
-		      (resume-tty device))))
+		    (when (eq (terminal-live-p terminal) t)
+		      (resume-tty terminal))))
 
 		 ;; -suspend:  Suspend the client's frame.  (In case we
 		 ;; get out of sync, and a C-z sends a SIGTSTP to
 		 ;; emacsclient.)
 		 ((equal "-suspend" arg)
-		  (let ((device (server-client-get client 'device)))
+		  (let ((terminal (server-client-get client 'terminal)))
 		    (setq dontkill t)
-		    (when (eq (display-live-p device) t)
-		      (suspend-tty device))))
+		    (when (eq (terminal-live-p terminal) t)
+		      (suspend-tty terminal))))
 
 		 ;; -ignore COMMENT:  Noop; useful for debugging emacsclient.
 		 ;; (The given comment appears in the server log.)
@@ -687,8 +687,8 @@
 							 (environment . ,env)))))
 		      (select-frame frame)
 		      (server-client-set client 'frame frame)
-		      (server-client-set client 'tty (display-name frame))
-		      (server-client-set client 'device (frame-display frame))
+		      (server-client-set client 'tty (terminal-name frame))
+		      (server-client-set client 'terminal (frame-terminal frame))
 
 		      ;; Reply with our pid.
 		      (server-send-string proc (concat "-emacs-pid " (number-to-string (emacs-pid)) "\n"))
@@ -1037,8 +1037,8 @@
 	       (get-window-with-predicate
 		(lambda (w)
 		  (and (not (window-dedicated-p w))
-		       (equal (frame-parameter (window-frame w) 'device)
-			      (frame-parameter (selected-frame) 'device))))
+		       (equal (frame-terminal (window-frame w))
+			      (frame-terminal (selected-frame)))))
 		'nomini 'visible (selected-window))))
 	    (condition-case nil
 		(switch-to-buffer next-buffer)
@@ -1047,7 +1047,7 @@
 	      (error (pop-to-buffer next-buffer)))))))))
 
 ;;;###autoload
-(defun server-save-buffers-kill-display (proc &optional arg)
+(defun server-save-buffers-kill-terminal (proc &optional arg)
   "Offer to save each buffer, then kill PROC.
 
 With prefix arg, silently save all file-visiting buffers, then kill.
--- a/lisp/startup.el	Thu Dec 29 04:57:14 2005 +0000
+++ b/lisp/startup.el	Thu Dec 29 18:20:26 2005 +0000
@@ -1430,7 +1430,7 @@
 	      ;; use precomputed string to save lots of time.
 	      (if (and (eq (key-binding "\C-h") 'help-command)
 		       (eq (key-binding "\C-xu") 'advertised-undo)
-		       (eq (key-binding "\C-x\C-c") 'save-buffers-kill-display)
+		       (eq (key-binding "\C-x\C-c") 'save-buffers-kill-terminal)
 		       (eq (key-binding "\C-ht") 'help-with-tutorial)
 		       (eq (key-binding "\C-hi") 'info)
 		       (eq (key-binding "\C-hr") 'info-emacs-manual)
@@ -1447,7 +1447,7 @@
 Get help	   %s
 Emacs manual	   \\[info-emacs-manual]
 Emacs tutorial	   \\[help-with-tutorial]\tUndo changes\t\\[advertised-undo]
-Buy manuals        \\[view-order-manuals]\tExit Emacs\t\\[save-buffers-kill-display]
+Buy manuals        \\[view-order-manuals]\tExit Emacs\t\\[save-buffers-kill-terminal]
 Browse manuals     \\[info]"
 				 (let ((where (where-is-internal
 					       'help-command nil t)))
--- a/lisp/talk.el	Thu Dec 29 04:57:14 2005 +0000
+++ b/lisp/talk.el	Thu Dec 29 18:20:26 2005 +0000
@@ -50,22 +50,22 @@
   "Connect to the Emacs talk group from the current X display or tty frame."
   (interactive)
   (let ((type (frame-live-p (selected-frame)))
-	(display (frame-display (selected-frame))))
+	(display (frame-terminal (selected-frame))))
     (cond
      ((eq type t)
       (talk-add-display (selected-frame)))
      ((eq type 'x)
-      (talk-add-display (frame-display (selected-frame))))
+      (talk-add-display (frame-terminal (selected-frame))))
      (t
       (error "Unknown frame type"))))
   (talk-update-buffers))
 
 (defun talk-add-display (frame)
   (let* ((display (if (frame-live-p frame)
-		      (frame-display frame)
+		      (frame-terminal frame)
 		    frame))
 	 (elt (assoc display talk-display-alist))
-	 (name (concat "*talk-" (display-name display) "*"))
+	 (name (concat "*talk-" (terminal-name display) "*"))
 	 buffer)
     (unless (frame-live-p frame)
       (setq frame (make-frame-on-display display (list (cons 'name name)))))
--- a/lisp/termdev.el	Thu Dec 29 04:57:14 2005 +0000
+++ b/lisp/termdev.el	Thu Dec 29 18:20:26 2005 +0000
@@ -34,17 +34,17 @@
 device (HOST.SERVER.SCREEN) or a tty device file."
   (cond
    ((integerp terminal)
-    (if (display-live-p terminal)
+    (if (terminal-live-p terminal)
 	terminal
-      (signal 'wrong-type-argument (list 'display-live-p terminal))))
+      (signal 'wrong-type-argument (list 'terminal-live-p terminal))))
    ((or (null terminal) (framep terminal))
-    (frame-display terminal))
+    (frame-terminal terminal))
    ((stringp terminal)
     (let ((f (car (filtered-frame-list (lambda (frame)
 					 (or (equal (frame-parameter frame 'display) terminal)
 					     (equal (frame-parameter frame 'tty) terminal)))))))
       (or f (error "Display %s does not exist" terminal))
-      (frame-display f)))
+      (frame-terminal f)))
    (t
     (error "Invalid argument %s in `terminal-id'" terminal))))
 
--- a/lisp/xt-mouse.el	Thu Dec 29 04:57:14 2005 +0000
+++ b/lisp/xt-mouse.el	Thu Dec 29 18:20:26 2005 +0000
@@ -197,18 +197,18 @@
 
 (defun turn-on-xterm-mouse-tracking-on-terminal (terminal)
   "Enable xterm mouse tracking on TERMINAL."
-  (when (and xterm-mouse-mode (eq t (display-live-p terminal)))
+  (when (and xterm-mouse-mode (eq t (terminal-live-p terminal)))
     (send-string-to-terminal "\e[?1000h" terminal)))
 
 (defun turn-off-xterm-mouse-tracking-on-terminal (terminal)
   "Disable xterm mouse tracking on TERMINAL."
-  (when (and xterm-mouse-mode (eq t (display-live-p terminal)))
+  (when (and xterm-mouse-mode (eq t (terminal-live-p terminal)))
     (send-string-to-terminal "\e[?1000l" terminal)))
 
 (defun xterm-mouse-handle-delete-frame (frame)
   "Turn off xterm mouse tracking if FRAME is the last frame on its device."
   (when (and (eq t (frame-live-p frame))
-	     (<= 1 (length (frames-on-display-list (frame-display frame)))))
+	     (<= 1 (length (frames-on-display-list (frame-terminal frame)))))
     (turn-off-xterm-mouse-tracking-on-terminal frame)))
 
 ;; Frame creation and deletion.
--- a/src/alloc.c	Thu Dec 29 04:57:14 2005 +0000
+++ b/src/alloc.c	Thu Dec 29 18:20:26 2005 +0000
@@ -324,7 +324,7 @@
 EMACS_INT gcs_done;		/* accumulated GCs  */
 
 static void mark_buffer P_ ((Lisp_Object));
-extern void mark_devices P_ ((void));
+extern void mark_terminals P_ ((void));
 extern void mark_kboards P_ ((void));
 extern void mark_ttys P_ ((void));
 extern void mark_backtrace P_ ((void));
@@ -4938,7 +4938,7 @@
       mark_object (bind->symbol);
       mark_object (bind->old_value);
     }
-  mark_devices ();
+  mark_terminals ();
   mark_kboards ();
   mark_ttys ();
 
--- a/src/coding.c	Thu Dec 29 04:57:14 2005 +0000
+++ b/src/coding.c	Thu Dec 29 18:20:26 2005 +0000
@@ -7351,11 +7351,11 @@
 DEFUN ("set-terminal-coding-system-internal", Fset_terminal_coding_system_internal,
        Sset_terminal_coding_system_internal, 1, 2, 0,
        doc: /* Internal use only.  */)
-     (coding_system, device)
+     (coding_system, terminal)
      Lisp_Object coding_system;
-     Lisp_Object device;
+     Lisp_Object terminal;
 {
-  struct coding_system *terminal_coding = DEVICE_TERMINAL_CODING (get_device (device, 1));
+  struct coding_system *terminal_coding = TERMINAL_TERMINAL_CODING (get_terminal (terminal, 1));
   CHECK_SYMBOL (coding_system);
   setup_coding_system (Fcheck_coding_system (coding_system), terminal_coding);
   /* We had better not send unsafe characters to terminal.  */
@@ -7389,41 +7389,41 @@
 
 DEFUN ("terminal-coding-system", Fterminal_coding_system,
        Sterminal_coding_system, 0, 1, 0,
-       doc: /* Return coding system specified for terminal output on the given device.
-DEVICE may be a display device id, a frame, or nil for the selected
-frame's display device.  */)
-     (device)
-     Lisp_Object device;
+       doc: /* Return coding system specified for terminal output on the given terminal.
+TERMINAL may be a terminal id, a frame, or nil for the selected
+frame's terminal device.  */)
+     (terminal)
+     Lisp_Object terminal;
 {
-  return DEVICE_TERMINAL_CODING (get_device (device, 1))->symbol;
+  return TERMINAL_TERMINAL_CODING (get_terminal (terminal, 1))->symbol;
 }
 
 DEFUN ("set-keyboard-coding-system-internal", Fset_keyboard_coding_system_internal,
        Sset_keyboard_coding_system_internal, 1, 2, 0,
        doc: /* Internal use only.  */)
-     (coding_system, device)
+     (coding_system, terminal)
      Lisp_Object coding_system;
-     Lisp_Object device;
+     Lisp_Object terminal;
 {
-  struct device *d = get_device (device, 1);
+  struct terminal *t = get_terminal (terminal, 1);
   CHECK_SYMBOL (coding_system);
 
   setup_coding_system (Fcheck_coding_system (coding_system),
-                       DEVICE_KEYBOARD_CODING (d));
+                       TERMINAL_KEYBOARD_CODING (t));
   /* Character composition should be disabled.  */
-  DEVICE_KEYBOARD_CODING (d)->composing = COMPOSITION_DISABLED;
+  TERMINAL_KEYBOARD_CODING (t)->composing = COMPOSITION_DISABLED;
   return Qnil;
 }
 
 DEFUN ("keyboard-coding-system", Fkeyboard_coding_system,
        Skeyboard_coding_system, 0, 1, 0,
-       doc: /* Return coding system for decoding keyboard input on DEVICE.
-DEVICE may be a display device id, a frame, or nil for the selected
-frame's display device.  */)
-     (device)
-     Lisp_Object device;
+       doc: /* Return coding system for decoding keyboard input on TERMINAL.
+TERMINAL may be a terminal id, a frame, or nil for the selected
+frame's terminal device.  */)
+     (terminal)
+     Lisp_Object terminal;
 {
-  return DEVICE_KEYBOARD_CODING (get_device (device, 1))->symbol;
+  return TERMINAL_KEYBOARD_CODING (get_terminal (terminal, 1))->symbol;
 }
 
 
--- a/src/data.c	Thu Dec 29 04:57:14 2005 +0000
+++ b/src/data.c	Thu Dec 29 18:20:26 2005 +0000
@@ -1900,41 +1900,41 @@
 /* This code is disabled now that we use the selected frame to return
    keyboard-local-values. */
 #if 0
-extern struct device *get_device P_ ((Lisp_Object display, int));
+extern struct terminal *get_terminal P_ ((Lisp_Object display, int));
 
 DEFUN ("terminal-local-value", Fterminal_local_value, Sterminal_local_value, 2, 2, 0,
-       doc: /* Return the terminal-local value of SYMBOL on DEVICE.
+       doc: /* Return the terminal-local value of SYMBOL on TERMINAL.
 If SYMBOL is not a terminal-local variable, then return its normal
 value, like `symbol-value'.
 
-DEVICE may be a display device id, a frame, or nil (meaning the
-selected frame's display device).  */)
-  (symbol, device)
+TERMINAL may be a terminal id, a frame, or nil (meaning the
+selected frame's terminal device).  */)
+  (symbol, terminal)
      Lisp_Object symbol;
-     Lisp_Object device;
+     Lisp_Object terminal;
 {
   Lisp_Object result;
-  struct device *d = get_device (device, 1);
-  push_kboard (d->kboard);
+  struct terminal *t = get_terminal (terminal, 1);
+  push_kboard (t->kboard);
   result = Fsymbol_value (symbol);
   pop_kboard ();
   return result;
 }
 
 DEFUN ("set-terminal-local-value", Fset_terminal_local_value, Sset_terminal_local_value, 3, 3, 0,
-       doc: /* Set the terminal-local binding of SYMBOL on DEVICE to VALUE.
+       doc: /* Set the terminal-local binding of SYMBOL on TERMINAL to VALUE.
 If VARIABLE is not a terminal-local variable, then set its normal
 binding, like `set'.
 
-DEVICE may be a display device id, a frame, or nil (meaning the
-selected frame's display device).  */)
-  (symbol, device, value)
+TERMINAL may be a terminal id, a frame, or nil (meaning the
+selected frame's terminal device).  */)
+  (symbol, terminal, value)
      Lisp_Object symbol;
-     Lisp_Object device;
+     Lisp_Object terminal;
      Lisp_Object value;
 {
   Lisp_Object result;
-  struct device *d = get_device (device, 1);
+  struct terminal *t = get_terminal (terminal, 1);
   push_kboard (d->kboard);
   result = Fset (symbol, value);
   pop_kboard ();
--- a/src/dispextern.h	Thu Dec 29 04:57:14 2005 +0000
+++ b/src/dispextern.h	Thu Dec 29 18:20:26 2005 +0000
@@ -1350,7 +1350,7 @@
 	DESCENT = FONT->descent
 	HEIGHT = FONT_HEIGHT (FONT)
 	F_DESCENT = (FRAME_FONT (F)->descent
-		     - F->device->output_data.x->baseline_offset)
+		     - F->terminal->output_data.x->baseline_offset)
 	F_HEIGHT = FRAME_LINE_HEIGHT (F)
 */
 
@@ -2927,11 +2927,8 @@
 extern void update_end P_ ((struct frame *));
 extern void set_terminal_window P_ ((struct frame *, int));
 extern void cursor_to P_ ((struct frame *, int, int));
-
-/* Was not declared before: */
 extern void raw_cursor_to P_ ((struct frame *, int, int));
 extern void clear_to_end P_ ((struct frame *));
-
 extern void clear_frame P_ ((struct frame *));
 extern void clear_end_of_line P_ ((struct frame *, int));
 extern void write_glyphs P_ ((struct frame *, struct glyph *, int));
@@ -2939,13 +2936,13 @@
 extern void delete_glyphs P_ ((struct frame *, int));
 extern void ins_del_lines P_ ((struct frame *, int, int));
 
-extern struct device *init_initial_device P_ ((void));
+extern struct terminal *init_initial_terminal P_ ((void));
 
 
 /* Defined in term.c */
 
-extern void tty_set_terminal_modes P_ ((struct device *));
-extern void tty_reset_terminal_modes P_ ((struct device *));
+extern void tty_set_terminal_modes P_ ((struct terminal *));
+extern void tty_reset_terminal_modes P_ ((struct terminal *));
 extern void tty_turn_off_insert P_ ((struct tty_display_info *));
 extern void tty_turn_off_highlight P_ ((struct tty_display_info *));
 extern int string_cost P_ ((char *));
@@ -2955,11 +2952,11 @@
 extern void produce_special_glyphs P_ ((struct it *, enum display_element_type));
 extern int tty_capable_p P_ ((struct tty_display_info *, unsigned, unsigned long, unsigned long));
 extern void set_tty_color_mode P_ ((struct frame *, Lisp_Object));
-extern struct device *get_tty_device P_ ((Lisp_Object terminal));
-extern struct device *get_named_tty P_ ((char *));
-EXFUN (Fdisplay_tty_type, 1);
+extern struct terminal *get_tty_terminal P_ ((Lisp_Object terminal));
+extern struct terminal *get_named_tty P_ ((char *));
+EXFUN (Ftty_type, 1);
 extern void create_tty_output P_ ((struct frame *));
-extern struct device *init_tty P_ ((char *, char *, int));
+extern struct terminal *init_tty P_ ((char *, char *, int));
 
 
 /* Defined in scroll.c */
--- a/src/dispnew.c	Thu Dec 29 04:57:14 2005 +0000
+++ b/src/dispnew.c	Thu Dec 29 18:20:26 2005 +0000
@@ -3345,7 +3345,7 @@
   update_begin (f);
 #ifdef MSDOS
   if (FRAME_MSDOS_P (f))
-    set_terminal_modes (FRAME_DEVICE (f));
+    set_terminal_modes (FRAME_TERMINAL (f));
 #endif
   clear_frame (f);
   clear_current_matrices (f);
@@ -6304,23 +6304,23 @@
        doc: /* Send STRING to the terminal without alteration.
 Control characters in STRING will have terminal-dependent effects.
 
-Optional parameter TERMINAL specifies the tty display device to use.
+Optional parameter TERMINAL specifies the tty terminal device to use.
 It may be a terminal id, a frame, or nil for the terminal used by the
 currently selected frame.  */)
-  (string, display)
+  (string, terminal)
      Lisp_Object string;
-     Lisp_Object display;
+     Lisp_Object terminal;
 {
-  struct device *d = get_tty_device (display);
+  struct terminal *t = get_tty_terminal (terminal);
   struct tty_display_info *tty;
 
   /* ??? Perhaps we should do something special for multibyte strings here.  */
   CHECK_STRING (string);
 
-  if (!d)
-    error ("Unknown display device");
-
-  tty = d->display_info.tty;
+  if (!t)
+    error ("Unknown terminal device");
+
+  tty = t->display_info.tty;
   
   if (tty->termscript)
     {
@@ -6783,34 +6783,34 @@
 #endif /* VMS */
 
   {
-    struct device *d;
+    struct terminal *t;
     struct frame *f = XFRAME (selected_frame);
 
     /* Open a display on the controlling tty. */
-    d = init_tty (0, terminal_type, 1); /* Errors are fatal. */
+    t = init_tty (0, terminal_type, 1); /* Errors are fatal. */
 
     /* Convert the initial frame to use the new display. */
     if (f->output_method != output_initial)
       abort ();
-    f->output_method = d->type;
-    f->device = d;
-
-    d->reference_count++;
-    d->display_info.tty->top_frame = selected_frame;
+    f->output_method = t->type;
+    f->terminal = t;
+
+    t->reference_count++;
+    t->display_info.tty->top_frame = selected_frame;
     change_frame_size (XFRAME (selected_frame),
-                       FrameRows (d->display_info.tty),
-                       FrameCols (d->display_info.tty), 0, 0, 1);
-
-    /* Delete the initial display. */
-    if (--initial_device->reference_count == 0
-        && initial_device->delete_device_hook)
-      (*initial_device->delete_device_hook) (initial_device);
+                       FrameRows (t->display_info.tty),
+                       FrameCols (t->display_info.tty), 0, 0, 1);
+
+    /* Delete the initial terminal. */
+    if (--initial_terminal->reference_count == 0
+        && initial_terminal->delete_terminal_hook)
+      (*initial_terminal->delete_terminal_hook) (initial_terminal);
 
     /* Update frame parameters to reflect the new type. */
     Fmodify_frame_parameters (selected_frame, Fcons (Fcons (Qwindow_system, Qnil), Qnil));
     Fmodify_frame_parameters
       (selected_frame, Fcons (Fcons (Qtty_type,
-                                     Fdisplay_tty_type (selected_frame)), Qnil));
+                                     Ftty_type (selected_frame)), Qnil));
     Fmodify_frame_parameters (selected_frame, Fcons (Fcons (Qtty, Qnil), Qnil));
   }
   
--- a/src/frame.c	Thu Dec 29 04:57:14 2005 +0000
+++ b/src/frame.c	Thu Dec 29 18:20:26 2005 +0000
@@ -76,8 +76,8 @@
 
 Lisp_Object Qx_frame_parameter;
 Lisp_Object Qx_resource_name;
-Lisp_Object Qdevice;
-Lisp_Object Qdisplay_live_p;
+Lisp_Object Qterminal;
+Lisp_Object Qterminal_live_p;
 
 /* Frame parameters (set or reported).  */
 
@@ -225,7 +225,7 @@
 DEFUN ("frame-live-p", Fframe_live_p, Sframe_live_p, 1, 1, 0,
        doc: /* Return non-nil if OBJECT is a frame which has not been deleted.
 Value is nil if OBJECT is not a live frame.  If object is a live
-frame, the return value indicates what sort of output device it is
+frame, the return value indicates what sort of terminal device it is
 displayed on.  See the documentation of `framep' for possible
 return values.  */)
      (object)
@@ -424,8 +424,8 @@
 
 #ifdef MULTI_KBOARD
   if (!NILP (mini_window)
-      && XFRAME (XWINDOW (mini_window)->frame)->device->kboard != kb)
-    error ("Frame and minibuffer must be on the same display");
+      && FRAME_KBOARD (XFRAME (XWINDOW (mini_window)->frame)) != kb)
+    error ("Frame and minibuffer must be on the same terminal");
 #endif
 
   /* Make a frame containing just a root window.  */
@@ -503,13 +503,13 @@
 
 /* Construct a frame that refers to a terminal.  */
 
-static int terminal_frame_count;
+static int tty_frame_count;
 
 struct frame *
 make_initial_frame (void)
 {
   struct frame *f;
-  struct device *device;
+  struct terminal *terminal;
   Lisp_Object frame;
 
 #ifdef MULTI_KBOARD
@@ -527,22 +527,22 @@
   if (! (NILP (Vframe_list) || CONSP (Vframe_list)))
     Vframe_list = Qnil;
 
-  device = init_initial_device ();
+  terminal = init_initial_terminal ();
 
   f = make_frame (1);
   XSETFRAME (frame, f);
 
   Vframe_list = Fcons (frame, Vframe_list);
 
-  terminal_frame_count = 1;
+  tty_frame_count = 1;
   f->name = build_string ("F1");
 
   f->visible = 1;
   f->async_visible = 1;
 
-  f->output_method = device->type;
-  f->device = device;
-  f->device->reference_count++;
+  f->output_method = terminal->type;
+  f->terminal = terminal;
+  f->terminal->reference_count++;
   f->output_data.nothing = 0;
   
   FRAME_FOREGROUND_PIXEL (f) = FACE_TTY_DEFAULT_FG_COLOR;
@@ -556,7 +556,7 @@
 
 
 struct frame *
-make_terminal_frame (struct device *device)
+make_terminal_frame (struct terminal *terminal)
 {
   register struct frame *f;
   Lisp_Object frame;
@@ -567,8 +567,8 @@
   XSETFRAME (frame, f);
   Vframe_list = Fcons (frame, Vframe_list);
 
-  terminal_frame_count++;
-  sprintf (name, "F%d", terminal_frame_count);
+  tty_frame_count++;
+  sprintf (name, "F%d", tty_frame_count);
   f->name = build_string (name);
 
   f->visible = 1;		/* FRAME_SET_VISIBLE wd set frame_garbaged. */
@@ -607,8 +607,8 @@
 #else
   {
     f->output_method = output_termcap;
-    f->device = device;
-    f->device->reference_count++;
+    f->terminal = terminal;
+    f->terminal->reference_count++;
     create_tty_output (f);
     
     FRAME_FOREGROUND_PIXEL (f) = FACE_TTY_DEFAULT_FG_COLOR;
@@ -687,7 +687,7 @@
      Lisp_Object parms;
 {
   struct frame *f;
-  struct device *d = NULL;
+  struct terminal *t = NULL;
   Lisp_Object frame, tem;
   struct frame *sf = SELECTED_FRAME ();
 
@@ -709,18 +709,17 @@
 #endif /* not MSDOS */
   
   {
-    Lisp_Object display_device;
-
-    display_device = Fassq (Qdevice, parms);
-    if (!NILP (display_device))
+    Lisp_Object terminal;
+
+    terminal = Fassq (Qterminal, parms);
+    if (!NILP (terminal))
       {
-        display_device = XCDR (display_device);
-        CHECK_NUMBER (display_device);
-        d = get_device (XINT (display_device), 1);
+        terminal = XCDR (terminal);
+        t = get_terminal (terminal, 1);
       }
   }
   
-  if (!d)
+  if (!t)
     { 
       char *name = 0, *type = 0;
       Lisp_Object tty, tty_type;
@@ -747,10 +746,10 @@
           type[SBYTES (tty_type)] = 0;
         }
 
-      d = init_tty (name, type, 0); /* Errors are not fatal. */
+      t = init_tty (name, type, 0); /* Errors are not fatal. */
     }
 
-  f = make_terminal_frame (d);
+  f = make_terminal_frame (t);
 
   {
     int width, height;
@@ -765,10 +764,10 @@
   Fmodify_frame_parameters (frame, parms);
   Fmodify_frame_parameters (frame, Fcons (Fcons (Qwindow_system, Qnil), Qnil));
   Fmodify_frame_parameters (frame, Fcons (Fcons (Qtty_type,
-                                                 build_string (d->display_info.tty->type)),
+                                                 build_string (t->display_info.tty->type)),
                                           Qnil));
   Fmodify_frame_parameters (frame, Fcons (Fcons (Qtty,
-                                                 build_string (d->display_info.tty->name)),
+                                                 build_string (t->display_info.tty->name)),
                                           Qnil));
   
   /* Make the frame face alist be frame-specific, so that each
@@ -793,7 +792,7 @@
    frame's focus to FRAME instead.
 
    FOR_DELETION non-zero means that the selected frame is being
-   deleted, which includes the possibility that the frame's display
+   deleted, which includes the possibility that the frame's terminal
    is dead.  */
 
 Lisp_Object
@@ -1060,30 +1059,6 @@
 
   return XFRAME (frame)->selected_window = window;
 }
-
-
-DEFUN ("frame-display", Fframe_display, Sframe_display, 0, 1, 0,
-       doc: /* Return the display device that FRAME is displayed on.
-If FRAME is nil, the selected frame is used.
-
-The display device is represented by its integer identifier.  */)
-  (frame)
-     Lisp_Object frame;
-{
-  struct device *d;
-
-  if (NILP (frame))
-    frame = selected_frame;
-
-  CHECK_LIVE_FRAME (frame);
-
-  d = get_device (frame, 0);
-
-  if (!d)
-    return Qnil;
-  else
-    return make_number (d->id);
-}
 
 
 DEFUN ("frame-list", Fframe_list, Sframe_list,
@@ -1532,32 +1507,33 @@
     xfree (FRAME_MESSAGE_BUF (f));
 
   /* Since some events are handled at the interrupt level, we may get
-     an event for f at any time; if we zero out the frame's display
+     an event for f at any time; if we zero out the frame's terminal
      now, then we may trip up the event-handling code.  Instead, we'll
-     promise that the display of the frame must be valid until we have
-     called the window-system-dependent frame destruction routine.  */
-
-  if (FRAME_DEVICE (f)->delete_frame_hook)
-    (*FRAME_DEVICE (f)->delete_frame_hook) (f);
+     promise that the terminal of the frame must be valid until we
+     have called the window-system-dependent frame destruction
+     routine.  */
+
+  if (FRAME_TERMINAL (f)->delete_frame_hook)
+    (*FRAME_TERMINAL (f)->delete_frame_hook) (f);
 
   {
-    struct device *device = FRAME_DEVICE (f);
+    struct terminal *terminal = FRAME_TERMINAL (f);
     f->output_data.nothing = 0; 
-    f->device = 0;             /* Now the frame is dead. */
-
-    /* If needed, delete the device that this frame was on.
+    f->terminal = 0;             /* Now the frame is dead. */
+
+    /* If needed, delete the terminal that this frame was on.
        (This must be done after the frame is killed.) */
-    device->reference_count--;
-    if (device->reference_count == 0)
+    terminal->reference_count--;
+    if (terminal->reference_count == 0)
       {
         kb = NULL;
-        if (device->delete_device_hook)
-          (*device->delete_device_hook) (device);
+        if (terminal->delete_terminal_hook)
+          (*terminal->delete_terminal_hook) (terminal);
         else
-          delete_device (device);
+          delete_terminal (terminal);
       }
     else
-      kb = device->kboard;
+      kb = terminal->kboard;
   }
 
   /* If we've deleted the last_nonminibuf_frame, then try to find
@@ -1704,11 +1680,11 @@
 
 #ifdef HAVE_MOUSE
   /* It's okay for the hook to refrain from storing anything.  */
-  if (FRAME_DEVICE (f)->mouse_position_hook)
-    (*FRAME_DEVICE (f)->mouse_position_hook) (&f, -1,
-                                              &lispy_dummy, &party_dummy,
-                                              &x, &y,
-                                              &long_dummy);
+  if (FRAME_TERMINAL (f)->mouse_position_hook)
+    (*FRAME_TERMINAL (f)->mouse_position_hook) (&f, -1,
+                                                &lispy_dummy, &party_dummy,
+                                                &x, &y,
+                                                &long_dummy);
   if (! NILP (x))
     {
       col = XINT (x);
@@ -1747,11 +1723,11 @@
 
 #ifdef HAVE_MOUSE
   /* It's okay for the hook to refrain from storing anything.  */
-  if (FRAME_DEVICE (f)->mouse_position_hook)
-    (*FRAME_DEVICE (f)->mouse_position_hook) (&f, -1,
-                                              &lispy_dummy, &party_dummy,
-                                              &x, &y,
-                                              &long_dummy);
+  if (FRAME_TERMINAL (f)->mouse_position_hook)
+    (*FRAME_TERMINAL (f)->mouse_position_hook) (&f, -1,
+                                                &lispy_dummy, &party_dummy,
+                                                &x, &y,
+                                                &long_dummy);
 #endif
   XSETFRAME (lispy_dummy, f);
   return Fcons (lispy_dummy, Fcons (x, y));
@@ -2028,8 +2004,8 @@
   /* Do like the documentation says. */
   Fmake_frame_visible (frame);
 
-  if (FRAME_DEVICE (f)->frame_raise_lower_hook)
-    (*FRAME_DEVICE (f)->frame_raise_lower_hook) (f, 1);
+  if (FRAME_TERMINAL (f)->frame_raise_lower_hook)
+    (*FRAME_TERMINAL (f)->frame_raise_lower_hook) (f, 1);
 
   return Qnil;
 }
@@ -2052,8 +2028,8 @@
 
   f = XFRAME (frame);
   
-  if (FRAME_DEVICE (f)->frame_raise_lower_hook)
-    (*FRAME_DEVICE (f)->frame_raise_lower_hook) (f, 0);
+  if (FRAME_TERMINAL (f)->frame_raise_lower_hook)
+    (*FRAME_TERMINAL (f)->frame_raise_lower_hook) (f, 0);
 
   return Qnil;
 }
@@ -2101,8 +2077,8 @@
   
   f->focus_frame = focus_frame;
 
-  if (FRAME_DEVICE (f)->frame_rehighlight_hook)
-    (*FRAME_DEVICE (f)->frame_rehighlight_hook) (f);
+  if (FRAME_TERMINAL (f)->frame_rehighlight_hook)
+    (*FRAME_TERMINAL (f)->frame_rehighlight_hook) (f);
 
   return Qnil;
 }
@@ -2236,8 +2212,8 @@
 			    SBYTES (f->name)))
 	return;
 
-      terminal_frame_count++;
-      sprintf (namebuf, "F%d", terminal_frame_count);
+      tty_frame_count++;
+      sprintf (namebuf, "F%d", tty_frame_count);
       name = build_string (namebuf);
     }
   else
@@ -4306,10 +4282,10 @@
   Qx_frame_parameter = intern ("x-frame-parameter");
   staticpro (&Qx_frame_parameter);
 
-  Qdevice = intern ("device");
-  staticpro (&Qdevice);
-  Qdisplay_live_p = intern ("display-live-p");
-  staticpro (&Qdisplay_live_p);
+  Qterminal = intern ("terminal");
+  staticpro (&Qterminal);
+  Qterminal_live_p = intern ("terminal-live-p");
+  staticpro (&Qterminal_live_p);
   
   {
     int i;
@@ -4449,7 +4425,6 @@
   defsubr (&Sframe_first_window);
   defsubr (&Sframe_selected_window);
   defsubr (&Sset_frame_selected_window);
-  defsubr (&Sframe_display);
   defsubr (&Sframe_list);
   defsubr (&Snext_frame);
   defsubr (&Sprevious_frame);
--- a/src/frame.h	Thu Dec 29 04:57:14 2005 +0000
+++ b/src/frame.h	Thu Dec 29 18:20:26 2005 +0000
@@ -70,7 +70,7 @@
 #define FRAME_FOREGROUND_PIXEL(f) ((f)->foreground_pixel)
 #define FRAME_BACKGROUND_PIXEL(f) ((f)->background_pixel)
 
-struct device;
+struct terminal;
 
 struct frame
 {
@@ -267,12 +267,12 @@
 
   /* The output method says how the contents of this frame are
      displayed.  It could be using termcap, or using an X window.
-     This must be the same as the device->type. */
+     This must be the same as the terminal->type. */
   enum output_method output_method;
 
-  /* The display device that this frame uses.  If this is NULL, then
+  /* The terminal device that this frame uses.  If this is NULL, then
      the frame has been deleted. */
-  struct device *device;
+  struct terminal *terminal;
   
   /* Device-dependent, frame-local auxiliary data used for displaying
      the contents.  When the frame is deleted, this data is deleted as
@@ -458,7 +458,7 @@
 };
 
 #ifdef MULTI_KBOARD
-#define FRAME_KBOARD(f) ((f)->device->kboard)
+#define FRAME_KBOARD(f) ((f)->terminal->kboard)
 #else
 #define FRAME_KBOARD(f) (&the_only_kboard)
 #endif
@@ -496,7 +496,7 @@
 #endif
 
 /* Nonzero if frame F is still alive (not deleted).  */
-#define FRAME_LIVE_P(f) ((f)->device != 0)
+#define FRAME_LIVE_P(f) ((f)->terminal != 0)
 
 /* Nonzero if frame F is a minibuffer-only frame.  */
 #define FRAME_MINIBUF_ONLY_P(f) \
@@ -780,13 +780,13 @@
 
 extern Lisp_Object Qframep, Qframe_live_p;
 extern Lisp_Object Qtty, Qtty_type;
-extern Lisp_Object Qdevice, Qdisplay_live_p;
+extern Lisp_Object Qterminal, Qterminal_live_p;
 extern Lisp_Object Qenvironment;
 
 extern struct frame *last_nonminibuf_frame;
 
 extern struct frame *make_initial_frame P_ ((void));
-extern struct frame *make_terminal_frame P_ ((struct device *));
+extern struct frame *make_terminal_frame P_ ((struct terminal *));
 extern struct frame *make_frame P_ ((int));
 #ifdef HAVE_WINDOW_SYSTEM
 extern struct frame *make_minibuffer_frame P_ ((void));
--- a/src/keyboard.c	Thu Dec 29 04:57:14 2005 +0000
+++ b/src/keyboard.c	Thu Dec 29 18:20:26 2005 +0000
@@ -1130,19 +1130,19 @@
 push_frame_kboard (f)
      FRAME_PTR f;
 {
-  push_kboard (f->device->kboard);
+  push_kboard (f->terminal->kboard);
 }
 
 void
 pop_kboard ()
 {
 #ifdef MULTI_KBOARD
-  struct device *d;
+  struct terminal *t;
   struct kboard_stack *p = kboard_stack;
   current_kboard = NULL;
-  for (d = device_list; d; d = d->next_device)
-    {
-      if (d->kboard == p->kboard)
+  for (t = terminal_list; t; t = t->next_terminal)
+    {
+      if (t->kboard == p->kboard)
         {
           current_kboard = p->kboard;
           break;
@@ -1150,7 +1150,7 @@
     }
   if (current_kboard == NULL)
     {
-      /* The display we remembered has been deleted.  */
+      /* The terminal we remembered has been deleted.  */
       current_kboard = FRAME_KBOARD (SELECTED_FRAME ());
     }
   kboard_stack = p->next;
@@ -4205,15 +4205,15 @@
       unsigned long time;
 
       *kbp = current_kboard;
-      /* Note that this uses F to determine which display to look at.
+      /* Note that this uses F to determine which terminal to look at.
 	 If there is no valid info, it does not store anything
 	 so x remains nil.  */
       x = Qnil;
 
       /* XXX Can f or mouse_position_hook be NULL here? */
-      if (f && FRAME_DEVICE (f)->mouse_position_hook)
-        (*FRAME_DEVICE (f)->mouse_position_hook) (&f, 0, &bar_window,
-                                                  &part, &x, &y, &time);
+      if (f && FRAME_TERMINAL (f)->mouse_position_hook)
+        (*FRAME_TERMINAL (f)->mouse_position_hook) (&f, 0, &bar_window,
+                                                    &part, &x, &y, &time);
 
       obj = Qnil;
 
@@ -6749,15 +6749,15 @@
 {
   int nread = 0;
   int err = 0;
-  struct device *d;
-
-  /* Loop through the available devices, and call their input hooks. */
-  d = device_list;
-  while (d)
-    {
-      struct device *next = d->next_device;
-
-      if (d->read_socket_hook)
+  struct terminal *t;
+
+  /* Loop through the available terminals, and call their input hooks. */
+  t = terminal_list;
+  while (t)
+    {
+      struct terminal *next = t->next_terminal;
+
+      if (t->read_socket_hook)
         {
           int nr;
           struct input_event hold_quit;
@@ -6766,7 +6766,7 @@
           hold_quit.kind = NO_EVENT;
 
           /* No need for FIONREAD or fcntl; just say don't wait.  */
-          while (nr = (*d->read_socket_hook) (d, expected, &hold_quit), nr > 0)
+          while (nr = (*t->read_socket_hook) (t, expected, &hold_quit), nr > 0)
             {
               nread += nr;
               expected = 0;
@@ -6778,10 +6778,10 @@
             }
           else if (nr == -2)          /* Non-transient error. */
             {
-              /* The display device terminated; it should be closed. */
+              /* The terminal device terminated; it should be closed. */
               
-              /* Kill Emacs if this was our last display. */
-              if (! device_list->next_device)
+              /* Kill Emacs if this was our last terminal. */
+              if (!terminal_list->next_terminal)
                 /* Formerly simply reported no input, but that
                    sometimes led to a failure of Emacs to terminate.
                    SIGHUP seems appropriate if we can't reach the
@@ -6792,18 +6792,18 @@
                    alone in its group.  */
                 kill (getpid (), SIGHUP);
               
-              /* XXX Is calling delete_device safe here?  It calls Fdelete_frame. */
-              if (d->delete_device_hook)
-                (*d->delete_device_hook) (d);
+              /* XXX Is calling delete_terminal safe here?  It calls Fdelete_frame. */
+              if (t->delete_terminal_hook)
+                (*t->delete_terminal_hook) (t);
               else
-                delete_device (d);
+                delete_terminal (t);
             }
 
           if (hold_quit.kind != NO_EVENT)
             kbd_buffer_store_event (&hold_quit);
         }
 
-      d = next;
+      t = next;
     }
 
   if (err && !nread)
@@ -6814,12 +6814,12 @@
 
 /* This is the tty way of reading available input.
 
-   Note that each terminal device has its own `struct device' object,
+   Note that each terminal device has its own `struct terminal' object,
    and so this function is called once for each individual termcap
-   display.  The first parameter indicates which device to read from.  */
+   terminal.  The first parameter indicates which terminal to read from.  */
 
 int
-tty_read_avail_input (struct device *device,
+tty_read_avail_input (struct terminal *terminal,
                       int expected,
                       struct input_event *hold_quit)
 {
@@ -6828,10 +6828,10 @@
      of characters on some systems when input is stuffed at us.  */
   unsigned char cbuf[KBD_BUFFER_SIZE - 1];
   int n_to_read, i;
-  struct tty_display_info *tty = device->display_info.tty;
+  struct tty_display_info *tty = terminal->display_info.tty;
   int nread = 0;
 
-  if (device->type != output_termcap)
+  if (terminal->type != output_termcap)
     abort ();
 
   /* XXX I think the following code should be moved to separate hook
@@ -6861,7 +6861,7 @@
   if (ioctl (fileno (tty->input), FIONREAD, &n_to_read) < 0)
     {
       if (! noninteractive)
-        return -2;          /* Close this device. */
+        return -2;          /* Close this terminal. */
       else
         n_to_read = 0;
     }
@@ -6890,14 +6890,14 @@
          when the control tty is taken away.
          Jeffrey Honig <jch@bsdi.com> says this is generally safe. */
       if (nread == -1 && errno == EIO)
-        return -2;          /* Close this device. */
+        return -2;          /* Close this terminal. */
 #if defined (AIX) && (! defined (aix386) && defined (_BSD))
       /* The kernel sometimes fails to deliver SIGHUP for ptys.
          This looks incorrect, but it isn't, because _BSD causes
          O_NDELAY to be defined in fcntl.h as O_NONBLOCK,
          and that causes a value other than 0 when there is no input.  */
       if (nread == 0)
-        return -2;          /* Close this device. */
+        return -2;          /* Close this terminal. */
 #endif
     }
   while (
@@ -10440,7 +10440,7 @@
 {
   /* Must preserve main program's value of errno.  */
   int old_errno = errno;
-  struct device *device;
+  struct terminal *terminal;
 
 #if defined (USG) && !defined (POSIX_SIGNALS)
   /* USG systems forget handlers when they are used;
@@ -10451,9 +10451,9 @@
 
   SIGNAL_THREAD_CHECK (signalnum);
 
-  /* See if we have an active display on our controlling terminal. */
-  device = get_named_tty (NULL);
-  if (!device)
+  /* See if we have an active terminal on our controlling tty. */
+  terminal = get_named_tty (NULL);
+  if (!terminal)
     {
       /* If there are no frames there, let's pretend that we are a
          well-behaving UN*X program and quit. */
@@ -10467,7 +10467,7 @@
          controlling tty, if we have a frame there.  We disable the
          interrupt key on secondary ttys, so the SIGINT must have come
          from the controlling tty.  */
-      internal_last_event_frame = device->display_info.tty->top_frame;
+      internal_last_event_frame = terminal->display_info.tty->top_frame;
 
       handle_interrupt ();
     }
@@ -10710,18 +10710,18 @@
 If FLOW is non-nil, flow control is enabled and you cannot use C-s or
 C-q in key sequences.
 
-This setting only has an effect on tty display devices and only when
+This setting only has an effect on tty terminals and only when
 Emacs reads input in CBREAK mode; see `set-input-interrupt-mode'.
 
 See also `current-input-mode'.  */)
        (flow, terminal)
        Lisp_Object flow, terminal;
 {
-  struct device *d = get_device (terminal, 1);
+  struct terminal *t = get_terminal (terminal, 1);
   struct tty_display_info *tty;
-  if (d == NULL || d->type != output_termcap)
+  if (t == NULL || t->type != output_termcap)
     return Qnil;
-  tty = d->display_info.tty;
+  tty = t->display_info.tty;
 
   if (tty->flow_control != !NILP (flow))
     {
@@ -10750,9 +10750,9 @@
 Otherwise, Emacs will accept and pass through 8-bit input without
 specially interpreting the top bit.
 
-This setting only has an effect on tty display devices.
-
-Optional parameter TERMINAL specifies the tty display device to use.
+This setting only has an effect on tty terminal devices.
+
+Optional parameter TERMINAL specifies the tty terminal device to use.
 It may be a terminal id, a frame, or nil for the terminal used by the
 currently selected frame.
 
@@ -10760,13 +10760,13 @@
        (meta, terminal)
        Lisp_Object meta, terminal;
 {
-  struct device *d = get_device (terminal, 1);
+  struct terminal *t = get_terminal (terminal, 1);
   struct tty_display_info *tty;
   int new_meta;
   
-  if (d == NULL || d->type != output_termcap)
+  if (t == NULL || t->type != output_termcap)
     return Qnil;
-  tty = d->display_info.tty;
+  tty = t->display_info.tty;
 
   if (NILP (meta))
     new_meta = 0;
@@ -10795,18 +10795,18 @@
        doc: /* Specify character used for quitting.
 QUIT must be an ASCII character.
 
-This function only has an effect on the tty display on the controlling
+This function only has an effect on the terminal on the controlling
 tty of the Emacs process.
 
 See also `current-input-mode'.  */)
        (quit)
        Lisp_Object quit;
 {
-  struct device *d = get_named_tty (NULL);
+  struct terminal *t = get_named_tty (NULL);
   struct tty_display_info *tty;
-  if (d == NULL || d->type != output_termcap)
+  if (t == NULL || t->type != output_termcap)
     return Qnil;
-  tty = d->display_info.tty;
+  tty = t->display_info.tty;
 
 #ifndef DOS_NT
   /* this causes startup screen to be restored and messes with the mouse */
@@ -11025,7 +11025,7 @@
       && FRAMEP (selected_frame)
       && FRAME_LIVE_P (XFRAME (selected_frame)))
     {
-      current_kboard = XFRAME (selected_frame)->device->kboard;
+      current_kboard = XFRAME (selected_frame)->terminal->kboard;
       if (current_kboard == kb)
 	abort ();
     }
@@ -11463,7 +11463,7 @@
 The value `kill-region' is special; it means that the previous command
 was a kill command.
 
-`last-command' has a separate binding for each display device.
+`last-command' has a separate binding for each terminal device.
 See Info node `(elisp)Multiple displays'.  */);
 
   DEFVAR_KBOARD ("real-last-command", Vreal_last_command,
@@ -11589,8 +11589,8 @@
 This is applied to the characters supplied to input methods, not their
 output.  See also `translation-table-for-input'.
 
-`local-keyboard-translate-table' has a separate binding for each
-terminal.  See Info node `(elisp)Multiple displays'.  */);
+This variable has a separate binding for each terminal.  See Info node
+`(elisp)Multiple displays'.  */);
 
   DEFVAR_BOOL ("cannot-suspend", &cannot_suspend,
 	       doc: /* Non-nil means to always spawn a subshell instead of suspending.
@@ -11677,7 +11677,8 @@
 This variable is intended to let commands such as `universal-argument'
 set up a different keymap for reading the next command.
 
-`overriding-terminal-local-map' has a separate binding for each display device.
+`overriding-terminal-local-map' has a separate binding for each
+terminal device.
 See Info node `(elisp)Multiple displays'.  */);
 
   DEFVAR_LISP ("overriding-local-map", &Voverriding_local_map,
@@ -11705,7 +11706,7 @@
 numeric keysym code (sans the \"system-specific\" bit 1<<28)
 and SYMBOL is its name.
 
-`system-key-alist' has a separate binding for each display device.
+`system-key-alist' has a separate binding for each terminal device.
 See Info node `(elisp)Multiple displays'.  */);
 
   DEFVAR_KBOARD ("local-function-key-map", Vlocal_function_key_map,
@@ -11731,15 +11732,15 @@
 `C-x ESC O P' would return [?\\C-x f1].  If [f1] were a prefix key,
 typing `ESC O P x' would return [f1 x].
 
-`local-function-key-map' has a separate binding for each display
+`local-function-key-map' has a separate binding for each terminal
 device.  See Info node `(elisp)Multiple displays'.  If you need to
-define a binding on all display devices, change `function-key-map'
+define a binding on all terminals, change `function-key-map'
 instead.  Initially, `local-function-key-map' is an empty keymap that
-has `function-key-map' as its parent on all display devices.  */);
+has `function-key-map' as its parent on all terminal devices.  */);
 
   DEFVAR_LISP ("function-key-map", &Vfunction_key_map,
                doc: /* The parent keymap of all `local-function-key-map' instances.
-Function key definitions that apply to all display devices should go
+Function key definitions that apply to all terminal devices should go
 here.  If a mapping is defined in both the current
 `local-function-key-map' binding and this variable, then the local
 definition will take precendence.  */);
@@ -11750,13 +11751,13 @@
 This keymap works like `function-key-map', but comes after that,
 and its non-prefix bindings override ordinary bindings.
 
-`key-translation-map' has a separate binding for each display device.
+`key-translation-map' has a separate binding for each terminal device.
 (See Info node `(elisp)Multiple displays'.)  If you need to set a key
-translation on all devices, change `global-key-translation-map' instead.  */);
+translation on all terminals, change `global-key-translation-map' instead.  */);
 
   DEFVAR_LISP ("key-translation-map", &Vkey_translation_map,
                doc: /* The parent keymap of all `local-key-translation-map' instances.
-Key translations that apply to all display devices should go here.  */);
+Key translations that apply to all terminal devices should go here.  */);
   Vkey_translation_map = Fmake_sparse_keymap (Qnil);
 
   DEFVAR_LISP ("deferred-action-list", &Vdeferred_action_list,
--- a/src/keyboard.h	Thu Dec 29 04:57:14 2005 +0000
+++ b/src/keyboard.h	Thu Dec 29 18:20:26 2005 +0000
@@ -21,8 +21,9 @@
 
 /* Length of echobuf field in each KBOARD.  */
 
-/* Each KBOARD represents one logical input stream from which Emacs gets input.
-   If we are using ordinary terminals, it has one KBOARD object for each terminal device.
+/* Each KBOARD represents one logical input stream from which Emacs
+   gets input.  If we are using ordinary terminals, it has one KBOARD
+   object for each terminal device.
    Usually each X display screen has its own KBOARD,
    but when two of them are on the same X server,
    we assume they share a keyboard and give them one KBOARD in common.
@@ -356,7 +357,7 @@
 extern Lisp_Object menu_item_eval_property P_ ((Lisp_Object));
 extern int  kbd_buffer_events_waiting P_ ((int));
 
-extern int tty_read_avail_input P_ ((struct device *, int,
+extern int tty_read_avail_input P_ ((struct terminal *, int,
                                      struct input_event *));
 
 /* arch-tag: 769cbade-1ba9-4950-b886-db265b061aa3
--- a/src/lisp.h	Thu Dec 29 04:57:14 2005 +0000
+++ b/src/lisp.h	Thu Dec 29 18:20:26 2005 +0000
@@ -3064,7 +3064,7 @@
 extern int child_setup P_ ((int, int, int, char **, int, Lisp_Object));
 extern void init_callproc_1 P_ ((void));
 extern void init_callproc P_ ((void));
-extern void set_process_environment P_ ((void));
+extern void set_global_environment P_ ((void));
 extern void syms_of_callproc P_ ((void));
 
 /* defined in doc.c */
@@ -3130,7 +3130,7 @@
 struct tty_display_info;
 
 /* defined in termhooks.h */
-struct device;
+struct terminal;
 
 /* defined in sysdep.c */
 #ifndef HAVE_GET_CURRENT_DIR_NAME
--- a/src/minibuf.c	Thu Dec 29 04:57:14 2005 +0000
+++ b/src/minibuf.c	Thu Dec 29 18:20:26 2005 +0000
@@ -552,7 +552,7 @@
   if (minibuffer_auto_raise)
     Fraise_frame (mini_frame);
 
-  temporarily_switch_to_single_kboard (XFRAME (mini_frame)->device->kboard);
+  temporarily_switch_to_single_kboard (XFRAME (mini_frame)->terminal->kboard);
 
   /* We have to do this after saving the window configuration
      since that is what restores the current buffer.  */
--- a/src/sysdep.c	Thu Dec 29 04:57:14 2005 +0000
+++ b/src/sysdep.c	Thu Dec 29 18:20:26 2005 +0000
@@ -1782,7 +1782,7 @@
   setbuf (tty_out->output, (char *) _sobuf);
 #endif
 
-  tty_set_terminal_modes (tty_out->device);
+  tty_set_terminal_modes (tty_out->terminal);
 
   if (!tty_out->term_initted)
     {
@@ -1994,7 +1994,7 @@
   }
 #endif
 
-  tty_reset_terminal_modes (tty_out->device);
+  tty_reset_terminal_modes (tty_out->terminal);
 
 #ifdef BSD_SYSTEM
 #ifndef BSD4_1
--- a/src/term.c	Thu Dec 29 04:57:14 2005 +0000
+++ b/src/term.c	Thu Dec 29 18:20:26 2005 +0000
@@ -87,7 +87,7 @@
 static void tty_hide_cursor P_ ((struct tty_display_info *));
 static void tty_background_highlight P_ ((struct tty_display_info *tty));
 static void dissociate_if_controlling_tty P_ ((int fd));
-static void delete_tty P_ ((struct device *));
+static void delete_tty P_ ((struct terminal *));
 
 #define OUTPUT(tty, a)                                          \
   emacs_tputs ((tty), a,                                        \
@@ -198,9 +198,9 @@
 /* Set up termcap modes for Emacs. */
 
 void
-tty_set_terminal_modes (struct device *display)
+tty_set_terminal_modes (struct terminal *terminal)
 {
-  struct tty_display_info *tty = display->display_info.tty;
+  struct tty_display_info *tty = terminal->display_info.tty;
   
   if (tty->output)
     {
@@ -227,9 +227,9 @@
 /* Reset termcap modes before exiting Emacs. */
 
 void
-tty_reset_terminal_modes (struct device *display)
+tty_reset_terminal_modes (struct terminal *terminal)
 {
-  struct tty_display_info *tty = display->display_info.tty;
+  struct tty_display_info *tty = terminal->display_info.tty;
 
   if (tty->output)
     {
@@ -246,7 +246,7 @@
     }
 }
 
-/* Flag the end of a display update on a termcap display. */
+/* Flag the end of a display update on a termcap terminal. */
 
 static void
 tty_update_end (struct frame *f)
@@ -1809,30 +1809,37 @@
 
 DEFUN ("tty-display-color-p", Ftty_display_color_p, Stty_display_color_p,
        0, 1, 0,
-       doc: /* Return non-nil if the display device DEVICE can display colors.
-DEVICE must be a tty device.  */)
-     (device)
-     Lisp_Object device;
+       doc: /* Return non-nil if the tty device TERMINAL can display colors.
+
+TERMINAL can be a terminal id, a frame or nil (meaning the selected
+frame's terminal).  This function always returns nil if TERMINAL
+is not on a tty device.  */)
+     (terminal)
+     Lisp_Object terminal;
 {
-  struct device *d = get_tty_device (device);
-  if (!d)
+  struct terminal *t = get_tty_terminal (terminal);
+  if (!t)
     return Qnil;
   else
-    return d->display_info.tty->TN_max_colors > 0 ? Qt : Qnil;
+    return t->display_info.tty->TN_max_colors > 0 ? Qt : Qnil;
 }
 
 /* Return the number of supported colors.  */
 DEFUN ("tty-display-color-cells", Ftty_display_color_cells,
        Stty_display_color_cells, 0, 1, 0,
-       doc: /* Return the number of colors supported by the tty device DEVICE.  */)
-     (device)
-     Lisp_Object device;
+       doc: /* Return the number of colors supported by the tty device TERMINAL.
+
+TERMINAL can be a terminal id, a frame or nil (meaning the selected
+frame's terminal).  This function always returns nil if TERMINAL
+is not on a tty device.  */)
+     (terminal)
+     Lisp_Object terminal;
 {
-  struct device *d = get_tty_device (device);
-  if (!d)
+  struct terminal *t = get_tty_terminal (terminal);
+  if (!t)
     return make_number (0);
   else
-    return make_number (d->display_info.tty->TN_max_colors);
+    return make_number (t->display_info.tty->TN_max_colors);
 }
 
 #ifndef WINDOWSNT
@@ -1974,20 +1981,20 @@
 
 
 
-/* Return the tty display object specified by DEVICE. */
-
-struct device *
-get_tty_device (Lisp_Object terminal)
+/* Return the tty display object specified by TERMINAL. */
+
+struct terminal *
+get_tty_terminal (Lisp_Object terminal)
 {
-  struct device *d = get_device (terminal, 0);
-
-  if (d && d->type == output_initial)
-    d = NULL;
-
-  if (d && d->type != output_termcap)
-    error ("Device %d is not a termcap display device", d->id);
-
-  return d;
+  struct terminal *t = get_terminal (terminal, 0);
+
+  if (t && t->type == output_initial)
+    t = NULL;
+
+  if (t && t->type != output_termcap)
+    error ("Device %d is not a termcap terminal device", t->id);
+
+  return t;
 }
 
 /* Return the active termcap device that uses the tty device with the
@@ -1998,75 +2005,77 @@
 
    Returns NULL if the named terminal device is not opened.  */
  
-struct device *
+struct terminal *
 get_named_tty (name)
      char *name;
 {
-  struct device *d;
-
-  for (d = device_list; d; d = d->next_device) {
-    if (d->type == output_termcap
-        && ((d->display_info.tty->name == 0 && name == 0)
-            || (name && d->display_info.tty->name
-                && !strcmp (d->display_info.tty->name, name)))
-        && DEVICE_ACTIVE_P (d))
-      return d;
+  struct terminal *t;
+
+  for (t = terminal_list; t; t = t->next_terminal) {
+    if (t->type == output_termcap
+        && ((t->display_info.tty->name == 0 && name == 0)
+            || (name && t->display_info.tty->name
+                && !strcmp (t->display_info.tty->name, name)))
+        && TERMINAL_ACTIVE_P (t))
+      return t;
   };
 
   return 0;
 }
 
 
-DEFUN ("display-tty-type", Fdisplay_tty_type, Sdisplay_tty_type, 0, 1, 0,
-       doc: /* Return the type of the tty device that DEVICE uses.
-
-DEVICE may be a display device id, a frame, or nil (meaning the
-selected frame's display device). */)
-  (device)
-     Lisp_Object device;
+DEFUN ("tty-type", Ftty_type, Stty_type, 0, 1, 0,
+       doc: /* Return the type of the tty device that TERMINAL uses.
+
+TERMINAL can be a terminal id, a frame or nil (meaning the selected
+frame's terminal).  */)
+     (terminal)
+     Lisp_Object terminal;
 {
-  struct device *d = get_device (device, 1);
-
-  if (d->type != output_termcap)
-    error ("Display %d is not a termcap display", d->id);
+  struct terminal *t = get_terminal (terminal, 1);
+
+  if (t->type != output_termcap)
+    error ("Terminal %d is not a termcap terminal", t->id);
            
-  if (d->display_info.tty->type)
-    return build_string (d->display_info.tty->type);
+  if (t->display_info.tty->type)
+    return build_string (t->display_info.tty->type);
   else
     return Qnil;
 }
 
-DEFUN ("display-controlling-tty-p", Fdisplay_controlling_tty_p, Sdisplay_controlling_tty_p, 0, 1, 0,
-       doc: /* Return non-nil if DEVICE is on the controlling tty of the Emacs process.
-
-DEVICE may be a display device id, a frame, or nil (meaning the
-selected frame's display device).  */)
-  (device)
-     Lisp_Object device;
+DEFUN ("controlling-tty-p", Fcontrolling_tty_p, Scontrolling_tty_p, 0, 1, 0,
+       doc: /* Return non-nil if TERMINAL is on the controlling tty of the Emacs process.
+
+TERMINAL can be a terminal id, a frame or nil (meaning the selected
+frame's terminal).  This function always returns nil if TERMINAL
+is not on a tty device.  */)
+     (terminal)
+     Lisp_Object terminal;
 {
-  struct device *d = get_device (device, 1);
-
-  if (d->type != output_termcap || d->display_info.tty->name)
+  struct terminal *t = get_terminal (terminal, 1);
+
+  if (t->type != output_termcap || t->display_info.tty->name)
     return Qnil;
   else
     return Qt;
 }
 
 DEFUN ("tty-no-underline", Ftty_no_underline, Stty_no_underline, 0, 1, 0,
-       doc: /* Declare that the tty used by DEVICE does not handle underlining.
+       doc: /* Declare that the tty used by TERMINAL does not handle underlining.
 This is used to override the terminfo data, for certain terminals that
 do not really do underlining, but say that they do.  This function has
-no effect if used on a non-tty display.
-
-DEVICE may be a display device id, a frame, or nil (meaning the
-selected frame's display device).  */)
-  (device)
-     Lisp_Object device;
+no effect if used on a non-tty terminal.
+
+TERMINAL can be a terminal id, a frame or nil (meaning the selected
+frame's terminal).  This function always returns nil if TERMINAL
+is not on a tty device.  */)
+  (terminal)
+     Lisp_Object terminal;
 {
-  struct device *d = get_device (device, 1);
-
-  if (d->type == output_termcap)
-    d->display_info.tty->TS_enter_underline_mode = 0;
+  struct terminal *t = get_terminal (terminal, 1);
+
+  if (t->type == output_termcap)
+    t->display_info.tty->TS_enter_underline_mode = 0;
   return Qnil;
 }
 
@@ -2094,36 +2103,36 @@
      (tty)
      Lisp_Object tty;
 {
-  struct device *d = get_tty_device (tty);
+  struct terminal *t = get_tty_terminal (tty);
   FILE *f;
   
-  if (!d)
+  if (!t)
     error ("Unknown tty device");
 
-  f = d->display_info.tty->input;
+  f = t->display_info.tty->input;
   
   if (f)
     {
-      reset_sys_modes (d->display_info.tty);
+      reset_sys_modes (t->display_info.tty);
 
       delete_keyboard_wait_descriptor (fileno (f));
       
       fclose (f);
-      if (f != d->display_info.tty->output)
-        fclose (d->display_info.tty->output);
+      if (f != t->display_info.tty->output)
+        fclose (t->display_info.tty->output);
       
-      d->display_info.tty->input = 0;
-      d->display_info.tty->output = 0;
-
-      if (FRAMEP (d->display_info.tty->top_frame))
-        FRAME_SET_VISIBLE (XFRAME (d->display_info.tty->top_frame), 0);
+      t->display_info.tty->input = 0;
+      t->display_info.tty->output = 0;
+
+      if (FRAMEP (t->display_info.tty->top_frame))
+        FRAME_SET_VISIBLE (XFRAME (t->display_info.tty->top_frame), 0);
       
       /* Run `suspend-tty-functions'.  */
       if (!NILP (Vrun_hooks))
         {
           Lisp_Object args[2];
           args[0] = intern ("suspend-tty-functions");
-          args[1] = make_number (d->id);
+          args[1] = make_number (t->id);
           Frun_hook_with_args (2, args);
         }
     }
@@ -2134,56 +2143,56 @@
 DEFUN ("resume-tty", Fresume_tty, Sresume_tty, 0, 1, 0,
        doc: /* Resume the previously suspended terminal device TTY.
 The terminal is opened and reinitialized.  Frames that are on the
-suspended display are revived.
-
-It is an error to resume a display while another display is active on
-the same device.
-
-This function runs `resume-tty-functions' after resuming the device.
-The functions are run with one arg, the id of the resumed display
+suspended terminal are revived.
+
+It is an error to resume a terminal while another terminal is active
+on the same device.
+
+This function runs `resume-tty-functions' after resuming the terminal.
+The functions are run with one arg, the id of the resumed terminal
 device.
 
 `resume-tty' does nothing if it is called on a device that is not
 suspended.
 
-TTY may be a display device id, a frame, or nil for the display device
-of the currently selected frame. */)
+TTY may be a terminal id, a frame, or nil for the terminal device of
+the currently selected frame. */)
      (tty)
      Lisp_Object tty;
 {
-  struct device *d = get_tty_device (tty);
+  struct terminal *t = get_tty_terminal (tty);
   int fd;
 
-  if (!d)
+  if (!t)
     error ("Unknown tty device");
 
-  if (!d->display_info.tty->input)
+  if (!t->display_info.tty->input)
     {
-      if (get_named_tty (d->display_info.tty->name))
+      if (get_named_tty (t->display_info.tty->name))
         error ("Cannot resume display while another display is active on the same device");
 
-      fd = emacs_open (d->display_info.tty->name, O_RDWR | O_NOCTTY, 0);
+      fd = emacs_open (t->display_info.tty->name, O_RDWR | O_NOCTTY, 0);
 
       /* XXX What if open fails? */
 
       dissociate_if_controlling_tty (fd);
       
-      d->display_info.tty->output = fdopen (fd, "w+");
-      d->display_info.tty->input = d->display_info.tty->output;
+      t->display_info.tty->output = fdopen (fd, "w+");
+      t->display_info.tty->input = t->display_info.tty->output;
     
       add_keyboard_wait_descriptor (fd);
 
-      if (FRAMEP (d->display_info.tty->top_frame))
-        FRAME_SET_VISIBLE (XFRAME (d->display_info.tty->top_frame), 1);
-
-      init_sys_modes (d->display_info.tty);
+      if (FRAMEP (t->display_info.tty->top_frame))
+        FRAME_SET_VISIBLE (XFRAME (t->display_info.tty->top_frame), 1);
+
+      init_sys_modes (t->display_info.tty);
 
       /* Run `suspend-tty-functions'.  */
       if (!NILP (Vrun_hooks))
         {
           Lisp_Object args[2];
           args[0] = intern ("resume-tty-functions");
-          args[1] = make_number (d->id);
+          args[1] = make_number (t->id);
           Frun_hook_with_args (2, args);
         }
     }
@@ -2210,7 +2219,7 @@
   t = xmalloc (sizeof (struct tty_output));
   bzero (t, sizeof (struct tty_output));
 
-  t->display_info = FRAME_DEVICE (f)->display_info.tty;
+  t->display_info = FRAME_TERMINAL (f)->display_info.tty;
 
   f->output_data.tty = t;
 }
@@ -2271,7 +2280,7 @@
 
    If MUST_SUCCEED is true, then all errors are fatal. */
 
-struct device *
+struct terminal *
 init_tty (char *name, char *terminal_type, int must_succeed)
 {
   char *area;
@@ -2281,72 +2290,72 @@
   register char *p;
   int status;
   struct tty_display_info *tty;
-  struct device *device;
+  struct terminal *terminal;
 
   if (!terminal_type)
     maybe_fatal (must_succeed, 0, 0,
                  "Unknown terminal type",
                  "Unknown terminal type");
 
-  /* If we already have a display on the given device, use that.  If
-     all such displays are suspended, create a new one instead.  */
+  /* If we already have a terminal on the given device, use that.  If
+     all such terminals are suspended, create a new one instead.  */
   /* XXX Perhaps this should be made explicit by having init_tty
-     always create a new display and separating device and frame
+     always create a new terminal and separating terminal and frame
      creation on Lisp level.  */
-  device = get_named_tty (name);
-  if (device)
-    return device;
-
-  device = create_device ();
+  terminal = get_named_tty (name);
+  if (terminal)
+    return terminal;
+
+  terminal = create_terminal ();
   tty = (struct tty_display_info *) xmalloc (sizeof (struct tty_display_info));
   bzero (tty, sizeof (struct tty_display_info));
   tty->next = tty_list;
   tty_list = tty;
 
-  device->type = output_termcap;
-  device->display_info.tty = tty;
-  tty->device = device;
+  terminal->type = output_termcap;
+  terminal->display_info.tty = tty;
+  tty->terminal = terminal;
 
   tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm));
   Wcm_clear (tty);
 
-  device->rif = 0; /* ttys don't support window-based redisplay. */
-
-  device->cursor_to_hook = &tty_cursor_to;
-  device->raw_cursor_to_hook = &tty_raw_cursor_to;
-
-  device->clear_to_end_hook = &tty_clear_to_end;
-  device->clear_frame_hook = &tty_clear_frame;
-  device->clear_end_of_line_hook = &tty_clear_end_of_line;
-
-  device->ins_del_lines_hook = &tty_ins_del_lines;
-
-  device->insert_glyphs_hook = &tty_insert_glyphs;
-  device->write_glyphs_hook = &tty_write_glyphs;
-  device->delete_glyphs_hook = &tty_delete_glyphs;
-
-  device->ring_bell_hook = &tty_ring_bell;
+  terminal->rif = 0; /* ttys don't support window-based redisplay. */
+
+  terminal->cursor_to_hook = &tty_cursor_to;
+  terminal->raw_cursor_to_hook = &tty_raw_cursor_to;
+
+  terminal->clear_to_end_hook = &tty_clear_to_end;
+  terminal->clear_frame_hook = &tty_clear_frame;
+  terminal->clear_end_of_line_hook = &tty_clear_end_of_line;
+
+  terminal->ins_del_lines_hook = &tty_ins_del_lines;
+
+  terminal->insert_glyphs_hook = &tty_insert_glyphs;
+  terminal->write_glyphs_hook = &tty_write_glyphs;
+  terminal->delete_glyphs_hook = &tty_delete_glyphs;
+
+  terminal->ring_bell_hook = &tty_ring_bell;
   
-  device->reset_terminal_modes_hook = &tty_reset_terminal_modes;
-  device->set_terminal_modes_hook = &tty_set_terminal_modes;
-  device->update_begin_hook = 0; /* Not needed. */
-  device->update_end_hook = &tty_update_end;
-  device->set_terminal_window_hook = &tty_set_terminal_window;
-
-  device->mouse_position_hook = 0; /* Not needed. */
-  device->frame_rehighlight_hook = 0; /* Not needed. */
-  device->frame_raise_lower_hook = 0; /* Not needed. */
-
-  device->set_vertical_scroll_bar_hook = 0; /* Not needed. */
-  device->condemn_scroll_bars_hook = 0; /* Not needed. */
-  device->redeem_scroll_bar_hook = 0; /* Not needed. */
-  device->judge_scroll_bars_hook = 0; /* Not needed. */
-
-  device->read_socket_hook = &tty_read_avail_input; /* keyboard.c */
-  device->frame_up_to_date_hook = 0; /* Not needed. */
+  terminal->reset_terminal_modes_hook = &tty_reset_terminal_modes;
+  terminal->set_terminal_modes_hook = &tty_set_terminal_modes;
+  terminal->update_begin_hook = 0; /* Not needed. */
+  terminal->update_end_hook = &tty_update_end;
+  terminal->set_terminal_window_hook = &tty_set_terminal_window;
+
+  terminal->mouse_position_hook = 0; /* Not needed. */
+  terminal->frame_rehighlight_hook = 0; /* Not needed. */
+  terminal->frame_raise_lower_hook = 0; /* Not needed. */
+
+  terminal->set_vertical_scroll_bar_hook = 0; /* Not needed. */
+  terminal->condemn_scroll_bars_hook = 0; /* Not needed. */
+  terminal->redeem_scroll_bar_hook = 0; /* Not needed. */
+  terminal->judge_scroll_bars_hook = 0; /* Not needed. */
+
+  terminal->read_socket_hook = &tty_read_avail_input; /* keyboard.c */
+  terminal->frame_up_to_date_hook = 0; /* Not needed. */
   
-  device->delete_frame_hook = &delete_tty_output;
-  device->delete_device_hook = &delete_tty;
+  terminal->delete_frame_hook = &delete_tty_output;
+  terminal->delete_terminal_hook = &delete_tty;
   
   if (name)
     {
@@ -2370,7 +2379,7 @@
 
       if (fd < 0)
         {
-          delete_tty (device);
+          delete_tty (terminal);
           error ("Could not open file: %s", name);
         }
       if (!isatty (fd))
@@ -2383,7 +2392,7 @@
       
       file = fdopen (fd, "w+");
       tty->name = xstrdup (name);
-      device->name = xstrdup (name);
+      terminal->name = xstrdup (name);
       tty->input = file;
       tty->output = file;
     }
@@ -2396,7 +2405,7 @@
           error ("There is no controlling terminal any more");
         }
       tty->name = 0;
-      device->name = xstrdup (ttyname (0));
+      terminal->name = xstrdup (ttyname (0));
       tty->input = stdin;
       tty->output = stdout;
     }
@@ -2418,16 +2427,16 @@
   FrameCols (tty) = FRAME_COLS (f);  /* XXX */
   tty->specified_window = FRAME_LINES (f); /* XXX */
 
-  tty->device->delete_in_insert_mode = 1;
+  tty->terminal->delete_in_insert_mode = 1;
 
   UseTabs (tty) = 0;
-  device->scroll_region_ok = 0;
+  terminal->scroll_region_ok = 0;
 
   /* Seems to insert lines when it's not supposed to, messing up the
-     device.  In doing a trace, it didn't seem to be called much, so I
+     display.  In doing a trace, it didn't seem to be called much, so I
      don't think we're losing anything by turning it off.  */
-  device->line_ins_del_ok = 0;
-  device->char_ins_del_ok = 1;
+  terminal->line_ins_del_ok = 0;
+  terminal->char_ins_del_ok = 1;
 
   baud_rate = 19200;
 
@@ -2435,7 +2444,7 @@
   FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none; /* XXX */
   TN_max_colors = 16;  /* Required to be non-zero for tty-display-color-p */
 
-  return device;
+  return terminal;
 #else  /* not WINDOWSNT */
 
   Wcm_clear (tty);
@@ -2451,11 +2460,11 @@
   if (status < 0)
     {
 #ifdef TERMINFO
-      maybe_fatal (must_succeed, buffer, device,
+      maybe_fatal (must_succeed, buffer, terminal,
                    "Cannot open terminfo database file",
                    "Cannot open terminfo database file");
 #else
-      maybe_fatal (must_succeed, buffer, device,
+      maybe_fatal (must_succeed, buffer, terminal,
                    "Cannot open termcap database file",
                    "Cannot open termcap database file");
 #endif
@@ -2463,7 +2472,7 @@
   if (status == 0)
     {
 #ifdef TERMINFO
-      maybe_fatal (must_succeed, buffer, device,
+      maybe_fatal (must_succeed, buffer, terminal,
                    "Terminal type %s is not defined",
                    "Terminal type %s is not defined.\n\
 If that is not the actual type of terminal you have,\n\
@@ -2472,7 +2481,7 @@
 to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.",
                    terminal_type);
 #else
-      maybe_fatal (must_succeed, buffer, device,
+      maybe_fatal (must_succeed, buffer, terminal,
                    "Terminal type %s is not defined",
                    "Terminal type %s is not defined.\n\
 If that is not the actual type of terminal you have,\n\
@@ -2594,9 +2603,9 @@
   /* Since we make MagicWrap terminals look like AutoWrap, we need to have
      the former flag imply the latter.  */
   AutoWrap (tty) = MagicWrap (tty) || tgetflag ("am");
-  device->memory_below_frame = tgetflag ("db");
+  terminal->memory_below_frame = tgetflag ("db");
   tty->TF_hazeltine = tgetflag ("hz");
-  device->must_write_spaces = tgetflag ("in");
+  terminal->must_write_spaces = tgetflag ("in");
   tty->meta_key = tgetflag ("km") || tgetflag ("MT");
   tty->TF_insmode_motion = tgetflag ("mi");
   tty->TF_standout_motion = tgetflag ("ms");
@@ -2604,19 +2613,19 @@
   tty->TF_teleray = tgetflag ("xt");
 
 #ifdef MULTI_KBOARD
-  device->kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
-  init_kboard (device->kboard);
-  device->kboard->next_kboard = all_kboards;
-  all_kboards = device->kboard;
-  device->kboard->reference_count++;
+  terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
+  init_kboard (terminal->kboard);
+  terminal->kboard->next_kboard = all_kboards;
+  all_kboards = terminal->kboard;
+  terminal->kboard->reference_count++;
   /* Don't let the initial kboard remain current longer than necessary.
      That would cause problems if a file loaded on startup tries to
      prompt in the mini-buffer.  */
   if (current_kboard == initial_kboard)
-    current_kboard = device->kboard;
+    current_kboard = terminal->kboard;
 #endif
 
-  term_get_fkeys (address, device->kboard);
+  term_get_fkeys (address, terminal->kboard);
 
   /* Get frame size from system, or else from termcap.  */
   {
@@ -2632,13 +2641,13 @@
     FrameRows (tty) = tgetnum ("li");
 
   if (FrameRows (tty) < 3 || FrameCols (tty) < 3)
-    maybe_fatal (must_succeed, NULL, device,
+    maybe_fatal (must_succeed, NULL, terminal,
                  "Screen size %dx%d is too small"
                  "Screen size %dx%d is too small",
                  FrameCols (tty), FrameRows (tty));
 
 #if 0  /* This is not used anywhere. */
-  tty->device->min_padding_speed = tgetnum ("pb");
+  tty->terminal->min_padding_speed = tgetnum ("pb");
 #endif
 
   TabWidth (tty) = tgetnum ("tw");
@@ -2716,7 +2725,7 @@
 
   if (!strcmp (terminal_type, "supdup"))
     {
-      device->memory_below_frame = 1;
+      terminal->memory_below_frame = 1;
       tty->Wcm->cm_losewrap = 1;
     }
   if (!strncmp (terminal_type, "c10", 3)
@@ -2743,7 +2752,7 @@
 	    tty->TS_set_window = "\033v%C %C %C %C ";
 	}
       /* Termcap entry often fails to have :in: flag */
-      device->must_write_spaces = 1;
+      terminal->must_write_spaces = 1;
       /* :ti string typically fails to have \E^G! in it */
       /* This limits scope of insert-char to one line.  */
       strcpy (area, tty->TS_termcap_modes);
@@ -2765,7 +2774,7 @@
 
   if (Wcm_init (tty) == -1)	/* can't do cursor motion */
     {
-      maybe_fatal (must_succeed, NULL, device,
+      maybe_fatal (must_succeed, NULL, terminal,
                    "Terminal type \"%s\" is not powerful enough to run Emacs",
 #ifdef VMS
                    "Terminal type \"%s\" is not powerful enough to run Emacs.\n\
@@ -2794,7 +2803,7 @@
     }
 
   if (FrameRows (tty) <= 0 || FrameCols (tty) <= 0)
-    maybe_fatal (must_succeed, NULL, device,
+    maybe_fatal (must_succeed, NULL, terminal,
                  "Could not determine the frame size",
                  "Could not determine the frame size");
 
@@ -2808,30 +2817,30 @@
 
   UseTabs (tty) = tabs_safe_p (fileno (tty->input)) && TabWidth (tty) == 8;
 
-  device->scroll_region_ok
+  terminal->scroll_region_ok
     = (tty->Wcm->cm_abs
        && (tty->TS_set_window || tty->TS_set_scroll_region || tty->TS_set_scroll_region_1));
 
-  device->line_ins_del_ok
+  terminal->line_ins_del_ok
     = (((tty->TS_ins_line || tty->TS_ins_multi_lines)
         && (tty->TS_del_line || tty->TS_del_multi_lines))
-       || (device->scroll_region_ok
+       || (terminal->scroll_region_ok
            && tty->TS_fwd_scroll && tty->TS_rev_scroll));
 
-  device->char_ins_del_ok
+  terminal->char_ins_del_ok
     = ((tty->TS_ins_char || tty->TS_insert_mode
         || tty->TS_pad_inserted_char || tty->TS_ins_multi_chars)
        && (tty->TS_del_char || tty->TS_del_multi_chars));
 
-  device->fast_clear_end_of_line = tty->TS_clr_line != 0;
+  terminal->fast_clear_end_of_line = tty->TS_clr_line != 0;
 
   init_baud_rate (fileno (tty->input));
 
 #ifdef AIXHFT
   /* The HFT system on AIX doesn't optimize for scrolling, so it's
      really ugly at times.  */
-  device->line_ins_del_ok = 0;
-  device->char_ins_del_ok = 0;
+  terminal->line_ins_del_ok = 0;
+  terminal->char_ins_del_ok = 0;
 #endif
 
   /* Don't do this.  I think termcap may still need the buffer. */
@@ -2840,26 +2849,26 @@
   /* Init system terminal modes (RAW or CBREAK, etc.).  */
   init_sys_modes (tty);
 
-  return device;
+  return terminal;
 #endif /* not WINDOWSNT */
 }
 
 /* Auxiliary error-handling function for init_tty.
-   Free BUFFER and delete DEVICE, then call error or fatal
+   Free BUFFER and delete TERMINAL, then call error or fatal
    with str1 or str2, respectively, according to MUST_SUCCEED.  */
 
 static void
-maybe_fatal (must_succeed, buffer, device, str1, str2, arg1, arg2)
+maybe_fatal (must_succeed, buffer, terminal, str1, str2, arg1, arg2)
      int must_succeed;
      char *buffer;
-     struct device *device;
+     struct terminal *terminal;
      char *str1, *str2, *arg1, *arg2;
 {
   if (buffer)
     xfree (buffer);
 
-  if (device)
-    delete_tty (device);
+  if (terminal)
+    delete_tty (terminal);
   
   if (must_succeed)
     fatal (str2, arg1, arg2);
@@ -2886,38 +2895,38 @@
 static int deleting_tty = 0;
 
 
-/* Delete the given terminal device, closing all frames on it. */
+/* Delete the given tty terminal, closing all frames on it. */
 
 static void
-delete_tty (struct device *device)
+delete_tty (struct terminal *terminal)
 {
   struct tty_display_info *tty;
   Lisp_Object tail, frame;
   char *tty_name;
-  int last_device;
+  int last_terminal;
   
   if (deleting_tty)
     /* We get a recursive call when we delete the last frame on this
-       device. */
+       terminal. */
     return;
 
-  if (device->type != output_termcap)
+  if (terminal->type != output_termcap)
     abort ();
 
-  tty = device->display_info.tty;
+  tty = terminal->display_info.tty;
   
-  last_device = 1;
+  last_terminal = 1;
   FOR_EACH_FRAME (tail, frame)
     {
       struct frame *f = XFRAME (frame);
       if (FRAME_LIVE_P (f) && (!FRAME_TERMCAP_P (f) || FRAME_TTY (f) != tty))
         {
-          last_device = 0;
+          last_terminal = 0;
           break;
         }
     }
-  if (last_device)
-      error ("Attempt to delete the sole display device with live frames");
+  if (last_terminal)
+      error ("Attempt to delete the sole terminal device with live frames");
   
   if (tty == tty_list)
     tty_list = tty->next;
@@ -2947,10 +2956,10 @@
     }
 
   /* reset_sys_modes needs a valid device, so this call needs to be
-     before delete_device. */
+     before delete_terminal. */
   reset_sys_modes (tty);
 
-  delete_device (device);
+  delete_terminal (terminal);
 
   tty_name = tty->name;
   if (tty->type)
@@ -3025,8 +3034,8 @@
   defsubr (&Stty_display_color_p);
   defsubr (&Stty_display_color_cells);
   defsubr (&Stty_no_underline);
-  defsubr (&Sdisplay_tty_type);
-  defsubr (&Sdisplay_controlling_tty_p);
+  defsubr (&Stty_type);
+  defsubr (&Scontrolling_tty_p);
   defsubr (&Ssuspend_tty);
   defsubr (&Sresume_tty);
 }
--- a/src/termchar.h	Thu Dec 29 04:57:14 2005 +0000
+++ b/src/termchar.h	Thu Dec 29 18:20:26 2005 +0000
@@ -58,9 +58,9 @@
 
   int reference_count;          /* Number of frames that are on this display. */
 
-  struct device *device;        /* Points back to the generic display device
+  struct terminal *terminal;    /* Points back to the generic terminal
                                    structure.  This is sometimes handy. */
-  
+
   /* Info on cursor positioning.  */
   struct cm *Wcm;
 
@@ -194,7 +194,7 @@
 
 #define FRAME_TTY(f)                            \
   ((f)->output_method == output_termcap         \
-   ? (f)->device->display_info.tty              \
+   ? (f)->terminal->display_info.tty            \
    : (abort(), (struct tty_display_info *) 0))
 
 #define CURTTY() FRAME_TTY (SELECTED_FRAME())
--- a/src/termhooks.h	Thu Dec 29 04:57:14 2005 +0000
+++ b/src/termhooks.h	Thu Dec 29 18:20:26 2005 +0000
@@ -1,4 +1,4 @@
-/* Parameters and display hooks for output devices.
+/* Parameters and display hooks for terminal devices.
    Copyright (C) 1985, 1986, 1993, 1994, 2002, 2003, 2004,
                  2005 Free Software Foundation, Inc.
 
@@ -288,30 +288,30 @@
 #endif /* CONSP */
 
 
-/* Device-local parameters. */
-struct device
+/* Terminal-local parameters. */
+struct terminal
 {
-  /* Chain of all display devices. */
-  struct device *next_device;
+  /* Chain of all terminal devices. */
+  struct terminal *next_terminal;
 
-  /* Unique id for this display device. */
+  /* Unique id for this terminal device. */
   int id;
 
-  /* The number of frames that are on this device. */
+  /* The number of frames that are on this terminal. */
   int reference_count;
   
-  /* The type of the display device. */
+  /* The type of the terminal device. */
   enum output_method type;
 
-  /* The name of the display device.  Do not use this to identify the device. */
+  /* The name of the terminal device.  Do not use this to identify the device. */
   char *name;
 
 #ifdef MULTI_KBOARD
-  /* The device's keyboard object. */
+  /* The terminal's keyboard object. */
   struct kboard *kboard;
 #endif
 
-  /* Device-type dependent data shared amongst all frames on this display. */
+  /* Device-type dependent data shared amongst all frames on this terminal. */
   union display_info
   {
     struct tty_display_info *tty;     /* termchar.h */
@@ -381,8 +381,8 @@
   
   void (*ring_bell_hook) P_ ((struct frame *f));
   
-  void (*reset_terminal_modes_hook) P_ ((struct device *));
-  void (*set_terminal_modes_hook) P_ ((struct device *));
+  void (*reset_terminal_modes_hook) P_ ((struct terminal *));
+  void (*set_terminal_modes_hook) P_ ((struct terminal *));
 
   void (*update_begin_hook) P_ ((struct frame *));
   void (*update_end_hook) P_ ((struct frame *));
@@ -428,7 +428,7 @@
   /* If we're displaying frames using a window system that can stack
      frames on top of each other, this hook allows you to bring a frame
      to the front, or bury it behind all the other windows.  If this
-     hook is zero, that means the device we're displaying on doesn't
+     hook is zero, that means the terminal we're displaying on doesn't
      support overlapping frames, so there's no need to raise or lower
      anything.
      
@@ -512,10 +512,10 @@
 
   /* Called to read input events.
 
-     DEVICE indicates which display device to read from.  Input events
-     should be read into BUF, the size of which is given in SIZE.
-     EXPECTED is non-zero if the caller suspects that new input is
-     available.
+     TERMINAL indicates which terminal device to read from.  Input
+     events should be read into BUF, the size of which is given in
+     SIZE.  EXPECTED is non-zero if the caller suspects that new input
+     is available.
 
      A positive return value indicates that that many input events
      where read into BUF.
@@ -525,11 +525,11 @@
 
      XXX Please note that a non-zero value of EXPECTED only means that
      there is available input on at least one of the currently opened
-     display devices -- but not necessarily on this device.
+     terminal devices -- but not necessarily on this device.
      Therefore, in most cases EXPECTED should be simply ignored.
 
      XXX This documentation needs to be updated.  */
-  int (*read_socket_hook) P_ ((struct device *device,
+  int (*read_socket_hook) P_ ((struct terminal *terminal,
                                int expected,
                                struct input_event *hold_quit));
 
@@ -538,43 +538,43 @@
 
 
   /* Called to delete the device-specific portions of a frame that is
-     on this display device. */
+     on this terminal device. */
   void (*delete_frame_hook) P_ ((struct frame *));
 
-  /* Called after the last frame on this device is deleted, or when
+  /* Called after the last frame on this terminal is deleted, or when
      the display device was closed (hangup).
      
-     If this is NULL, then the generic delete_device is called
-     instead.  Otherwise the hook must call delete_device itself.
+     If this is NULL, then the generic delete_terminal is called
+     instead.  Otherwise the hook must call delete_terminal itself.
 
      The hook must check for and close any live frames that are still
-     on the device.  Fdelete_frame ensures that there are no live
-     frames on the device when it calls this hook, so infinite
+     on the terminal.  Fdelete_frame ensures that there are no live
+     frames on the terminal when it calls this hook, so infinite
      recursion is prevented.  */
-  void (*delete_device_hook) P_ ((struct device *));
+  void (*delete_terminal_hook) P_ ((struct terminal *));
 };
 
 
-/* Chain of all display devices currently in use. */
-extern struct device *device_list;
+/* Chain of all terminal devices currently in use. */
+extern struct terminal *terminal_list;
 
-#define FRAME_MUST_WRITE_SPACES(f) ((f)->device->must_write_spaces)
-#define FRAME_FAST_CLEAR_END_OF_LINE(f) ((f)->device->fast_clear_end_of_line)
-#define FRAME_LINE_INS_DEL_OK(f) ((f)->device->line_ins_del_ok)
-#define FRAME_CHAR_INS_DEL_OK(f) ((f)->device->char_ins_del_ok)
-#define FRAME_SCROLL_REGION_OK(f) ((f)->device->scroll_region_ok)
-#define FRAME_SCROLL_REGION_COST(f) ((f)->device->scroll_region_cost)
-#define FRAME_MEMORY_BELOW_FRAME(f) ((f)->device->memory_below_frame)
+#define FRAME_MUST_WRITE_SPACES(f) ((f)->terminal->must_write_spaces)
+#define FRAME_FAST_CLEAR_END_OF_LINE(f) ((f)->terminal->fast_clear_end_of_line)
+#define FRAME_LINE_INS_DEL_OK(f) ((f)->terminal->line_ins_del_ok)
+#define FRAME_CHAR_INS_DEL_OK(f) ((f)->terminal->char_ins_del_ok)
+#define FRAME_SCROLL_REGION_OK(f) ((f)->terminal->scroll_region_ok)
+#define FRAME_SCROLL_REGION_COST(f) ((f)->terminal->scroll_region_cost)
+#define FRAME_MEMORY_BELOW_FRAME(f) ((f)->terminal->memory_below_frame)
 
-#define FRAME_TERMINAL_CODING(f) ((f)->device->terminal_coding)
-#define FRAME_KEYBOARD_CODING(f) ((f)->device->keyboard_coding)
+#define FRAME_TERMINAL_CODING(f) ((f)->terminal->terminal_coding)
+#define FRAME_KEYBOARD_CODING(f) ((f)->terminal->keyboard_coding)
 
-#define DEVICE_TERMINAL_CODING(d) ((d)->terminal_coding)
-#define DEVICE_KEYBOARD_CODING(d) ((d)->keyboard_coding)
+#define TERMINAL_TERMINAL_CODING(d) ((d)->terminal_coding)
+#define TERMINAL_KEYBOARD_CODING(d) ((d)->keyboard_coding)
 
-#define FRAME_RIF(f) ((f)->device->rif)
+#define FRAME_RIF(f) ((f)->terminal->rif)
 
-#define FRAME_DEVICE(f) ((f)->device)
+#define FRAME_TERMINAL(f) ((f)->terminal)
 
 /* FRAME_WINDOW_P tests whether the frame is a window, and is
    defined to be the predicate for the window system being used.  */
@@ -592,16 +592,16 @@
 #define FRAME_WINDOW_P(f) (0)
 #endif
 
-/* Return true if the display device is not suspended. */
-#define DEVICE_ACTIVE_P(d) ((d)->type != output_termcap || (d)->display_info.tty->input)
+/* Return true if the terminal device is not suspended. */
+#define TERMINAL_ACTIVE_P(d) ((d)->type != output_termcap || (d)->display_info.tty->input)
 
-extern Lisp_Object get_terminal_param P_ ((struct device *, Lisp_Object));
-extern struct device *get_device P_ ((Lisp_Object display, int));
-extern struct device *create_device P_ ((void));
-extern void delete_device P_ ((struct device *));
+extern Lisp_Object get_terminal_param P_ ((struct terminal *, Lisp_Object));
+extern struct terminal *get_terminal P_ ((Lisp_Object terminal, int));
+extern struct terminal *create_terminal P_ ((void));
+extern void delete_terminal P_ ((struct terminal *));
 
-/* The initial display device, created by initial_term_init. */
-extern struct device *initial_device;
+/* The initial terminal device, created by initial_term_init. */
+extern struct terminal *initial_terminal;
 
 /* arch-tag: 33a00ecc-52b5-4186-a410-8801ac9f087d
    (do not change this comment) */
--- a/src/terminal.c	Thu Dec 29 04:57:14 2005 +0000
+++ b/src/terminal.c	Thu Dec 29 18:20:26 2005 +0000
@@ -28,19 +28,19 @@
 #include "coding.h"
 #include "keyboard.h"
 
-/* Chain of all displays currently in use. */
-struct device *device_list;
+/* Chain of all terminals currently in use. */
+struct terminal *terminal_list;
 
-/* The first unallocated display id. */
-static int next_device_id;
+/* The first unallocated terminal id. */
+static int next_terminal_id;
 
-/* The initial display device, created by initial_term_init. */
-struct device *initial_device;
+/* The initial terminal device, created by initial_term_init. */
+struct terminal *initial_terminal;
 
 /* Function to use to ring the bell.  */
 Lisp_Object Vring_bell_function;
 
-void delete_initial_device P_ ((struct device *));
+static void delete_initial_terminal P_ ((struct terminal *));
 
 
 
@@ -66,22 +66,22 @@
 
       Vring_bell_function = function;
     }
-  else if (FRAME_DEVICE (f)->ring_bell_hook)
-    (*FRAME_DEVICE (f)->ring_bell_hook) (f);
+  else if (FRAME_TERMINAL (f)->ring_bell_hook)
+    (*FRAME_TERMINAL (f)->ring_bell_hook) (f);
 }
 
 void
 update_begin (struct frame *f)
 {
-  if (FRAME_DEVICE (f)->update_begin_hook)
-    (*FRAME_DEVICE (f)->update_begin_hook) (f);
+  if (FRAME_TERMINAL (f)->update_begin_hook)
+    (*FRAME_TERMINAL (f)->update_begin_hook) (f);
 }
 
 void
 update_end (struct frame *f)
 {
-  if (FRAME_DEVICE (f)->update_end_hook)
-    (*FRAME_DEVICE (f)->update_end_hook) (f);
+  if (FRAME_TERMINAL (f)->update_end_hook)
+    (*FRAME_TERMINAL (f)->update_end_hook) (f);
 }
 
 /* Specify how many text lines, from the top of the window,
@@ -92,8 +92,8 @@
 void
 set_terminal_window (struct frame *f, int size)
 {
-  if (FRAME_DEVICE (f)->set_terminal_window_hook)
-    (*FRAME_DEVICE (f)->set_terminal_window_hook) (f, size);
+  if (FRAME_TERMINAL (f)->set_terminal_window_hook)
+    (*FRAME_TERMINAL (f)->set_terminal_window_hook) (f, size);
 }
 
 /* Move cursor to row/column position VPOS/HPOS.  HPOS/VPOS are
@@ -102,8 +102,8 @@
 void
 cursor_to (struct frame *f, int vpos, int hpos)
 {
-  if (FRAME_DEVICE (f)->cursor_to_hook)
-    (*FRAME_DEVICE (f)->cursor_to_hook) (f, vpos, hpos);
+  if (FRAME_TERMINAL (f)->cursor_to_hook)
+    (*FRAME_TERMINAL (f)->cursor_to_hook) (f, vpos, hpos);
 }
 
 /* Similar but don't take any account of the wasted characters.  */
@@ -111,8 +111,8 @@
 void
 raw_cursor_to (struct frame *f, int row, int col)
 {
-  if (FRAME_DEVICE (f)->raw_cursor_to_hook)
-    (*FRAME_DEVICE (f)->raw_cursor_to_hook) (f, row, col);  
+  if (FRAME_TERMINAL (f)->raw_cursor_to_hook)
+    (*FRAME_TERMINAL (f)->raw_cursor_to_hook) (f, row, col);  
 }
 
 /* Erase operations */
@@ -121,8 +121,8 @@
 void
 clear_to_end (struct frame *f)
 {
-  if (FRAME_DEVICE (f)->clear_to_end_hook)
-    (*FRAME_DEVICE (f)->clear_to_end_hook) (f);
+  if (FRAME_TERMINAL (f)->clear_to_end_hook)
+    (*FRAME_TERMINAL (f)->clear_to_end_hook) (f);
 }
 
 /* Clear entire frame */
@@ -130,8 +130,8 @@
 void
 clear_frame (struct frame *f)
 {
-  if (FRAME_DEVICE (f)->clear_frame_hook)
-    (*FRAME_DEVICE (f)->clear_frame_hook) (f);
+  if (FRAME_TERMINAL (f)->clear_frame_hook)
+    (*FRAME_TERMINAL (f)->clear_frame_hook) (f);
 }
 
 /* Clear from cursor to end of line.
@@ -142,8 +142,8 @@
 void
 clear_end_of_line (struct frame *f, int first_unused_hpos)
 {
-  if (FRAME_DEVICE (f)->clear_end_of_line_hook)
-    (*FRAME_DEVICE (f)->clear_end_of_line_hook) (f, first_unused_hpos);
+  if (FRAME_TERMINAL (f)->clear_end_of_line_hook)
+    (*FRAME_TERMINAL (f)->clear_end_of_line_hook) (f, first_unused_hpos);
 }
 
 /* Output LEN glyphs starting at STRING at the nominal cursor position.
@@ -152,8 +152,8 @@
 void
 write_glyphs (struct frame *f, struct glyph *string, int len)
 {
-  if (FRAME_DEVICE (f)->write_glyphs_hook)
-    (*FRAME_DEVICE (f)->write_glyphs_hook) (f, string, len);
+  if (FRAME_TERMINAL (f)->write_glyphs_hook)
+    (*FRAME_TERMINAL (f)->write_glyphs_hook) (f, string, len);
 }
 
 /* Insert LEN glyphs from START at the nominal cursor position.
@@ -166,8 +166,8 @@
   if (len <= 0)
     return;
 
-  if (FRAME_DEVICE (f)->insert_glyphs_hook)
-    (*FRAME_DEVICE (f)->insert_glyphs_hook) (f, start, len);
+  if (FRAME_TERMINAL (f)->insert_glyphs_hook)
+    (*FRAME_TERMINAL (f)->insert_glyphs_hook) (f, start, len);
 }
 
 /* Delete N glyphs at the nominal cursor position. */
@@ -175,8 +175,8 @@
 void
 delete_glyphs (struct frame *f, int n)
 {
-  if (FRAME_DEVICE (f)->delete_glyphs_hook)
-    (*FRAME_DEVICE (f)->delete_glyphs_hook) (f, n);
+  if (FRAME_TERMINAL (f)->delete_glyphs_hook)
+    (*FRAME_TERMINAL (f)->delete_glyphs_hook) (f, n);
 }
 
 /* Insert N lines at vpos VPOS.  If N is negative, delete -N lines.  */
@@ -184,185 +184,209 @@
 void
 ins_del_lines (struct frame *f, int vpos, int n)
 {
-  if (FRAME_DEVICE (f)->ins_del_lines_hook)
-    (*FRAME_DEVICE (f)->ins_del_lines_hook) (f, vpos, n);
+  if (FRAME_TERMINAL (f)->ins_del_lines_hook)
+    (*FRAME_TERMINAL (f)->ins_del_lines_hook) (f, vpos, n);
 }
 
 
 
 
-/* Return the display object specified by DEVICE.  DEVICE may be a
-   display id, a frame, or nil for the display device of the current
+/* Return the terminal object specified by TERMINAL.  TERMINAL may be a
+   terminal id, a frame, or nil for the terminal device of the current
    frame.  If THROW is zero, return NULL for failure, otherwise throw
    an error.  */
 
-struct device *
-get_device (Lisp_Object device, int throw)
+struct terminal *
+get_terminal (Lisp_Object terminal, int throw)
 {
-  struct device *result = NULL;
+  struct terminal *result = NULL;
 
-  if (NILP (device))
-    device = selected_frame;
+  if (NILP (terminal))
+    terminal = selected_frame;
 
-  if (INTEGERP (device))
+  if (INTEGERP (terminal))
     {
-      struct device *d;
+      struct terminal *t;
 
-      for (d = device_list; d; d = d->next_device)
+      for (t = terminal_list; t; t = t->next_terminal)
         {
-          if (d->id == XINT (device))
+          if (t->id == XINT (terminal))
             {
-              result = d;
+              result = t;
               break;
             }
         }
     }
-  else if (FRAMEP (device))
+  else if (FRAMEP (terminal))
     {
-      result = FRAME_DEVICE (XFRAME (device));
+      result = FRAME_TERMINAL (XFRAME (terminal));
     }
 
   if (result == NULL && throw)
-    wrong_type_argument (Qdisplay_live_p, device);
+    wrong_type_argument (Qterminal_live_p, terminal);
 
   return result;
 }
 
 
 
-/* Create a new device object and add it to the device list. */
+/* Create a new terminal object and add it to the terminal list. */
 
-struct device *
-create_device (void)
+struct terminal *
+create_terminal (void)
 {
-  struct device *device = (struct device *) xmalloc (sizeof (struct device));
+  struct terminal *terminal = (struct terminal *) xmalloc (sizeof (struct terminal));
   
-  bzero (device, sizeof (struct device));
-  device->next_device = device_list;
-  device_list = device;
+  bzero (terminal, sizeof (struct terminal));
+  terminal->next_terminal = terminal_list;
+  terminal_list = terminal;
 
-  device->id = next_device_id++;
+  terminal->id = next_terminal_id++;
 
-  device->keyboard_coding =
+  terminal->keyboard_coding =
     (struct coding_system *) xmalloc (sizeof (struct coding_system));
-  device->terminal_coding =
+  terminal->terminal_coding =
     (struct coding_system *) xmalloc (sizeof (struct coding_system));
 
-  setup_coding_system (Qnil, device->keyboard_coding);
-  setup_coding_system (Qnil, device->terminal_coding);
+  setup_coding_system (Qnil, terminal->keyboard_coding);
+  setup_coding_system (Qnil, terminal->terminal_coding);
 
-  device->param_alist = Qnil;
-  return device;
+  terminal->param_alist = Qnil;
+  return terminal;
 }
 
 /* Mark the Lisp pointers in the terminal objects.
    Called by the Fgarbage_collector.  */
 
 void
-mark_devices (void)
+mark_terminals (void)
 {
-  struct device *d;
-  for (d = device_list; d; d = d->next_device)
+  struct terminal *t;
+  for (t = terminal_list; t; t = t->next_terminal)
     {
-      mark_object (d->param_alist);
+      mark_object (t->param_alist);
     }
 }
 
 
-/* Remove a device from the device list and free its memory. */
+/* Remove a terminal from the terminal list and free its memory. */
 
 void
-delete_device (struct device *device)
+delete_terminal (struct terminal *terminal)
 {
-  struct device **dp;
+  struct terminal **tp;
   Lisp_Object tail, frame;
   
   /* Check for and close live frames that are still on this
-     device. */
+     terminal. */
   FOR_EACH_FRAME (tail, frame)
     {
       struct frame *f = XFRAME (frame);
-      if (FRAME_LIVE_P (f) && f->device == device)
+      if (FRAME_LIVE_P (f) && f->terminal == terminal)
         {
           Fdelete_frame (frame, Qt);
         }
     }
 
-  for (dp = &device_list; *dp != device; dp = &(*dp)->next_device)
-    if (! *dp)
+  for (tp = &terminal_list; *tp != terminal; tp = &(*tp)->next_terminal)
+    if (! *tp)
       abort ();
-  *dp = device->next_device;
+  *tp = terminal->next_terminal;
 
-  if (device->keyboard_coding)
-    xfree (device->keyboard_coding);
-  if (device->terminal_coding)
-    xfree (device->terminal_coding);
-  if (device->name)
-    xfree (device->name);
+  if (terminal->keyboard_coding)
+    xfree (terminal->keyboard_coding);
+  if (terminal->terminal_coding)
+    xfree (terminal->terminal_coding);
+  if (terminal->name)
+    xfree (terminal->name);
   
 #ifdef MULTI_KBOARD
-  if (device->kboard && --device->kboard->reference_count == 0)
-    delete_kboard (device->kboard);
+  if (terminal->kboard && --terminal->kboard->reference_count == 0)
+    delete_kboard (terminal->kboard);
 #endif
   
-  bzero (device, sizeof (struct device));
-  xfree (device);
+  bzero (terminal, sizeof (struct terminal));
+  xfree (terminal);
 }
 
-DEFUN ("delete-display", Fdelete_display, Sdelete_display, 0, 2, 0,
-       doc: /* Delete DEVICE by deleting all frames on it and closing the device.
-DEVICE may be a display device id, a frame, or nil (meaning the
-selected frame's display device).
+DEFUN ("delete-terminal", Fdelete_terminal, Sdelete_terminal, 0, 2, 0,
+       doc: /* Delete TERMINAL by deleting all frames on it and closing the terminal.
+TERMINAL may be a terminal id, a frame, or nil (meaning the selected
+frame's terminal).
 
 Normally, you may not delete a display if all other displays are suspended,
 but if the second argument FORCE is non-nil, you may do so. */)
-  (device, force)
-     Lisp_Object device, force;
+  (terminal, force)
+     Lisp_Object terminal, force;
 {
-  struct device *d, *p;
+  struct terminal *t, *p;
 
-  d = get_device (device, 0);
+  t = get_terminal (terminal, 0);
 
-  if (!d)
+  if (!t)
     return Qnil;
 
-  p = device_list;
-  while (p && (p == d || !DEVICE_ACTIVE_P (p)))
-    p = p->next_device;
+  p = terminal_list;
+  while (p && (p == t || !TERMINAL_ACTIVE_P (p)))
+    p = p->next_terminal;
   
   if (NILP (force) && !p)
-    error ("Attempt to delete the sole active display device");
+    error ("Attempt to delete the sole active display terminal");
 
-  if (d->delete_device_hook)
-    (*d->delete_device_hook) (d);
+  if (t->delete_terminal_hook)
+    (*t->delete_terminal_hook) (t);
   else
-    delete_device (d);
+    delete_terminal (t);
 
   return Qnil;
 }
 
-DEFUN ("display-live-p", Fdisplay_live_p, Sdisplay_live_p, 1, 1, 0,
-       doc: /* Return non-nil if OBJECT is a device which has not been deleted.
-Value is nil if OBJECT is not a live display device.
-If object is a live display device, the return value indicates what
-sort of output device it uses.  See the documentation of `framep' for
+
+DEFUN ("frame-terminal", Fframe_terminal, Sframe_terminal, 0, 1, 0,
+       doc: /* Return the terminal that FRAME is displayed on.
+If FRAME is nil, the selected frame is used.
+
+The terminal device is represented by its integer identifier.  */)
+  (frame)
+     Lisp_Object frame;
+{
+  struct terminal *t;
+
+  if (NILP (frame))
+    frame = selected_frame;
+
+  CHECK_LIVE_FRAME (frame);
+
+  t = get_terminal (frame, 0);
+
+  if (!t)
+    return Qnil;
+  else
+    return make_number (t->id);
+}
+
+DEFUN ("terminal-live-p", Fterminal_live_p, Sterminal_live_p, 1, 1, 0,
+       doc: /* Return non-nil if OBJECT is a terminal which has not been deleted.
+Value is nil if OBJECT is not a live display terminal.
+If object is a live display terminal, the return value indicates what
+sort of output terminal it uses.  See the documentation of `framep' for
 possible return values.
 
-Display devices are represented by their integer identifiers. */)
+Display terminals are represented by their integer identifiers. */)
      (object)
      Lisp_Object object;
 {
-  struct device *d;
+  struct terminal *t;
   
   if (!INTEGERP (object))
     return Qnil;
 
-  d = get_device (object, 0);
+  t = get_terminal (object, 0);
 
-  if (!d)
+  if (!t)
     return Qnil;
 
-  switch (d->type)
+  switch (t->type)
     {
     case output_initial: /* The initial frame is like a termcap frame. */
     case output_termcap:
@@ -380,64 +404,64 @@
     }
 }
 
-DEFUN ("display-list", Fdisplay_list, Sdisplay_list, 0, 0, 0,
-       doc: /* Return a list of all display devices.
-Display devices are represented by their integer identifiers. */)
+DEFUN ("terminal-list", Fterminal_list, Sterminal_list, 0, 0, 0,
+       doc: /* Return a list of all terminal devices.
+Terminal devices are represented by their integer identifiers. */)
   ()
 {
-  Lisp_Object devices = Qnil;
-  struct device *d;
+  Lisp_Object terminals = Qnil;
+  struct terminal *t;
 
-  for (d = device_list; d; d = d->next_device)
-    devices = Fcons (make_number (d->id), devices);
+  for (t = terminal_list; t; t = t->next_terminal)
+    terminals = Fcons (make_number (t->id), terminals);
 
-  return devices;
+  return terminals;
 }
 
-DEFUN ("display-name", Fdisplay_name, Sdisplay_name, 0, 1, 0,
-       doc: /* Return the name of the display device DEVICE.
+DEFUN ("terminal-name", Fterminal_name, Sterminal_name, 0, 1, 0,
+       doc: /* Return the name of the terminal device TERMINAL.
 It is not guaranteed that the returned value is unique among opened devices.
 
-DEVICE may be a display device id, a frame, or nil (meaning the
-selected frame's display device). */)
-  (device)
-     Lisp_Object device;
+TERMINAL may be a terminal id, a frame, or nil (meaning the
+selected frame's terminal). */)
+  (terminal)
+     Lisp_Object terminal;
 {
-  struct device *d = get_device (device, 1);
+  struct terminal *t = get_terminal (terminal, 1);
 
-  if (d->name)
-    return build_string (d->name);
+  if (t->name)
+    return build_string (t->name);
   else
     return Qnil;
 }
 
 
 
-/* Return the value of terminal parameter PARAM in device D.  */
+/* Return the value of terminal parameter PARAM in terminal T.  */
 Lisp_Object
-get_terminal_param (d, param)
-     struct device *d;
+get_terminal_param (t, param)
+     struct terminal *t;
      Lisp_Object param;
 {
-  Lisp_Object tem = Fassq (param, d->param_alist);
+  Lisp_Object tem = Fassq (param, t->param_alist);
   if (EQ (tem, Qnil))
     return tem;
   return Fcdr (tem);
 }
 
-/* Set the value of terminal parameter PARAMETER in device D to VALUE.
+/* Set the value of terminal parameter PARAMETER in terminal D to VALUE.
    Return the previous value.  */
 
 Lisp_Object
-store_terminal_param (d, parameter, value)
-     struct device *d;
+store_terminal_param (t, parameter, value)
+     struct terminal *t;
      Lisp_Object parameter;
      Lisp_Object value;
 {
-  Lisp_Object old_alist_elt = Fassq (parameter, d->param_alist);
+  Lisp_Object old_alist_elt = Fassq (parameter, t->param_alist);
   if (EQ (old_alist_elt, Qnil))
     {
-      d->param_alist = Fcons (Fcons (parameter, value), d->param_alist);
+      t->param_alist = Fcons (Fcons (parameter, value), t->param_alist);
       return Qnil;
     }
   else
@@ -454,27 +478,27 @@
 The value is a list of elements of the form (PARM . VALUE), where PARM
 is a symbol.
 
-TERMINAL can be a terminal if, a frame or nil (meaning the selected
+TERMINAL can be a terminal id, a frame or nil (meaning the selected
 frame's terminal).  */)
      (terminal)
      Lisp_Object terminal;
 {
-  struct device *d = get_device (terminal, 1);
-  return Fcopy_alist (d->param_alist);
+  struct terminal *t = get_terminal (terminal, 1);
+  return Fcopy_alist (t->param_alist);
 }
 
 DEFUN ("terminal-parameter", Fterminal_parameter, Sterminal_parameter, 2, 2, 0,
        doc: /* Return TERMINAL's value for parameter PARAMETER.
-TERMINAL can be a terminal if, a frame or nil (meaning the selected
+TERMINAL can be a terminal id, a frame or nil (meaning the selected
 frame's terminal).  */)
      (terminal, parameter)
      Lisp_Object terminal;
      Lisp_Object parameter;
 {
   Lisp_Object value;
-  struct device *d = get_device (terminal, 1);
+  struct terminal *t = get_terminal (terminal, 1);
   CHECK_SYMBOL (parameter);
-  value = Fcdr (Fassq (parameter, d->param_alist));
+  value = Fcdr (Fassq (parameter, t->param_alist));
   return value;
 }
 
@@ -484,14 +508,14 @@
 ALIST is an alist of parameters to change and their new values.
 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
 
-TERMINAL can be a terminal if, a frame or nil (meaning the selected
+TERMINAL can be a terminal id, a frame or nil (meaning the selected
 frame's terminal).  */)
      (terminal, alist)
      Lisp_Object terminal;
      Lisp_Object alist;
 {
   Lisp_Object tail, prop, val;
-  struct device *d = get_device (terminal, 1);
+  struct terminal *t = get_terminal (terminal, 1);
   int length = XINT (Fsafe_length (alist));
   int i;
   Lisp_Object *parms = (Lisp_Object *) alloca (length * sizeof (Lisp_Object));
@@ -515,7 +539,7 @@
     {
       prop = parms[i];
       val = values[i];
-      store_terminal_param (d, prop, val);
+      store_terminal_param (t, prop, val);
     }
   return Qnil;
 }
@@ -525,50 +549,50 @@
        doc: /* Set TERMINAL's value for parameter PARAMETER to VALUE.
 Return the previous value of PARAMETER.
 
-TERMINAL can be a terminal if, a frame or nil (meaning the selected
+TERMINAL can be a terminal id, a frame or nil (meaning the selected
 frame's terminal).  */)
      (terminal, parameter, value)
      Lisp_Object terminal;
      Lisp_Object parameter;
      Lisp_Object value;
 {
-  struct device *d = get_device (terminal, 1);
-  return store_terminal_param (d, parameter, value);
+  struct terminal *t = get_terminal (terminal, 1);
+  return store_terminal_param (t, parameter, value);
 }
 
 
 
-/* Create the bootstrap display device for the initial frame.
-   Returns a device of type output_initial.  */
+/* Create the bootstrap display terminal for the initial frame.
+   Returns a terminal of type output_initial.  */
 
-struct device *
-init_initial_device (void)
+struct terminal *
+init_initial_terminal (void)
 {
-  if (initialized || device_list || tty_list)
+  if (initialized || terminal_list || tty_list)
     abort ();
 
-  initial_device = create_device ();
-  initial_device->type = output_initial;
-  initial_device->name = xstrdup ("initial_device");
-  initial_device->kboard = initial_kboard;
+  initial_terminal = create_terminal ();
+  initial_terminal->type = output_initial;
+  initial_terminal->name = xstrdup ("initial_terminal");
+  initial_terminal->kboard = initial_kboard;
 
-  initial_device->delete_device_hook = &delete_initial_device;
+  initial_terminal->delete_terminal_hook = &delete_initial_terminal;
   /* All other hooks are NULL. */
 
-  return initial_device;
+  return initial_terminal;
 }
 
-/* Deletes the bootstrap display device.
-   Called through delete_device_hook. */
+/* Deletes the bootstrap terminal device.
+   Called through delete_terminal_hook. */
 
-void
-delete_initial_device (struct device *device)
+static void
+delete_initial_terminal (struct terminal *terminal)
 {
-  if (device != initial_device)
+  if (terminal != initial_terminal)
     abort ();
 
-  delete_device (device);
-  initial_device = NULL;
+  delete_terminal (terminal);
+  initial_terminal = NULL;
 }
 
 void
@@ -580,10 +604,11 @@
 The function should accept no arguments.  */);
   Vring_bell_function = Qnil;
 
-  defsubr (&Sdelete_display);
-  defsubr (&Sdisplay_live_p);
-  defsubr (&Sdisplay_list);
-  defsubr (&Sdisplay_name);
+  defsubr (&Sdelete_terminal);
+  defsubr (&Sframe_terminal);
+  defsubr (&Sterminal_live_p);
+  defsubr (&Sterminal_list);
+  defsubr (&Sterminal_name);
   defsubr (&Sterminal_parameters);
   defsubr (&Sterminal_parameter);
   defsubr (&Smodify_terminal_parameters);
--- a/src/xdisp.c	Thu Dec 29 04:57:14 2005 +0000
+++ b/src/xdisp.c	Thu Dec 29 18:20:26 2005 +0000
@@ -7304,8 +7304,8 @@
       do_pending_window_change (0);
       echo_area_display (1);
       do_pending_window_change (0);
-      if (FRAME_DEVICE (f)->frame_up_to_date_hook != 0 && ! gc_in_progress)
-	(*FRAME_DEVICE (f)->frame_up_to_date_hook) (f);
+      if (FRAME_TERMINAL (f)->frame_up_to_date_hook != 0 && ! gc_in_progress)
+	(*FRAME_TERMINAL (f)->frame_up_to_date_hook) (f);
     }
 }
 
@@ -7408,8 +7408,8 @@
       do_pending_window_change (0);
       echo_area_display (1);
       do_pending_window_change (0);
-      if (FRAME_DEVICE (f)->frame_up_to_date_hook != 0 && ! gc_in_progress)
-	(*FRAME_DEVICE (f)->frame_up_to_date_hook) (f);
+      if (FRAME_TERMINAL (f)->frame_up_to_date_hook != 0 && ! gc_in_progress)
+	(*FRAME_TERMINAL (f)->frame_up_to_date_hook) (f);
     }
 }
 
@@ -10940,16 +10940,16 @@
 
 	      /* Mark all the scroll bars to be removed; we'll redeem
 		 the ones we want when we redisplay their windows.  */
-	      if (FRAME_DEVICE (f)->condemn_scroll_bars_hook)
-		FRAME_DEVICE (f)->condemn_scroll_bars_hook (f);
+	      if (FRAME_TERMINAL (f)->condemn_scroll_bars_hook)
+		FRAME_TERMINAL (f)->condemn_scroll_bars_hook (f);
 
 	      if (FRAME_VISIBLE_P (f) && !FRAME_OBSCURED_P (f))
 		redisplay_windows (FRAME_ROOT_WINDOW (f));
 
 	      /* Any scroll bars which redisplay_windows should have
 		 nuked should now go away.  */
-	      if (FRAME_DEVICE (f)->judge_scroll_bars_hook)
-		FRAME_DEVICE (f)->judge_scroll_bars_hook (f);
+	      if (FRAME_TERMINAL (f)->judge_scroll_bars_hook)
+		FRAME_TERMINAL (f)->judge_scroll_bars_hook (f);
 
 	      /* If fonts changed, display again.  */
 	      /* ??? rms: I suspect it is a mistake to jump all the way
@@ -10999,8 +10999,8 @@
               if (f->updated_p)
                 {
                   mark_window_display_accurate (f->root_window, 1);
-                  if (FRAME_DEVICE (f)->frame_up_to_date_hook)
-                    FRAME_DEVICE (f)->frame_up_to_date_hook (f);
+                  if (FRAME_TERMINAL (f)->frame_up_to_date_hook)
+                    FRAME_TERMINAL (f)->frame_up_to_date_hook (f);
                 }
 	    }
 	}
@@ -11086,8 +11086,8 @@
 	  /* Say overlay arrows are up to date.  */
 	  update_overlay_arrows (1);
 
-	  if (FRAME_DEVICE (sf)->frame_up_to_date_hook != 0)
-	    FRAME_DEVICE (sf)->frame_up_to_date_hook (sf);
+	  if (FRAME_TERMINAL (sf)->frame_up_to_date_hook != 0)
+	    FRAME_TERMINAL (sf)->frame_up_to_date_hook (sf);
 	}
 
       update_mode_lines = 0;
@@ -12343,8 +12343,8 @@
     start = end = whole = 0;
 
   /* Indicate what this scroll bar ought to be displaying now.  */
-  if (FRAME_DEVICE (XFRAME (w->frame))->set_vertical_scroll_bar_hook)
-    (*FRAME_DEVICE (XFRAME (w->frame))->set_vertical_scroll_bar_hook)
+  if (FRAME_TERMINAL (XFRAME (w->frame))->set_vertical_scroll_bar_hook)
+    (*FRAME_TERMINAL (XFRAME (w->frame))->set_vertical_scroll_bar_hook)
       (w, end - start, whole, start);
 }
 
@@ -13083,8 +13083,8 @@
 
       /* Note that we actually used the scroll bar attached to this
 	 window, so it shouldn't be deleted at the end of redisplay.  */
-      if (FRAME_DEVICE (f)->redeem_scroll_bar_hook)
-        (*FRAME_DEVICE (f)->redeem_scroll_bar_hook) (w);
+      if (FRAME_TERMINAL (f)->redeem_scroll_bar_hook)
+        (*FRAME_TERMINAL (f)->redeem_scroll_bar_hook) (w);
     }
 
   /* Restore current_buffer and value of point in it.  */
--- a/src/xfns.c	Thu Dec 29 04:57:14 2005 +0000
+++ b/src/xfns.c	Thu Dec 29 18:20:26 2005 +0000
@@ -244,7 +244,7 @@
 }
 
 /* Let the user specify an X display with a Lisp object.
-   OBJECT may be nil, a frame or a device id.
+   OBJECT may be nil, a frame or a terminal id.
    nil stands for the selected frame--or, if that is not an X frame,
    the first X display on the list.  */
 
@@ -267,12 +267,12 @@
     }
   else if (INTEGERP (object))
     {
-      struct device *d = get_device (XINT (object), 1);
-
-      if (d->type != output_x_window)
-        error ("Display %d is not an X display", XINT (object));
-
-      dpyinfo = d->display_info.x;
+      struct terminal *t = get_terminal (XINT (object), 1);
+
+      if (t->type != output_x_window)
+        error ("Terminal %d is not an X display", XINT (object));
+
+      dpyinfo = t->display_info.x;
     }
   else if (STRINGP (object))
     dpyinfo = x_display_info_for_name (object);
@@ -1463,10 +1463,10 @@
   if (FRAME_X_WINDOW (f) && FRAME_VISIBLE_P (f))
     {
       /* Remove all scroll bars because they have wrong colors.  */
-      if (FRAME_DEVICE (f)->condemn_scroll_bars_hook)
-	(*FRAME_DEVICE (f)->condemn_scroll_bars_hook) (f);
-      if (FRAME_DEVICE (f)->judge_scroll_bars_hook)
-	(*FRAME_DEVICE (f)->judge_scroll_bars_hook) (f);
+      if (FRAME_TERMINAL (f)->condemn_scroll_bars_hook)
+	(*FRAME_TERMINAL (f)->condemn_scroll_bars_hook) (f);
+      if (FRAME_TERMINAL (f)->judge_scroll_bars_hook)
+	(*FRAME_TERMINAL (f)->judge_scroll_bars_hook) (f);
 
       update_face_from_frame_parameter (f, Qscroll_bar_foreground, value);
       redraw_frame (f);
@@ -1512,10 +1512,10 @@
   if (FRAME_X_WINDOW (f) && FRAME_VISIBLE_P (f))
     {
       /* Remove all scroll bars because they have wrong colors.  */
-      if (FRAME_DEVICE (f)->condemn_scroll_bars_hook)
-	(*FRAME_DEVICE (f)->condemn_scroll_bars_hook) (f);
-      if (FRAME_DEVICE (f)->judge_scroll_bars_hook)
-	(*FRAME_DEVICE (f)->judge_scroll_bars_hook) (f);
+      if (FRAME_TERMINAL (f)->condemn_scroll_bars_hook)
+	(*FRAME_TERMINAL (f)->condemn_scroll_bars_hook) (f);
+      if (FRAME_TERMINAL (f)->judge_scroll_bars_hook)
+	(*FRAME_TERMINAL (f)->judge_scroll_bars_hook) (f);
 
       update_face_from_frame_parameter (f, Qscroll_bar_background, value);
       redraw_frame (f);
@@ -3025,14 +3025,14 @@
      until we know if this frame has a specified name.  */
   Vx_resource_name = Vinvocation_name;
 
-  display = x_get_arg (dpyinfo, parms, Qdevice, 0, 0, RES_TYPE_NUMBER);
+  display = x_get_arg (dpyinfo, parms, Qterminal, 0, 0, RES_TYPE_NUMBER);
   if (EQ (display, Qunbound))
     display = x_get_arg (dpyinfo, parms, Qdisplay, 0, 0, RES_TYPE_STRING);
   if (EQ (display, Qunbound))
     display = Qnil;
   dpyinfo = check_x_display_info (display);
 #ifdef MULTI_KBOARD
-  kb = dpyinfo->device->kboard;
+  kb = dpyinfo->terminal->kboard;
 #else
   kb = &the_only_kboard;
 #endif
@@ -3077,8 +3077,8 @@
   /* Note that X Windows does support scroll bars.  */
   FRAME_CAN_HAVE_SCROLL_BARS (f) = 1;
 
-  f->device = dpyinfo->device;
-  f->device->reference_count++;
+  f->terminal = dpyinfo->terminal;
+  f->terminal->reference_count++;
 
   f->output_method = output_x_window;
   f->output_data.x = (struct x_output *) xmalloc (sizeof (struct x_output));
@@ -3395,7 +3395,7 @@
     }
 
   /* Initialize `default-minibuffer-frame' in case this is the first
-     frame on this display device.  */
+     frame on this terminal.  */
   if (FRAME_HAS_MINIBUF_P (f)
       && (!FRAMEP (kb->Vdefault_minibuffer_frame)
           || !FRAME_LIVE_P (XFRAME (kb->Vdefault_minibuffer_frame))))
@@ -3500,10 +3500,10 @@
 
 DEFUN ("xw-display-color-p", Fxw_display_color_p, Sxw_display_color_p, 0, 1, 0,
        doc: /* Internal function called by `display-color-p', which see.  */)
-     (device)
-     Lisp_Object device;
+     (terminal)
+     Lisp_Object terminal;
 {
-  struct x_display_info *dpyinfo = check_x_display_info (device);
+  struct x_display_info *dpyinfo = check_x_display_info (terminal);
 
   if (dpyinfo->n_planes <= 2)
     return Qnil;
@@ -3525,13 +3525,13 @@
        0, 1, 0,
        doc: /* Return t if the X display supports shades of gray.
 Note that color displays do support shades of gray.
-The optional argument DEVICE specifies which display to ask about.
-DEVICE should be a device id, a frame or a display name (a string).
-If omitted or nil, that stands for the selected frame's display device.  */)
-     (device)
-     Lisp_Object device;
+The optional argument TERMINAL specifies which display to ask about.
+TERMINAL should be a terminal id, a frame or a display name (a string).
+If omitted or nil, that stands for the selected frame's display.  */)
+     (terminal)
+     Lisp_Object terminal;
 {
-  struct x_display_info *dpyinfo = check_x_display_info (device);
+  struct x_display_info *dpyinfo = check_x_display_info (terminal);
 
   if (dpyinfo->n_planes <= 1)
     return Qnil;
@@ -3553,56 +3553,56 @@
 
 DEFUN ("x-display-pixel-width", Fx_display_pixel_width, Sx_display_pixel_width,
        0, 1, 0,
-       doc: /* Returns the width in pixels of the X display DEVICE.
-The optional argument DEVICE specifies which display to ask about.
-DEVICE should be a device id, a frame or a display name (a string).
+       doc: /* Returns the width in pixels of the X display TERMINAL.
+The optional argument TERMINAL specifies which display to ask about.
+TERMINAL should be a terminal id, a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-     (device)
-     Lisp_Object device;
+     (terminal)
+     Lisp_Object terminal;
 {
-  struct x_display_info *dpyinfo = check_x_display_info (device);
+  struct x_display_info *dpyinfo = check_x_display_info (terminal);
 
   return make_number (dpyinfo->width);
 }
 
 DEFUN ("x-display-pixel-height", Fx_display_pixel_height,
        Sx_display_pixel_height, 0, 1, 0,
-       doc: /* Returns the height in pixels of the X display DEVICE.
-The optional argument DEVICE specifies which display to ask about.
-DEVICE should be a device id, a frame or a display name (a string).
+       doc: /* Returns the height in pixels of the X display TERMINAL.
+The optional argument TERMINAL specifies which display to ask about.
+TERMINAL should be a terminal id, a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-     (device)
-     Lisp_Object device;
+     (terminal)
+     Lisp_Object terminal;
 {
-  struct x_display_info *dpyinfo = check_x_display_info (device);
+  struct x_display_info *dpyinfo = check_x_display_info (terminal);
 
   return make_number (dpyinfo->height);
 }
 
 DEFUN ("x-display-planes", Fx_display_planes, Sx_display_planes,
        0, 1, 0,
-       doc: /* Returns the number of bitplanes of the X display DEVICE.
-The optional argument DEVICE specifies which display to ask about.
-DEVICE should be a device id, a frame or a display name (a string).
+       doc: /* Returns the number of bitplanes of the X display TERMINAL.
+The optional argument TERMINAL specifies which display to ask about.
+TERMINAL should be a terminal id, a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-     (device)
-     Lisp_Object device;
+     (terminal)
+     Lisp_Object terminal;
 {
-  struct x_display_info *dpyinfo = check_x_display_info (device);
+  struct x_display_info *dpyinfo = check_x_display_info (terminal);
 
   return make_number (dpyinfo->n_planes);
 }
 
 DEFUN ("x-display-color-cells", Fx_display_color_cells, Sx_display_color_cells,
        0, 1, 0,
-       doc: /* Returns the number of color cells of the X display DEVICE.
-The optional argument DEVICE specifies which display to ask about.
-DEVICE should be a device id, a frame or a display name (a string).
+       doc: /* Returns the number of color cells of the X display TERMINAL.
+The optional argument TERMINAL specifies which display to ask about.
+TERMINAL should be a terminal id, a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-     (device)
-     Lisp_Object device;
+     (terminal)
+     Lisp_Object terminal;
 {
-  struct x_display_info *dpyinfo = check_x_display_info (device);
+  struct x_display_info *dpyinfo = check_x_display_info (terminal);
 
   int nr_planes = DisplayPlanes (dpyinfo->display,
                                  XScreenNumberOfScreen (dpyinfo->screen));
@@ -3620,29 +3620,29 @@
 DEFUN ("x-server-max-request-size", Fx_server_max_request_size,
        Sx_server_max_request_size,
        0, 1, 0,
-       doc: /* Returns the maximum request size of the X server of display DEVICE.
-The optional argument DEVICE specifies which display to ask about.
-DEVICE should be a device id, a frame or a display name (a string).
+       doc: /* Returns the maximum request size of the X server of display TERMINAL.
+The optional argument TERMINAL specifies which display to ask about.
+TERMINAL should be a terminal id, a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-     (device)
-     Lisp_Object device;
+     (terminal)
+     Lisp_Object terminal;
 {
-  struct x_display_info *dpyinfo = check_x_display_info (device);
+  struct x_display_info *dpyinfo = check_x_display_info (terminal);
 
   return make_number (MAXREQUEST (dpyinfo->display));
 }
 
 DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0,
-       doc: /* Returns the "vendor ID" string of the X server of display DEVICE.
+       doc: /* Returns the "vendor ID" string of the X server of display TERMINAL.
 \(Labelling every distributor as a "vendor" embodies the false assumption
 that operating systems cannot be developed and distributed noncommercially.)
-The optional argument DEVICE specifies which display to ask about.
-DEVICE should be a device id, a frame or a display name (a string).
+The optional argument TERMINAL specifies which display to ask about.
+TERMINAL should be a terminal id, a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-     (device)
-     Lisp_Object device;
+     (terminal)
+     Lisp_Object terminal;
 {
-  struct x_display_info *dpyinfo = check_x_display_info (device);
+  struct x_display_info *dpyinfo = check_x_display_info (terminal);
   char *vendor = ServerVendor (dpyinfo->display);
 
   if (! vendor) vendor = "";
@@ -3650,18 +3650,18 @@
 }
 
 DEFUN ("x-server-version", Fx_server_version, Sx_server_version, 0, 1, 0,
-       doc: /* Returns the version numbers of the X server of display DEVICE.
+       doc: /* Returns the version numbers of the X server of display TERMINAL.
 The value is a list of three integers: the major and minor
 version numbers of the X Protocol in use, and the distributor-specific release
 number.  See also the function `x-server-vendor'.
 
-The optional argument DEVICE specifies which display to ask about.
-DEVICE should be a device id, a frame or a display name (a string).
+The optional argument TERMINAL specifies which display to ask about.
+TERMINAL should be a terminal id, a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-     (device)
-     Lisp_Object device;
+     (terminal)
+     Lisp_Object terminal;
 {
-  struct x_display_info *dpyinfo = check_x_display_info (device);
+  struct x_display_info *dpyinfo = check_x_display_info (terminal);
   Display *dpy = dpyinfo->display;
 
   return Fcons (make_number (ProtocolVersion (dpy)),
@@ -3670,55 +3670,55 @@
 }
 
 DEFUN ("x-display-screens", Fx_display_screens, Sx_display_screens, 0, 1, 0,
-       doc: /* Return the number of screens on the X server of display DEVICE.
-The optional argument DEVICE specifies which display to ask about.
-DEVICE should be a device id, a frame or a display name (a string).
+       doc: /* Return the number of screens on the X server of display TERMINAL.
+The optional argument TERMINAL specifies which display to ask about.
+TERMINAL should be a terminal id, a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-     (device)
-     Lisp_Object device;
+     (terminal)
+     Lisp_Object terminal;
 {
-  struct x_display_info *dpyinfo = check_x_display_info (device);
+  struct x_display_info *dpyinfo = check_x_display_info (terminal);
 
   return make_number (ScreenCount (dpyinfo->display));
 }
 
 DEFUN ("x-display-mm-height", Fx_display_mm_height, Sx_display_mm_height, 0, 1, 0,
-       doc: /* Return the height in millimeters of the X display DEVICE.
-The optional argument DEVICE specifies which display to ask about.
-DEVICE should be a device id, a frame or a display name (a string).
+       doc: /* Return the height in millimeters of the X display TERMINAL.
+The optional argument TERMINAL specifies which display to ask about.
+TERMINAL should be a terminal id, a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-     (device)
-     Lisp_Object device;
+     (terminal)
+     Lisp_Object terminal;
 {
-  struct x_display_info *dpyinfo = check_x_display_info (device);
+  struct x_display_info *dpyinfo = check_x_display_info (terminal);
 
   return make_number (HeightMMOfScreen (dpyinfo->screen));
 }
 
 DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0,
-       doc: /* Return the width in millimeters of the X display DEVICE.
-The optional argument DEVICE specifies which display to ask about.
-DEVICE should be a device id, a frame or a display name (a string).
+       doc: /* Return the width in millimeters of the X display TERMINAL.
+The optional argument TERMINAL specifies which display to ask about.
+TERMINAL should be a terminal id, a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-     (device)
-     Lisp_Object device;
+     (terminal)
+     Lisp_Object terminal;
 {
-  struct x_display_info *dpyinfo = check_x_display_info (device);
+  struct x_display_info *dpyinfo = check_x_display_info (terminal);
 
   return make_number (WidthMMOfScreen (dpyinfo->screen));
 }
 
 DEFUN ("x-display-backing-store", Fx_display_backing_store,
        Sx_display_backing_store, 0, 1, 0,
-       doc: /* Returns an indication of whether X display DEVICE does backing store.
+       doc: /* Returns an indication of whether X display TERMINAL does backing store.
 The value may be `always', `when-mapped', or `not-useful'.
-The optional argument DEVICE specifies which display to ask about.
-DEVICE should be a device id, a frame or a display name (a string).
+The optional argument TERMINAL specifies which display to ask about.
+TERMINAL should be a terminal id, a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-     (device)
-     Lisp_Object device;
+     (terminal)
+     Lisp_Object terminal;
 {
-  struct x_display_info *dpyinfo = check_x_display_info (device);
+  struct x_display_info *dpyinfo = check_x_display_info (terminal);
   Lisp_Object result;
 
   switch (DoesBackingStore (dpyinfo->screen))
@@ -3745,17 +3745,17 @@
 
 DEFUN ("x-display-visual-class", Fx_display_visual_class,
        Sx_display_visual_class, 0, 1, 0,
-       doc: /* Return the visual class of the X display DEVICE.
+       doc: /* Return the visual class of the X display TERMINAL.
 The value is one of the symbols `static-gray', `gray-scale',
 `static-color', `pseudo-color', `true-color', or `direct-color'.
 
-The optional argument DEVICE specifies which display to ask about.
-DEVICE should a device id, a frame or a display name (a string).
+The optional argument TERMINAL specifies which display to ask about.
+TERMINAL should a terminal id, a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-     (device)
-     Lisp_Object device;
+     (terminal)
+     Lisp_Object terminal;
 {
-  struct x_display_info *dpyinfo = check_x_display_info (device);
+  struct x_display_info *dpyinfo = check_x_display_info (terminal);
   Lisp_Object result;
 
   switch (dpyinfo->visual->class)
@@ -3788,14 +3788,14 @@
 
 DEFUN ("x-display-save-under", Fx_display_save_under,
        Sx_display_save_under, 0, 1, 0,
-       doc: /* Returns t if the X display DEVICE supports the save-under feature.
-The optional argument DEVICE specifies which display to ask about.
-DEVICE should be a device id, a frame or a display name (a string).
+       doc: /* Returns t if the X display TERMINAL supports the save-under feature.
+The optional argument TERMINAL specifies which display to ask about.
+TERMINAL should be a terminal id, a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-     (device)
-     Lisp_Object device;
+     (terminal)
+     Lisp_Object terminal;
 {
-  struct x_display_info *dpyinfo = check_x_display_info (device);
+  struct x_display_info *dpyinfo = check_x_display_info (terminal);
 
   if (DoesSaveUnders (dpyinfo->screen) == True)
     return Qt;
@@ -4075,7 +4075,7 @@
   if (dpyinfo->reference_count > 0)
     error ("Display still has frames on it");
 
-  x_delete_device (dpyinfo->device);
+  x_delete_terminal (dpyinfo->terminal);
 
   return Qnil;
 }
@@ -4652,8 +4652,8 @@
   FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;
   record_unwind_protect (unwind_create_tip_frame, frame);
 
-  f->device = dpyinfo->device;
-  f->device->reference_count++;
+  f->terminal = dpyinfo->terminal;
+  f->terminal->reference_count++;
 
   /* By setting the output method, we're essentially saying that
      the frame is live, as per FRAME_LIVE_P.  If we get a signal
--- a/src/xselect.c	Thu Dec 29 04:57:14 2005 +0000
+++ b/src/xselect.c	Thu Dec 29 18:20:26 2005 +0000
@@ -1010,7 +1010,7 @@
      to see if this Emacs job now owns the selection
      through that display.  */
   for (t_dpyinfo = x_display_list; t_dpyinfo; t_dpyinfo = t_dpyinfo->next)
-    if (t_dpyinfo->device->kboard == dpyinfo->device->kboard)
+    if (t_dpyinfo->terminal->kboard == dpyinfo->terminal->kboard)
       {
 	Window owner_window
 	  = XGetSelectionOwner (t_dpyinfo->display, selection);
--- a/src/xterm.c	Thu Dec 29 04:57:14 2005 +0000
+++ b/src/xterm.c	Thu Dec 29 18:20:26 2005 +0000
@@ -338,15 +338,15 @@
 void x_set_window_size P_ ((struct frame *, int, int, int));
 void x_wm_set_window_state P_ ((struct frame *, int));
 void x_wm_set_icon_pixmap P_ ((struct frame *, int));
-struct device *x_create_device P_ ((struct x_display_info *));
-void x_delete_device P_ ((struct device *));
+static struct terminal *x_create_terminal P_ ((struct x_display_info *));
+void x_delete_terminal P_ ((struct terminal *));
 void x_initialize P_ ((void));
 static void x_font_min_bounds P_ ((XFontStruct *, int *, int *));
 static int x_compute_min_glyph_bounds P_ ((struct frame *));
 static void x_update_end P_ ((struct frame *));
 static void XTframe_up_to_date P_ ((struct frame *));
-static void XTset_terminal_modes P_ ((struct device *));
-static void XTreset_terminal_modes P_ ((struct device *));
+static void XTset_terminal_modes P_ ((struct terminal *));
+static void XTreset_terminal_modes P_ ((struct terminal *));
 static void x_clear_frame P_ ((struct frame *));
 static void frame_highlight P_ ((struct frame *));
 static void frame_unhighlight P_ ((struct frame *));
@@ -806,7 +806,7 @@
    rarely happens).  */
 
 static void
-XTset_terminal_modes (struct device *device)
+XTset_terminal_modes (struct terminal *terminal)
 {
 }
 
@@ -814,7 +814,7 @@
    the X-windows go away, and suspending requires no action.  */
 
 static void
-XTreset_terminal_modes (struct device *device)
+XTreset_terminal_modes (struct terminal *terminal)
 {
 }
 
@@ -5673,7 +5673,7 @@
   int count = 0;
   int do_help = 0;
   int nbytes = 0;
-  struct frame *f;
+  struct frame *f = NULL;
   struct coding_system coding;
   XEvent event = *eventp;
 
@@ -6923,8 +6923,8 @@
    EXPECTED is nonzero if the caller knows input is available.  */
 
 static int
-XTread_socket (device, expected, hold_quit)
-     struct device *device;
+XTread_socket (terminal, expected, hold_quit)
+     struct terminal *terminal;
      int expected;
      struct input_event *hold_quit;
 {
@@ -6987,7 +6987,7 @@
 
 #ifdef HAVE_X_SM
       /* Only check session manager input for the primary display. */
-      if (device->id == 1 && x_session_have_connection ())
+      if (terminal->id == 1 && x_session_have_connection ())
         {
           struct input_event inev;
           BLOCK_INPUT;
@@ -7656,7 +7656,7 @@
       /* Protect display from being closed when we delete the last
          frame on it. */
       dpyinfo->reference_count++;
-      dpyinfo->device->reference_count++;
+      dpyinfo->terminal->reference_count++;
     }
   
   /* First delete frames whose mini-buffers are on frames
@@ -7724,7 +7724,7 @@
       dpyinfo->display = 0;
 
       dpyinfo->reference_count--;
-      dpyinfo->device->reference_count--;
+      dpyinfo->terminal->reference_count--;
       if (dpyinfo->reference_count != 0)
         /* We have just closed all frames on this display. */
         abort ();
@@ -7734,7 +7734,7 @@
 
   x_uncatch_errors (dpy, count);
 
-  if (device_list == 0)
+  if (terminal_list == 0)
     {
       fprintf (stderr, "%s\n", error_msg);
       shut_down_emacs (0, 0, Qnil);
@@ -10121,7 +10121,7 @@
 {
   int connection;
   Display *dpy;
-  struct device *device;
+  struct terminal *terminal;
   struct x_display_info *dpyinfo;
   XrmDatabase xrdb;
 
@@ -10268,7 +10268,7 @@
   dpyinfo = (struct x_display_info *) xmalloc (sizeof (struct x_display_info));
   bzero (dpyinfo, sizeof *dpyinfo);
 
-  device = x_create_device (dpyinfo);
+  terminal = x_create_terminal (dpyinfo);
 
 #ifdef MULTI_KBOARD
   {
@@ -10281,30 +10281,30 @@
 			 SDATA (display_name)))
 	break;
     if (share)
-      device->kboard = share->device->kboard;
+      terminal->kboard = share->terminal->kboard;
     else
       {
-	device->kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
-	init_kboard (device->kboard);
+	terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
+	init_kboard (terminal->kboard);
 	if (!EQ (XSYMBOL (Qvendor_specific_keysyms)->function, Qunbound))
 	  {
 	    char *vendor = ServerVendor (dpy);
 	    UNBLOCK_INPUT;
-	    device->kboard->Vsystem_key_alist
+	    terminal->kboard->Vsystem_key_alist
 	      = call1 (Qvendor_specific_keysyms,
 		       build_string (vendor ? vendor : ""));
 	    BLOCK_INPUT;
 	  }
 
-	device->kboard->next_kboard = all_kboards;
-	all_kboards = device->kboard;
+	terminal->kboard->next_kboard = all_kboards;
+	all_kboards = terminal->kboard;
 	/* Don't let the initial kboard remain current longer than necessary.
 	   That would cause problems if a file loaded on startup tries to
 	   prompt in the mini-buffer.  */
 	if (current_kboard == initial_kboard)
-	  current_kboard = device->kboard;
+	  current_kboard = terminal->kboard;
       }
-    device->kboard->reference_count++;
+    terminal->kboard->reference_count++;
   }
 #endif
 
@@ -10319,10 +10319,10 @@
 
   dpyinfo->display = dpy;
 
-  /* Set the name of the device. */
-  device->name = (char *) xmalloc (SBYTES (display_name) + 1);
-  strncpy (device->name, SDATA (display_name), SBYTES (display_name));
-  device->name[SBYTES (display_name)] = 0;
+  /* Set the name of the terminal. */
+  terminal->name = (char *) xmalloc (SBYTES (display_name) + 1);
+  strncpy (terminal->name, SDATA (display_name), SBYTES (display_name));
+  terminal->name[SBYTES (display_name)] = 0;
   
 #if 0
   XSetAfterFunction (x_current_display, x_trace_wire);
@@ -10614,7 +10614,7 @@
   /* Only do this for the very first display in the Emacs session.
      Ignore X session management when Emacs was first started on a
      tty.  */
-  if (device->id == 1)
+  if (terminal->id == 1)
     x_session_initialize (dpyinfo);
 #endif
 
@@ -10631,17 +10631,17 @@
      struct x_display_info *dpyinfo;
 {
   int i;
-  struct device *d;
-
-  /* Delete the generic struct device for this X display. */
-  for (d = device_list; d; d = d->next_device)
-    if (d->type == output_x_window && d->display_info.x == dpyinfo)
+  struct terminal *t;
+
+  /* Delete the generic struct terminal for this X display. */
+  for (t = terminal_list; t; t = t->next_terminal)
+    if (t->type == output_x_window && t->display_info.x == dpyinfo)
       {
         /* Close X session management when we close its display. */
-        if (d->id == 1 && x_session_have_connection ())
+        if (t->id == 1 && x_session_have_connection ())
           x_session_close();
 
-        delete_device (d);
+        delete_terminal (t);
         break;
       }
 
@@ -10776,9 +10776,9 @@
 
 /* This function is called when the last frame on a display is deleted. */
 void
-x_delete_device (struct device *device)
-{
-  struct x_display_info *dpyinfo = device->display_info.x;
+x_delete_terminal (struct terminal *terminal)
+{
+  struct x_display_info *dpyinfo = terminal->display_info.x;
   int i;
 
   BLOCK_INPUT;
@@ -10807,50 +10807,50 @@
 }
 
 
-struct device *
-x_create_device (struct x_display_info *dpyinfo)
-{
-  struct device *device;
+static struct terminal *
+x_create_terminal (struct x_display_info *dpyinfo)
+{
+  struct terminal *terminal;
   
-  device = create_device ();
-
-  device->type = output_x_window;
-  device->display_info.x = dpyinfo;
-  dpyinfo->device = device;
+  terminal = create_terminal ();
+
+  terminal->type = output_x_window;
+  terminal->display_info.x = dpyinfo;
+  dpyinfo->terminal = terminal;
 
   /* kboard is initialized in x_term_init. */
   
-  device->clear_frame_hook = x_clear_frame;
-  device->ins_del_lines_hook = x_ins_del_lines;
-  device->delete_glyphs_hook = x_delete_glyphs;
-  device->ring_bell_hook = XTring_bell;
-  device->reset_terminal_modes_hook = XTreset_terminal_modes;
-  device->set_terminal_modes_hook = XTset_terminal_modes;
-  device->update_begin_hook = x_update_begin;
-  device->update_end_hook = x_update_end;
-  device->set_terminal_window_hook = XTset_terminal_window;
-  device->read_socket_hook = XTread_socket;
-  device->frame_up_to_date_hook = XTframe_up_to_date;
-  device->mouse_position_hook = XTmouse_position;
-  device->frame_rehighlight_hook = XTframe_rehighlight;
-  device->frame_raise_lower_hook = XTframe_raise_lower;
-  device->set_vertical_scroll_bar_hook = XTset_vertical_scroll_bar;
-  device->condemn_scroll_bars_hook = XTcondemn_scroll_bars;
-  device->redeem_scroll_bar_hook = XTredeem_scroll_bar;
-  device->judge_scroll_bars_hook = XTjudge_scroll_bars;
-
-  device->delete_frame_hook = x_destroy_window;
-  device->delete_device_hook = x_delete_device;
+  terminal->clear_frame_hook = x_clear_frame;
+  terminal->ins_del_lines_hook = x_ins_del_lines;
+  terminal->delete_glyphs_hook = x_delete_glyphs;
+  terminal->ring_bell_hook = XTring_bell;
+  terminal->reset_terminal_modes_hook = XTreset_terminal_modes;
+  terminal->set_terminal_modes_hook = XTset_terminal_modes;
+  terminal->update_begin_hook = x_update_begin;
+  terminal->update_end_hook = x_update_end;
+  terminal->set_terminal_window_hook = XTset_terminal_window;
+  terminal->read_socket_hook = XTread_socket;
+  terminal->frame_up_to_date_hook = XTframe_up_to_date;
+  terminal->mouse_position_hook = XTmouse_position;
+  terminal->frame_rehighlight_hook = XTframe_rehighlight;
+  terminal->frame_raise_lower_hook = XTframe_raise_lower;
+  terminal->set_vertical_scroll_bar_hook = XTset_vertical_scroll_bar;
+  terminal->condemn_scroll_bars_hook = XTcondemn_scroll_bars;
+  terminal->redeem_scroll_bar_hook = XTredeem_scroll_bar;
+  terminal->judge_scroll_bars_hook = XTjudge_scroll_bars;
+
+  terminal->delete_frame_hook = x_destroy_window;
+  terminal->delete_terminal_hook = x_delete_terminal;
   
-  device->rif = &x_redisplay_interface;
-  device->scroll_region_ok = 1;    /* We'll scroll partial frames. */
-  device->char_ins_del_ok = 1;
-  device->line_ins_del_ok = 1;         /* We'll just blt 'em. */
-  device->fast_clear_end_of_line = 1;  /* X does this well. */
-  device->memory_below_frame = 0;   /* We don't remember what scrolls
+  terminal->rif = &x_redisplay_interface;
+  terminal->scroll_region_ok = 1;    /* We'll scroll partial frames. */
+  terminal->char_ins_del_ok = 1;
+  terminal->line_ins_del_ok = 1;         /* We'll just blt 'em. */
+  terminal->fast_clear_end_of_line = 1;  /* X does this well. */
+  terminal->memory_below_frame = 0;   /* We don't remember what scrolls
                                         off the bottom. */
 
-  return device;
+  return terminal;
 }
 
 void
--- a/src/xterm.h	Thu Dec 29 04:57:14 2005 +0000
+++ b/src/xterm.h	Thu Dec 29 18:20:26 2005 +0000
@@ -388,7 +388,7 @@
     } wm_type;
 
   /* The generic display parameters corresponding to this X display. */
-  struct device *device;
+  struct terminal *terminal;
 };
 
 #ifdef HAVE_X_I18N
@@ -995,7 +995,7 @@
 extern void x_wm_set_window_state P_ ((struct frame *, int));
 extern void x_wm_set_icon_pixmap P_ ((struct frame *, int));
 extern void x_delete_display P_ ((struct x_display_info *));
-extern void x_delete_device P_ ((struct device *device));
+extern void x_delete_terminal P_ ((struct terminal *terminal));
 extern void x_initialize P_ ((void));
 extern unsigned long x_copy_color P_ ((struct frame *, unsigned long));
 #ifdef USE_X_TOOLKIT