]> code.delx.au - gnu-emacs/blobdiff - lisp/term/x-win.el
* term/x-win.el (x-select-text, x-cut-buffer-or-selection-value):
[gnu-emacs] / lisp / term / x-win.el
index f161f5cb202aeca8bdedea2357a07c20bc2e7987..0e68fa575eb9155616ccd347241910c33494666c 100644 (file)
@@ -1,9 +1,10 @@
-;;; x-win.el --- parse switches controlling interface with X window system
+;;; x-win.el --- parse relevant switches and set up for X  -*-coding: iso-2022-7bit;-*-
 
-;; Copyright (C) 1993, 1994, 2001 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1994, 2001, 2002, 2003, 2004,
+;;   2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: FSF
-;; Keywords: terminals
+;; Keywords: terminals, i18n
 
 ;; This file is part of GNU Emacs.
 
@@ -19,8 +20,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
@@ -30,7 +31,7 @@
 ;; X display is opened and hooks are set for popping up the initial window.
 
 ;; startup.el will then examine startup files, and eventually call the hooks
-;; which create the first window (s).
+;; which create the first window(s).
 
 ;;; Code:
 \f
@@ -53,8 +54,6 @@
 ;; -font               *font
 ;; -foreground         *foreground
 ;; -geometry           .geometry
-;; -i                  .iconType
-;; -itype              .iconType
 ;; -iconic             .iconic
 ;; -name               .name
 ;; -reverse            *reverseVideo
 
 (if (not (eq window-system 'x))
     (error "%s: Loading x-win.el but not compiled for X" (invocation-name)))
-        
+
 (require 'frame)
 (require 'mouse)
 (require 'scroll-bar)
 (require 'faces)
 (require 'select)
 (require 'menu-bar)
-(if (fboundp 'new-fontset)
-    (require 'fontset))
+(require 'fontset)
+(require 'x-dnd)
 
 (defvar x-invocation-args)
+(defvar x-keysym-table)
+(defvar x-selection-timeout)
+(defvar x-session-id)
+(defvar x-session-previous-id)
 
 (defvar x-command-line-resources nil)
 
        (let ((param (nth 3 aelt)))
          (setq default-frame-alist
                (cons (cons param
-                           (string-to-int (car x-invocation-args)))
+                           (string-to-number (car x-invocation-args)))
                      default-frame-alist)
                x-invocation-args
                (cdr x-invocation-args))))))
 
+;; Handle options that apply to initial frame only
+(defun x-handle-initial-switch (switch)
+  (let ((aelt (assoc switch command-line-x-option-alist)))
+    (if aelt
+       (let ((param (nth 3 aelt))
+             (value (nth 4 aelt)))
+         (if value
+             (setq initial-frame-alist
+                   (cons (cons param value)
+                         initial-frame-alist))
+           (setq initial-frame-alist
+                 (cons (cons param
+                             (car x-invocation-args))
+                       initial-frame-alist)
+                 x-invocation-args (cdr x-invocation-args)))))))
+
 ;; Make -iconic apply only to the initial frame!
 (defun x-handle-iconic (switch)
   (setq initial-frame-alist
     (if (or height width)
        (setq default-frame-alist
              (append default-frame-alist
+                     '((user-size . t))
+                     (if height (list height))
+                     (if width (list width)))
+             initial-frame-alist
+             (append initial-frame-alist
                      '((user-size . t))
                      (if height (list height))
                      (if width (list width)))))
                                  initial-frame-alist)))
 
 (defvar x-display-name nil
-  "The X display name specifying server and X frame.")
+  "The name of the X display on which Emacs was started.
+
+For the X display name of individual frames, see the `display'
+frame parameter.")
 
 (defun x-handle-display (switch)
+  "Handle -display DISPLAY option."
   (setq x-display-name (car x-invocation-args)
        x-invocation-args (cdr x-invocation-args))
   ;; Make subshell programs see the same DISPLAY value Emacs really uses.
@@ -213,6 +241,75 @@ This function returns ARGS minus the arguments that have been processed."
            (funcall handler this-switch))
        (setq args (cons orig-this-switch args)))))
   (nconc (nreverse args) x-invocation-args))
+
+;; Handle the --smid switch.  This is used by the session manager
+;; to give us back our session id we had on the previous run.
+(defun x-handle-smid (switch)
+  (or (consp x-invocation-args)
+      (error "%s: missing argument to `%s' option" (invocation-name) switch))
+  (setq x-session-previous-id (car x-invocation-args)
+       x-invocation-args (cdr x-invocation-args)))
+
+(defvar emacs-save-session-functions nil
+  "Special hook run when a save-session event occurs.
+The functions do not get any argument.
+Functions can return non-nil to inform the session manager that the
+window system shutdown should be aborted.
+
+See also `emacs-session-save'.")
+
+(defun emacs-session-filename (session-id)
+  "Construct a filename to save the session in based on SESSION-ID.
+If the directory ~/.emacs.d exists, we make a filename in there, otherwise
+a file in the home directory."
+  (let ((basename (concat "session." session-id))
+       (emacs-dir "~/.emacs.d/"))
+    (expand-file-name (if (file-directory-p emacs-dir)
+                         (concat emacs-dir basename)
+                       (concat "~/.emacs-" basename)))))
+
+(defun emacs-session-save ()
+  "This function is called when the window system is shutting down.
+If this function returns non-nil, the window system shutdown is cancelled.
+
+When a session manager tells Emacs that the window system is shutting
+down, this function is called.  It calls the functions in the hook
+`emacs-save-session-functions'.  Functions are called with the current
+buffer set to a temporary buffer.  Functions should use `insert' to insert
+lisp code to save the session state.  The buffer is saved
+in a file in the home directory of the user running Emacs.  The file
+is evaluated when Emacs is restarted by the session manager.
+
+If any of the functions returns non-nil, no more functions are called
+and this function returns non-nil.  This will inform the session manager
+that it should abort the window system shutdown."
+  (let ((filename (emacs-session-filename x-session-id))
+       (buf (get-buffer-create (concat " *SES " x-session-id))))
+    (when (file-exists-p filename)
+      (delete-file filename))
+    (with-current-buffer buf
+      (let ((cancel-shutdown (condition-case nil
+                                ;; A return of t means cancel the shutdown.
+                                (run-hook-with-args-until-success
+                                 'emacs-save-session-functions)
+                              (error t))))
+       (unless cancel-shutdown
+         (write-file filename))
+       (kill-buffer buf)
+       cancel-shutdown))))
+
+(defun emacs-session-restore (previous-session-id)
+  "Restore the Emacs session if started by a session manager.
+The file saved by `emacs-session-save' is evaluated and deleted if it
+exists."
+  (let ((filename (emacs-session-filename previous-session-id)))
+    (when (file-exists-p filename)
+      (load-file filename)
+      (delete-file filename)
+      (message "Restored session data"))))
+
+
+
 \f
 ;;
 ;; Standard X cursor shapes, courtesy of Mr. Fox, who wanted ALL of them.
@@ -1070,13 +1167,6 @@ XConsortium: rgb.txt,v 10.41 94/02/20 18:39:36 rws Exp")
 \f
 ;;;; Function keys
 
-(defun iconify-or-deiconify-frame ()
-  "Iconify the selected frame, or deiconify if it's currently an icon."
-  (interactive)
-  (if (eq (cdr (assq 'visibility (frame-parameters))) t)
-      (iconify-frame)
-    (make-frame-visible)))
-
 (substitute-key-definition 'suspend-emacs 'iconify-or-deiconify-frame
                           global-map)
 
@@ -1097,6 +1187,7 @@ XConsortium: rgb.txt,v 10.41 94/02/20 18:39:36 rws Exp")
 (define-key function-key-map [M-return] [?\M-\C-m])
 (define-key function-key-map [M-escape] [?\M-\e])
 (define-key function-key-map [iso-lefttab] [backtab])
+(define-key function-key-map [S-iso-lefttab] [backtab])
 
 ;; These tell read-char how to convert
 ;; these special chars to ASCII.
@@ -1108,10 +1199,14 @@ XConsortium: rgb.txt,v 10.41 94/02/20 18:39:36 rws Exp")
 (put 'return 'ascii-character 13)
 (put 'escape 'ascii-character ?\e)
 
+\f
+;;;; Keysyms
+
 (defun vendor-specific-keysyms (vendor)
-  "Return the appropriate value of system-key-alist for VENDOR.
+  "Return the appropriate value of `system-key-alist' for VENDOR.
 VENDOR is a string containing the name of the X Server's vendor,
-as returned by (x-server-vendor)."
+as returned by `x-server-vendor'."
+  ;; Fixme: Drop Apollo now?
   (cond ((string-equal vendor "Apollo Computer Inc.")
         '((65280 . linedel)
           (65281 . chardel)
@@ -1155,6 +1250,7 @@ as returned by (x-server-vendor)."
           (65395 . deletechar)
           (65396 . backtab)
           (65397 . kp-backtab)))
+       ;; Fixme: What about non-X11/NeWS sun server?
        ((or (string-equal vendor "X11/NeWS - Sun Microsystems Inc.")
             (string-equal vendor "X Consortium"))
         '((392976 . f36)
@@ -1171,18 +1267,881 @@ as returned by (x-server-vendor)."
         ;; This is used by DEC's X server.
         '((65280 . remove)))))
 
+(let ((i 160))
+  (while (< i 256)
+    (puthash i (make-char 'latin-iso8859-1 i) x-keysym-table)
+    (setq i (1+ i))))
+
+;; Table from Kuhn's proposed additions to the `KEYSYM Encoding'
+;; appendix to the X protocol definition.
+(dolist
+     (pair
+      '(
+       ;; Latin-2
+       (#x1a1 . ?\e,B!\e(B)
+       (#x1a2 . ?\e,B"\e(B)
+       (#x1a3 . ?\e,B#\e(B)
+       (#x1a5 . ?\e,B%\e(B)
+       (#x1a6 . ?\e,B&\e(B)
+       (#x1a9 . ?\e,B)\e(B)
+       (#x1aa . ?\e,B*\e(B)
+       (#x1ab . ?\e,B+\e(B)
+       (#x1ac . ?\e,B,\e(B)
+       (#x1ae . ?\e,B.\e(B)
+       (#x1af . ?\e,B/\e(B)
+       (#x1b1 . ?\e,B1\e(B)
+       (#x1b2 . ?\e,B2\e(B)
+       (#x1b3 . ?\e,B3\e(B)
+       (#x1b5 . ?\e,B5\e(B)
+       (#x1b6 . ?\e,B6\e(B)
+       (#x1b7 . ?\e,B7\e(B)
+       (#x1b9 . ?\e,B9\e(B)
+       (#x1ba . ?\e,B:\e(B)
+       (#x1bb . ?\e,B;\e(B)
+       (#x1bc . ?\e,B<\e(B)
+       (#x1bd . ?\e,B=\e(B)
+       (#x1be . ?\e,B>\e(B)
+       (#x1bf . ?\e,B?\e(B)
+       (#x1c0 . ?\e,B@\e(B)
+       (#x1c3 . ?\e,BC\e(B)
+       (#x1c5 . ?\e,BE\e(B)
+       (#x1c6 . ?\e,BF\e(B)
+       (#x1c8 . ?\e,BH\e(B)
+       (#x1ca . ?\e,BJ\e(B)
+       (#x1cc . ?\e,BL\e(B)
+       (#x1cf . ?\e,BO\e(B)
+       (#x1d0 . ?\e,BP\e(B)
+       (#x1d1 . ?\e,BQ\e(B)
+       (#x1d2 . ?\e,BR\e(B)
+       (#x1d5 . ?\e,BU\e(B)
+       (#x1d8 . ?\e,BX\e(B)
+       (#x1d9 . ?\e,BY\e(B)
+       (#x1db . ?\e,B[\e(B)
+       (#x1de . ?\e,B^\e(B)
+       (#x1e0 . ?\e,B`\e(B)
+       (#x1e3 . ?\e,Bc\e(B)
+       (#x1e5 . ?\e,Be\e(B)
+       (#x1e6 . ?\e,Bf\e(B)
+       (#x1e8 . ?\e,Bh\e(B)
+       (#x1ea . ?\e,Bj\e(B)
+       (#x1ec . ?\e,Bl\e(B)
+       (#x1ef . ?\e,Bo\e(B)
+       (#x1f0 . ?\e,Bp\e(B)
+       (#x1f1 . ?\e,Bq\e(B)
+       (#x1f2 . ?\e,Br\e(B)
+       (#x1f5 . ?\e,Bu\e(B)
+       (#x1f8 . ?\e,Bx\e(B)
+       (#x1f9 . ?\e,By\e(B)
+       (#x1fb . ?\e,B{\e(B)
+       (#x1fe . ?\e,B~\e(B)
+       (#x1ff . ?\e,B\7f\e(B)
+       ;; Latin-3
+       (#x2a1 . ?\e,C!\e(B)
+       (#x2a6 . ?\e,C&\e(B)
+       (#x2a9 . ?\e,C)\e(B)
+       (#x2ab . ?\e,C+\e(B)
+       (#x2ac . ?\e,C,\e(B)
+       (#x2b1 . ?\e,C1\e(B)
+       (#x2b6 . ?\e,C6\e(B)
+       (#x2b9 . ?\e,C9\e(B)
+       (#x2bb . ?\e,C;\e(B)
+       (#x2bc . ?\e,C<\e(B)
+       (#x2c5 . ?\e,CE\e(B)
+       (#x2c6 . ?\e,CF\e(B)
+       (#x2d5 . ?\e,CU\e(B)
+       (#x2d8 . ?\e,CX\e(B)
+       (#x2dd . ?\e,C]\e(B)
+       (#x2de . ?\e,C^\e(B)
+       (#x2e5 . ?\e,Ce\e(B)
+       (#x2e6 . ?\e,Cf\e(B)
+       (#x2f5 . ?\e,Cu\e(B)
+       (#x2f8 . ?\e,Cx\e(B)
+       (#x2fd . ?\e,C}\e(B)
+       (#x2fe . ?\e,C~\e(B)
+       ;; Latin-4
+       (#x3a2 . ?\e,D"\e(B)
+       (#x3a3 . ?\e,D#\e(B)
+       (#x3a5 . ?\e,D%\e(B)
+       (#x3a6 . ?\e,D&\e(B)
+       (#x3aa . ?\e,D*\e(B)
+       (#x3ab . ?\e,D+\e(B)
+       (#x3ac . ?\e,D,\e(B)
+       (#x3b3 . ?\e,D3\e(B)
+       (#x3b5 . ?\e,D5\e(B)
+       (#x3b6 . ?\e,D6\e(B)
+       (#x3ba . ?\e,D:\e(B)
+       (#x3bb . ?\e,D;\e(B)
+       (#x3bc . ?\e,D<\e(B)
+       (#x3bd . ?\e,D=\e(B)
+       (#x3bf . ?\e,D?\e(B)
+       (#x3c0 . ?\e,D@\e(B)
+       (#x3c7 . ?\e,DG\e(B)
+       (#x3cc . ?\e,DL\e(B)
+       (#x3cf . ?\e,DO\e(B)
+       (#x3d1 . ?\e,DQ\e(B)
+       (#x3d2 . ?\e,DR\e(B)
+       (#x3d3 . ?\e,DS\e(B)
+       (#x3d9 . ?\e,DY\e(B)
+       (#x3dd . ?\e,D]\e(B)
+       (#x3de . ?\e,D^\e(B)
+       (#x3e0 . ?\e,D`\e(B)
+       (#x3e7 . ?\e,Dg\e(B)
+       (#x3ec . ?\e,Dl\e(B)
+       (#x3ef . ?\e,Do\e(B)
+       (#x3f1 . ?\e,Dq\e(B)
+       (#x3f2 . ?\e,Dr\e(B)
+       (#x3f3 . ?\e,Ds\e(B)
+       (#x3f9 . ?\e,Dy\e(B)
+       (#x3fd . ?\e,D}\e(B)
+       (#x3fe . ?\e,D~\e(B)
+       ;; Kana: Fixme: needs conversion to Japanese charset -- seems
+       ;; to require jisx0213, for which the Unicode translation
+       ;; isn't clear.
+       (#x47e . ?\e$,1s>\e(B)
+       (#x4a1 . ?\e$,2=B\e(B)
+       (#x4a2 . ?\\e$,2=L\e(B)
+       (#x4a3 . ?\\e$,2=M\e(B)
+       (#x4a4 . ?\e$,2=A\e(B)
+       (#x4a5 . ?\e$,2?{\e(B)
+       (#x4a6 . ?\e$,2?r\e(B)
+       (#x4a7 . ?\e$,2?!\e(B)
+       (#x4a8 . ?\e$,2?#\e(B)
+       (#x4a9 . ?\e$,2?%\e(B)
+       (#x4aa . ?\e$,2?'\e(B)
+       (#x4ab . ?\e$,2?)\e(B)
+       (#x4ac . ?\e$,2?c\e(B)
+       (#x4ad . ?\e$,2?e\e(B)
+       (#x4ae . ?\e$,2?g\e(B)
+       (#x4af . ?\e$,2?C\e(B)
+       (#x4b0 . ?\e$,2?|\e(B)
+       (#x4b1 . ?\e$,2?"\e(B)
+       (#x4b2 . ?\e$,2?$\e(B)
+       (#x4b3 . ?\e$,2?&\e(B)
+       (#x4b4 . ?\e$,2?(\e(B)
+       (#x4b5 . ?\e$,2?*\e(B)
+       (#x4b6 . ?\e$,2?+\e(B)
+       (#x4b7 . ?\e$,2?-\e(B)
+       (#x4b8 . ?\e$,2?/\e(B)
+       (#x4b9 . ?\e$,2?1\e(B)
+       (#x4ba . ?\e$,2?3\e(B)
+       (#x4bb . ?\e$,2?5\e(B)
+       (#x4bc . ?\e$,2?7\e(B)
+       (#x4bd . ?\e$,2?9\e(B)
+       (#x4be . ?\e$,2?;\e(B)
+       (#x4bf . ?\e$,2?=\e(B)
+       (#x4c0 . ?\e$,2??\e(B)
+       (#x4c1 . ?\e$,2?A\e(B)
+       (#x4c2 . ?\e$,2?D\e(B)
+       (#x4c3 . ?\e$,2?F\e(B)
+       (#x4c4 . ?\e$,2?H\e(B)
+       (#x4c5 . ?\e$,2?J\e(B)
+       (#x4c6 . ?\e$,2?K\e(B)
+       (#x4c7 . ?\e$,2?L\e(B)
+       (#x4c8 . ?\e$,2?M\e(B)
+       (#x4c9 . ?\e$,2?N\e(B)
+       (#x4ca . ?\e$,2?O\e(B)
+       (#x4cb . ?\e$,2?R\e(B)
+       (#x4cc . ?\e$,2?U\e(B)
+       (#x4cd . ?\e$,2?X\e(B)
+       (#x4ce . ?\e$,2?[\e(B)
+       (#x4cf . ?\e$,2?^\e(B)
+       (#x4d0 . ?\e$,2?_\e(B)
+       (#x4d1 . ?\e$,2?`\e(B)
+       (#x4d2 . ?\e$,2?a\e(B)
+       (#x4d3 . ?\e$,2?b\e(B)
+       (#x4d4 . ?\e$,2?d\e(B)
+       (#x4d5 . ?\e$,2?f\e(B)
+       (#x4d6 . ?\e$,2?h\e(B)
+       (#x4d7 . ?\e$,2?i\e(B)
+       (#x4d8 . ?\e$,2?j\e(B)
+       (#x4d9 . ?\e$,2?k\e(B)
+       (#x4da . ?\e$,2?l\e(B)
+       (#x4db . ?\e$,2?m\e(B)
+       (#x4dc . ?\e$,2?o\e(B)
+       (#x4dd . ?\e$,2?s\e(B)
+       (#x4de . ?\e$,2>{\e(B)
+       (#x4df . ?\e$,2>|\e(B)
+       ;; Arabic
+       (#x5ac . ?\e,G,\e(B)
+       (#x5bb . ?\e,G;\e(B)
+       (#x5bf . ?\e,G?\e(B)
+       (#x5c1 . ?\e,GA\e(B)
+       (#x5c2 . ?\e,GB\e(B)
+       (#x5c3 . ?\e,GC\e(B)
+       (#x5c4 . ?\e,GD\e(B)
+       (#x5c5 . ?\e,GE\e(B)
+       (#x5c6 . ?\e,GF\e(B)
+       (#x5c7 . ?\e,GG\e(B)
+       (#x5c8 . ?\e,GH\e(B)
+       (#x5c9 . ?\e,GI\e(B)
+       (#x5ca . ?\e,GJ\e(B)
+       (#x5cb . ?\e,GK\e(B)
+       (#x5cc . ?\e,GL\e(B)
+       (#x5cd . ?\e,GM\e(B)
+       (#x5ce . ?\e,GN\e(B)
+       (#x5cf . ?\e,GO\e(B)
+       (#x5d0 . ?\e,GP\e(B)
+       (#x5d1 . ?\e,GQ\e(B)
+       (#x5d2 . ?\e,GR\e(B)
+       (#x5d3 . ?\e,GS\e(B)
+       (#x5d4 . ?\e,GT\e(B)
+       (#x5d5 . ?\e,GU\e(B)
+       (#x5d6 . ?\e,GV\e(B)
+       (#x5d7 . ?\e,GW\e(B)
+       (#x5d8 . ?\e,GX\e(B)
+       (#x5d9 . ?\e,GY\e(B)
+       (#x5da . ?\e,GZ\e(B)
+       (#x5e0 . ?\e,G`\e(B)
+       (#x5e1 . ?\e,Ga\e(B)
+       (#x5e2 . ?\e,Gb\e(B)
+       (#x5e3 . ?\e,Gc\e(B)
+       (#x5e4 . ?\e,Gd\e(B)
+       (#x5e5 . ?\e,Ge\e(B)
+       (#x5e6 . ?\e,Gf\e(B)
+       (#x5e7 . ?\e,Gg\e(B)
+       (#x5e8 . ?\e,Gh\e(B)
+       (#x5e9 . ?\e,Gi\e(B)
+       (#x5ea . ?\e,Gj\e(B)
+       (#x5eb . ?\e,Gk\e(B)
+       (#x5ec . ?\e,Gl\e(B)
+       (#x5ed . ?\e,Gm\e(B)
+       (#x5ee . ?\e,Gn\e(B)
+       (#x5ef . ?\e,Go\e(B)
+       (#x5f0 . ?\e,Gp\e(B)
+       (#x5f1 . ?\e,Gq\e(B)
+       (#x5f2 . ?\e,Gr\e(B)
+       ;; Cyrillic
+       (#x680 . ?\e$,1)R\e(B)
+       (#x681 . ?\e$,1)V\e(B)
+       (#x682 . ?\e$,1)Z\e(B)
+       (#x683 . ?\e$,1)\\e(B)
+       (#x684 . ?\e$,1)b\e(B)
+       (#x685 . ?\e$,1)n\e(B)
+       (#x686 . ?\e$,1)p\e(B)
+       (#x687 . ?\e$,1)r\e(B)
+       (#x688 . ?\e$,1)v\e(B)
+       (#x689 . ?\e$,1)x\e(B)
+       (#x68a . ?\e$,1)z\e(B)
+       (#x68c . ?\e$,1*8\e(B)
+       (#x68d . ?\e$,1*B\e(B)
+       (#x68e . ?\e$,1*H\e(B)
+       (#x68f . ?\e$,1*N\e(B)
+       (#x690 . ?\e$,1)S\e(B)
+       (#x691 . ?\e$,1)W\e(B)
+       (#x692 . ?\e$,1)[\e(B)
+       (#x693 . ?\e$,1)]\e(B)
+       (#x694 . ?\e$,1)c\e(B)
+       (#x695 . ?\e$,1)o\e(B)
+       (#x696 . ?\e$,1)q\e(B)
+       (#x697 . ?\e$,1)s\e(B)
+       (#x698 . ?\e$,1)w\e(B)
+       (#x699 . ?\e$,1)y\e(B)
+       (#x69a . ?\e$,1){\e(B)
+       (#x69c . ?\e$,1*9\e(B)
+       (#x69d . ?\e$,1*C\e(B)
+       (#x69e . ?\e$,1*I\e(B)
+       (#x69f . ?\e$,1*O\e(B)
+       (#x6a1 . ?\e,Lr\e(B)
+       (#x6a2 . ?\e,Ls\e(B)
+       (#x6a3 . ?\e,Lq\e(B)
+       (#x6a4 . ?\e,Lt\e(B)
+       (#x6a5 . ?\e,Lu\e(B)
+       (#x6a6 . ?\e,Lv\e(B)
+       (#x6a7 . ?\e,Lw\e(B)
+       (#x6a8 . ?\e,Lx\e(B)
+       (#x6a9 . ?\e,Ly\e(B)
+       (#x6aa . ?\e,Lz\e(B)
+       (#x6ab . ?\e,L{\e(B)
+       (#x6ac . ?\e,L|\e(B)
+       (#x6ae . ?\e,L~\e(B)
+       (#x6af . ?\e,L\7f\e(B)
+       (#x6b0 . ?\e,Lp\e(B)
+       (#x6b1 . ?\e,L"\e(B)
+       (#x6b2 . ?\e,L#\e(B)
+       (#x6b3 . ?\e,L!\e(B)
+       (#x6b4 . ?\e,L$\e(B)
+       (#x6b5 . ?\e,L%\e(B)
+       (#x6b6 . ?\e,L&\e(B)
+       (#x6b7 . ?\e,L'\e(B)
+       (#x6b8 . ?\e,L(\e(B)
+       (#x6b9 . ?\e,L)\e(B)
+       (#x6ba . ?\e,L*\e(B)
+       (#x6bb . ?\e,L+\e(B)
+       (#x6bc . ?\e,L,\e(B)
+       (#x6be . ?\e,L.\e(B)
+       (#x6bf . ?\e,L/\e(B)
+       (#x6c0 . ?\e,Ln\e(B)
+       (#x6c1 . ?\e,LP\e(B)
+       (#x6c2 . ?\e,LQ\e(B)
+       (#x6c3 . ?\e,Lf\e(B)
+       (#x6c4 . ?\e,LT\e(B)
+       (#x6c5 . ?\e,LU\e(B)
+       (#x6c6 . ?\e,Ld\e(B)
+       (#x6c7 . ?\e,LS\e(B)
+       (#x6c8 . ?\e,Le\e(B)
+       (#x6c9 . ?\e,LX\e(B)
+       (#x6ca . ?\e,LY\e(B)
+       (#x6cb . ?\e,LZ\e(B)
+       (#x6cc . ?\e,L[\e(B)
+       (#x6cd . ?\e,L\\e(B)
+       (#x6ce . ?\e,L]\e(B)
+       (#x6cf . ?\e,L^\e(B)
+       (#x6d0 . ?\e,L_\e(B)
+       (#x6d1 . ?\e,Lo\e(B)
+       (#x6d2 . ?\e,L`\e(B)
+       (#x6d3 . ?\e,La\e(B)
+       (#x6d4 . ?\e,Lb\e(B)
+       (#x6d5 . ?\e,Lc\e(B)
+       (#x6d6 . ?\e,LV\e(B)
+       (#x6d7 . ?\e,LR\e(B)
+       (#x6d8 . ?\e,Ll\e(B)
+       (#x6d9 . ?\e,Lk\e(B)
+       (#x6da . ?\e,LW\e(B)
+       (#x6db . ?\e,Lh\e(B)
+       (#x6dc . ?\e,Lm\e(B)
+       (#x6dd . ?\e,Li\e(B)
+       (#x6de . ?\e,Lg\e(B)
+       (#x6df . ?\e,Lj\e(B)
+       (#x6e0 . ?\e,LN\e(B)
+       (#x6e1 . ?\e,L0\e(B)
+       (#x6e2 . ?\e,L1\e(B)
+       (#x6e3 . ?\e,LF\e(B)
+       (#x6e4 . ?\e,L4\e(B)
+       (#x6e5 . ?\e,L5\e(B)
+       (#x6e6 . ?\e,LD\e(B)
+       (#x6e7 . ?\e,L3\e(B)
+       (#x6e8 . ?\e,LE\e(B)
+       (#x6e9 . ?\e,L8\e(B)
+       (#x6ea . ?\e,L9\e(B)
+       (#x6eb . ?\e,L:\e(B)
+       (#x6ec . ?\e,L;\e(B)
+       (#x6ed . ?\e,L<\e(B)
+       (#x6ee . ?\e,L=\e(B)
+       (#x6ef . ?\e,L>\e(B)
+       (#x6f0 . ?\e,L?\e(B)
+       (#x6f1 . ?\e,LO\e(B)
+       (#x6f2 . ?\e,L@\e(B)
+       (#x6f3 . ?\e,LA\e(B)
+       (#x6f4 . ?\e,LB\e(B)
+       (#x6f5 . ?\e,LC\e(B)
+       (#x6f6 . ?\e,L6\e(B)
+       (#x6f7 . ?\e,L2\e(B)
+       (#x6f8 . ?\e,LL\e(B)
+       (#x6f9 . ?\e,LK\e(B)
+       (#x6fa . ?\e,L7\e(B)
+       (#x6fb . ?\e,LH\e(B)
+       (#x6fc . ?\e,LM\e(B)
+       (#x6fd . ?\e,LI\e(B)
+       (#x6fe . ?\e,LG\e(B)
+       (#x6ff . ?\e,LJ\e(B)
+       ;; Greek
+       (#x7a1 . ?\e,F6\e(B)
+       (#x7a2 . ?\e,F8\e(B)
+       (#x7a3 . ?\e,F9\e(B)
+       (#x7a4 . ?\e,F:\e(B)
+       (#x7a5 . ?\e,FZ\e(B)
+       (#x7a7 . ?\e,F<\e(B)
+       (#x7a8 . ?\e,F>\e(B)
+       (#x7a9 . ?\e,F[\e(B)
+       (#x7ab . ?\e,F?\e(B)
+       (#x7ae . ?\e,F5\e(B)
+       (#x7af . ?\e,F/\e(B)
+       (#x7b1 . ?\e,F\\e(B)
+       (#x7b2 . ?\e,F]\e(B)
+       (#x7b3 . ?\e,F^\e(B)
+       (#x7b4 . ?\e,F_\e(B)
+       (#x7b5 . ?\e,Fz\e(B)
+       (#x7b6 . ?\e,F@\e(B)
+       (#x7b7 . ?\e,F|\e(B)
+       (#x7b8 . ?\e,F}\e(B)
+       (#x7b9 . ?\e,F{\e(B)
+       (#x7ba . ?\e,F`\e(B)
+       (#x7bb . ?\e,F~\e(B)
+       (#x7c1 . ?\e,FA\e(B)
+       (#x7c2 . ?\e,FB\e(B)
+       (#x7c3 . ?\e,FC\e(B)
+       (#x7c4 . ?\e,FD\e(B)
+       (#x7c5 . ?\e,FE\e(B)
+       (#x7c6 . ?\e,FF\e(B)
+       (#x7c7 . ?\e,FG\e(B)
+       (#x7c8 . ?\e,FH\e(B)
+       (#x7c9 . ?\e,FI\e(B)
+       (#x7ca . ?\e,FJ\e(B)
+       (#x7cb . ?\e,FK\e(B)
+       (#x7cc . ?\e,FL\e(B)
+       (#x7cd . ?\e,FM\e(B)
+       (#x7ce . ?\e,FN\e(B)
+       (#x7cf . ?\e,FO\e(B)
+       (#x7d0 . ?\e,FP\e(B)
+       (#x7d1 . ?\e,FQ\e(B)
+       (#x7d2 . ?\e,FS\e(B)
+       (#x7d4 . ?\e,FT\e(B)
+       (#x7d5 . ?\e,FU\e(B)
+       (#x7d6 . ?\e,FV\e(B)
+       (#x7d7 . ?\e,FW\e(B)
+       (#x7d8 . ?\e,FX\e(B)
+       (#x7d9 . ?\e,FY\e(B)
+       (#x7e1 . ?\e,Fa\e(B)
+       (#x7e2 . ?\e,Fb\e(B)
+       (#x7e3 . ?\e,Fc\e(B)
+       (#x7e4 . ?\e,Fd\e(B)
+       (#x7e5 . ?\e,Fe\e(B)
+       (#x7e6 . ?\e,Ff\e(B)
+       (#x7e7 . ?\e,Fg\e(B)
+       (#x7e8 . ?\e,Fh\e(B)
+       (#x7e9 . ?\e,Fi\e(B)
+       (#x7ea . ?\e,Fj\e(B)
+       (#x7eb . ?\e,Fk\e(B)
+       (#x7ec . ?\e,Fl\e(B)
+       (#x7ed . ?\e,Fm\e(B)
+       (#x7ee . ?\e,Fn\e(B)
+       (#x7ef . ?\e,Fo\e(B)
+       (#x7f0 . ?\e,Fp\e(B)
+       (#x7f1 . ?\e,Fq\e(B)
+       (#x7f2 . ?\e,Fs\e(B)
+       (#x7f3 . ?\e,Fr\e(B)
+       (#x7f4 . ?\e,Ft\e(B)
+       (#x7f5 . ?\e,Fu\e(B)
+       (#x7f6 . ?\e,Fv\e(B)
+       (#x7f7 . ?\e,Fw\e(B)
+       (#x7f8 . ?\e,Fx\e(B)
+       (#x7f9 . ?\e,Fy\e(B)
+        ;; Technical
+       (#x8a1 . ?\e$,1|W\e(B)
+       (#x8a2 . ?\e$,2 ,\e(B)
+       (#x8a3 . ?\e$,2  \e(B)
+       (#x8a4 . ?\e$,1{ \e(B)
+       (#x8a5 . ?\e$,1{!\e(B)
+       (#x8a6 . ?\e$,2 "\e(B)
+       (#x8a7 . ?\e$,1|A\e(B)
+       (#x8a8 . ?\e$,1|C\e(B)
+       (#x8a9 . ?\e$,1|D\e(B)
+       (#x8aa . ?\e$,1|F\e(B)
+       (#x8ab . ?\e$,1|;\e(B)
+       (#x8ac . ?\e$,1|=\e(B)
+       (#x8ad . ?\e$,1|>\e(B)
+       (#x8ae . ?\e$,1|@\e(B)
+       (#x8af . ?\e$,1|H\e(B)
+       (#x8b0 . ?\e$,1|L\e(B)
+       (#x8bc . ?\e$,1y$\e(B)
+       (#x8bd . ?\e$,1y \e(B)
+       (#x8be . ?\e$,1y%\e(B)
+       (#x8bf . ?\e$,1xK\e(B)
+       (#x8c0 . ?\e$,1xT\e(B)
+       (#x8c1 . ?\e$,1x=\e(B)
+       (#x8c2 . ?\e$,1x>\e(B)
+       (#x8c5 . ?\e$,1x'\e(B)
+       (#x8c8 . ?\e$,1x\\e(B)
+       (#x8c9 . ?\e$,1xc\e(B)
+       (#x8cd . ?\e$,1wT\e(B)
+       (#x8ce . ?\e$,1wR\e(B)
+       (#x8cf . ?\e$,1y!\e(B)
+       (#x8d6 . ?\e$,1x:\e(B)
+       (#x8da . ?\e$,1yB\e(B)
+       (#x8db . ?\e$,1yC\e(B)
+       (#x8dc . ?\e$,1xI\e(B)
+       (#x8dd . ?\e$,1xJ\e(B)
+       (#x8de . ?\e$,1xG\e(B)
+       (#x8df . ?\e$,1xH\e(B)
+       (#x8ef . ?\e$,1x"\e(B)
+       (#x8f6 . ?\e$,1!R\e(B)
+       (#x8fb . ?\e$,1vp\e(B)
+       (#x8fc . ?\e$,1vq\e(B)
+       (#x8fd . ?\e$,1vr\e(B)
+       (#x8fe . ?\e$,1vs\e(B)
+       ;; Special
+       (#x9e0 . ?\e$,2"&\e(B)
+       (#x9e1 . ?\e$,2!R\e(B)
+       (#x9e2 . ?\e$,1}I\e(B)
+       (#x9e3 . ?\e$,1}L\e(B)
+       (#x9e4 . ?\e$,1}M\e(B)
+       (#x9e5 . ?\e$,1}J\e(B)
+       (#x9e8 . ?\e$,1}d\e(B)
+       (#x9e9 . ?\e$,1}K\e(B)
+       (#x9ea . ?\e$,2 8\e(B)
+       (#x9eb . ?\e$,2 0\e(B)
+       (#x9ec . ?\e$,2 ,\e(B)
+       (#x9ed . ?\e$,2 4\e(B)
+       (#x9ee . ?\e$,2 \\e(B)
+       (#x9ef . ?\e$,1|Z\e(B)
+       (#x9f0 . ?\e$,1|[\e(B)
+       (#x9f1 . ?\e$,2  \e(B)
+       (#x9f2 . ?\e$,1|\\e(B)
+       (#x9f3 . ?\e$,1|]\e(B)
+       (#x9f4 . ?\e$,2 <\e(B)
+       (#x9f5 . ?\e$,2 D\e(B)
+       (#x9f6 . ?\e$,2 T\e(B)
+       (#x9f7 . ?\e$,2 L\e(B)
+       (#x9f8 . ?\e$,2 "\e(B)
+       ;; Publishing
+       (#xaa1 . ?\e$,1rc\e(B)
+       (#xaa2 . ?\e$,1rb\e(B)
+       (#xaa3 . ?\e$,1rd\e(B)
+       (#xaa4 . ?\e$,1re\e(B)
+       (#xaa5 . ?\e$,1rg\e(B)
+       (#xaa6 . ?\e$,1rh\e(B)
+       (#xaa7 . ?\e$,1ri\e(B)
+       (#xaa8 . ?\e$,1rj\e(B)
+       (#xaa9 . ?\e$,1rt\e(B)
+       (#xaaa . ?\e$,1rs\e(B)
+       (#xaae . ?\e$,1s&\e(B)
+       (#xaaf . ?\e$,1s%\e(B)
+       (#xab0 . ?\e$,1v3\e(B)
+       (#xab1 . ?\e$,1v4\e(B)
+       (#xab2 . ?\e$,1v5\e(B)
+       (#xab3 . ?\e$,1v6\e(B)
+       (#xab4 . ?\e$,1v7\e(B)
+       (#xab5 . ?\e$,1v8\e(B)
+       (#xab6 . ?\e$,1v9\e(B)
+       (#xab7 . ?\e$,1v:\e(B)
+       (#xab8 . ?\e$,1uE\e(B)
+       (#xabb . ?\e$,1rr\e(B)
+       (#xabc . ?\e$,1{)\e(B)
+       (#xabe . ?\e$,1{*\e(B)
+       (#xac3 . ?\e$,1v;\e(B)
+       (#xac4 . ?\e$,1v<\e(B)
+       (#xac5 . ?\e$,1v=\e(B)
+       (#xac6 . ?\e$,1v>\e(B)
+       (#xac9 . ?\e$,1ub\e(B)
+       (#xaca . ?\e$,2"s\e(B)
+       (#xacc . ?\e$,2"!\e(B)
+       (#xacd . ?\e$,2!w\e(B)
+       (#xace . ?\e$,2"+\e(B)
+       (#xacf . ?\e$,2!o\e(B)
+       (#xad0 . ?\e$,1rx\e(B)
+       (#xad1 . ?\e$,1ry\e(B)
+       (#xad2 . ?\e$,1r|\e(B)
+       (#xad3 . ?\e$,1r}\e(B)
+       (#xad4 . ?\e$,1u^\e(B)
+       (#xad6 . ?\e$,1s2\e(B)
+       (#xad7 . ?\e$,1s3\e(B)
+       (#xad9 . ?\e$,2%]\e(B)
+       (#xadb . ?\e$,2!l\e(B)
+       (#xadc . ?\e$,2" \e(B)
+       (#xadd . ?\e$,2!v\e(B)
+       (#xade . ?\e$,2"/\e(B)
+       (#xadf . ?\e$,2!n\e(B)
+       (#xae0 . ?\e$,2"F\e(B)
+       (#xae1 . ?\e$,2!k\e(B)
+       (#xae2 . ?\e$,2!m\e(B)
+       (#xae3 . ?\e$,2!s\e(B)
+       (#xae4 . ?\e$,2!}\e(B)
+       (#xae5 . ?\e$,2"f\e(B)
+       (#xae6 . ?\e$,1s"\e(B)
+       (#xae7 . ?\e$,2!j\e(B)
+       (#xae8 . ?\e$,2!r\e(B)
+       (#xae9 . ?\e$,2!|\e(B)
+       (#xaea . ?\e$,2"|\e(B)
+       (#xaeb . ?\e$,2"~\e(B)
+       (#xaec . ?\e$,2#c\e(B)
+       (#xaed . ?\e$,2#f\e(B)
+       (#xaee . ?\e$,2#e\e(B)
+       (#xaf0 . ?\e$,2%`\e(B)
+       (#xaf1 . ?\e$,1s \e(B)
+       (#xaf2 . ?\e$,1s!\e(B)
+       (#xaf3 . ?\e$,2%S\e(B)
+       (#xaf4 . ?\e$,2%W\e(B)
+       (#xaf5 . ?\e$,2#o\e(B)
+       (#xaf6 . ?\e$,2#m\e(B)
+       (#xaf7 . ?\e$,2#B\e(B)
+       (#xaf8 . ?\e$,2#@\e(B)
+       (#xaf9 . ?\e$,2"n\e(B)
+       (#xafa . ?\e$,1zu\e(B)
+       (#xafb . ?\e$,1uW\e(B)
+       (#xafc . ?\e$,1s8\e(B)
+       (#xafd . ?\e$,1rz\e(B)
+       (#xafe . ?\e$,1r~\e(B)
+       ;; APL
+       (#xba3 . ?<)
+       (#xba6 . ?>)
+       (#xba8 . ?\e$,1xH\e(B)
+       (#xba9 . ?\e$,1xG\e(B)
+       (#xbc0 . ?\e,A/\e(B)
+       (#xbc2 . ?\e$,1ye\e(B)
+       (#xbc3 . ?\e$,1xI\e(B)
+       (#xbc4 . ?\e$,1zj\e(B)
+       (#xbc6 . ?_)
+       (#xbca . ?\e$,1x8\e(B)
+       (#xbcc . ?\e$,1|5\e(B)
+       (#xbce . ?\e$,1yd\e(B)
+       (#xbcf . ?\e$,2"+\e(B)
+       (#xbd3 . ?\e$,1zh\e(B)
+       (#xbd6 . ?\e$,1xJ\e(B)
+       (#xbd8 . ?\e$,1yC\e(B)
+       (#xbda . ?\e$,1yB\e(B)
+       (#xbdc . ?\e$,1yb\e(B)
+       (#xbfc . ?\e$,1yc\e(B)
+       ;; Hebrew
+       (#xcdf . ?\e,H_\e(B)
+       (#xce0 . ?\e,H`\e(B)
+       (#xce1 . ?\e,Ha\e(B)
+       (#xce2 . ?\e,Hb\e(B)
+       (#xce3 . ?\e,Hc\e(B)
+       (#xce4 . ?\e,Hd\e(B)
+       (#xce5 . ?\e,He\e(B)
+       (#xce6 . ?\e,Hf\e(B)
+       (#xce7 . ?\e,Hg\e(B)
+       (#xce8 . ?\e,Hh\e(B)
+       (#xce9 . ?\e,Hi\e(B)
+       (#xcea . ?\e,Hj\e(B)
+       (#xceb . ?\e,Hk\e(B)
+       (#xcec . ?\e,Hl\e(B)
+       (#xced . ?\e,Hm\e(B)
+       (#xcee . ?\e,Hn\e(B)
+       (#xcef . ?\e,Ho\e(B)
+       (#xcf0 . ?\e,Hp\e(B)
+       (#xcf1 . ?\e,Hq\e(B)
+       (#xcf2 . ?\e,Hr\e(B)
+       (#xcf3 . ?\e,Hs\e(B)
+       (#xcf4 . ?\e,Ht\e(B)
+       (#xcf5 . ?\e,Hu\e(B)
+       (#xcf6 . ?\e,Hv\e(B)
+       (#xcf7 . ?\e,Hw\e(B)
+       (#xcf8 . ?\e,Hx\e(B)
+       (#xcf9 . ?\e,Hy\e(B)
+       (#xcfa . ?\e,Hz\e(B)
+       ;; Thai
+       (#xda1 . ?\e,T!\e(B)
+       (#xda2 . ?\e,T"\e(B)
+       (#xda3 . ?\e,T#\e(B)
+       (#xda4 . ?\e,T$\e(B)
+       (#xda5 . ?\e,T%\e(B)
+       (#xda6 . ?\e,T&\e(B)
+       (#xda7 . ?\e,T'\e(B)
+       (#xda8 . ?\e,T(\e(B)
+       (#xda9 . ?\e,T)\e(B)
+       (#xdaa . ?\e,T*\e(B)
+       (#xdab . ?\e,T+\e(B)
+       (#xdac . ?\e,T,\e(B)
+       (#xdad . ?\e,T-\e(B)
+       (#xdae . ?\e,T.\e(B)
+       (#xdaf . ?\e,T/\e(B)
+       (#xdb0 . ?\e,T0\e(B)
+       (#xdb1 . ?\e,T1\e(B)
+       (#xdb2 . ?\e,T2\e(B)
+       (#xdb3 . ?\e,T3\e(B)
+       (#xdb4 . ?\e,T4\e(B)
+       (#xdb5 . ?\e,T5\e(B)
+       (#xdb6 . ?\e,T6\e(B)
+       (#xdb7 . ?\e,T7\e(B)
+       (#xdb8 . ?\e,T8\e(B)
+       (#xdb9 . ?\e,T9\e(B)
+       (#xdba . ?\e,T:\e(B)
+       (#xdbb . ?\e,T;\e(B)
+       (#xdbc . ?\e,T<\e(B)
+       (#xdbd . ?\e,T=\e(B)
+       (#xdbe . ?\e,T>\e(B)
+       (#xdbf . ?\e,T?\e(B)
+       (#xdc0 . ?\e,T@\e(B)
+       (#xdc1 . ?\e,TA\e(B)
+       (#xdc2 . ?\e,TB\e(B)
+       (#xdc3 . ?\e,TC\e(B)
+       (#xdc4 . ?\e,TD\e(B)
+       (#xdc5 . ?\e,TE\e(B)
+       (#xdc6 . ?\e,TF\e(B)
+       (#xdc7 . ?\e,TG\e(B)
+       (#xdc8 . ?\e,TH\e(B)
+       (#xdc9 . ?\e,TI\e(B)
+       (#xdca . ?\e,TJ\e(B)
+       (#xdcb . ?\e,TK\e(B)
+       (#xdcc . ?\e,TL\e(B)
+       (#xdcd . ?\e,TM\e(B)
+       (#xdce . ?\e,TN\e(B)
+       (#xdcf . ?\e,TO\e(B)
+       (#xdd0 . ?\e,TP\e(B)
+       (#xdd1 . ?\e,TQ\e(B)
+       (#xdd2 . ?\e,TR\e(B)
+       (#xdd3 . ?\e,TS\e(B)
+       (#xdd4 . ?\e,TT\e(B)
+       (#xdd5 . ?\e,TU\e(B)
+       (#xdd6 . ?\e,TV\e(B)
+       (#xdd7 . ?\e,TW\e(B)
+       (#xdd8 . ?\e,TX\e(B)
+       (#xdd9 . ?\e,TY\e(B)
+       (#xdda . ?\e,TZ\e(B)
+       (#xddf . ?\e,T_\e(B)
+       (#xde0 . ?\e,T`\e(B)
+       (#xde1 . ?\e,Ta\e(B)
+       (#xde2 . ?\e,Tb\e(B)
+       (#xde3 . ?\e,Tc\e(B)
+       (#xde4 . ?\e,Td\e(B)
+       (#xde5 . ?\e,Te\e(B)
+       (#xde6 . ?\e,Tf\e(B)
+       (#xde7 . ?\e,Tg\e(B)
+       (#xde8 . ?\e,Th\e(B)
+       (#xde9 . ?\e,Ti\e(B)
+       (#xdea . ?\e,Tj\e(B)
+       (#xdeb . ?\e,Tk\e(B)
+       (#xdec . ?\e,Tl\e(B)
+       (#xded . ?\e,Tm\e(B)
+       (#xdf0 . ?\e,Tp\e(B)
+       (#xdf1 . ?\e,Tq\e(B)
+       (#xdf2 . ?\e,Tr\e(B)
+       (#xdf3 . ?\e,Ts\e(B)
+       (#xdf4 . ?\e,Tt\e(B)
+       (#xdf5 . ?\e,Tu\e(B)
+       (#xdf6 . ?\e,Tv\e(B)
+       (#xdf7 . ?\e,Tw\e(B)
+       (#xdf8 . ?\e,Tx\e(B)
+       (#xdf9 . ?\e,Ty\e(B)
+       ;; Korean
+       (#xea1 . ?\e$(C$!\e(B)
+       (#xea2 . ?\e$(C$"\e(B)
+       (#xea3 . ?\e$(C$#\e(B)
+       (#xea4 . ?\e$(C$$\e(B)
+       (#xea5 . ?\e$(C$%\e(B)
+       (#xea6 . ?\e$(C$&\e(B)
+       (#xea7 . ?\e$(C$'\e(B)
+       (#xea8 . ?\e$(C$(\e(B)
+       (#xea9 . ?\e$(C$)\e(B)
+       (#xeaa . ?\e$(C$*\e(B)
+       (#xeab . ?\e$(C$+\e(B)
+       (#xeac . ?\e$(C$,\e(B)
+       (#xead . ?\e$(C$-\e(B)
+       (#xeae . ?\e$(C$.\e(B)
+       (#xeaf . ?\e$(C$/\e(B)
+       (#xeb0 . ?\e$(C$0\e(B)
+       (#xeb1 . ?\e$(C$1\e(B)
+       (#xeb2 . ?\e$(C$2\e(B)
+       (#xeb3 . ?\e$(C$3\e(B)
+       (#xeb4 . ?\e$(C$4\e(B)
+       (#xeb5 . ?\e$(C$5\e(B)
+       (#xeb6 . ?\e$(C$6\e(B)
+       (#xeb7 . ?\e$(C$7\e(B)
+       (#xeb8 . ?\e$(C$8\e(B)
+       (#xeb9 . ?\e$(C$9\e(B)
+       (#xeba . ?\e$(C$:\e(B)
+       (#xebb . ?\e$(C$;\e(B)
+       (#xebc . ?\e$(C$<\e(B)
+       (#xebd . ?\e$(C$=\e(B)
+       (#xebe . ?\e$(C$>\e(B)
+       (#xebf . ?\e$(C$?\e(B)
+       (#xec0 . ?\e$(C$@\e(B)
+       (#xec1 . ?\e$(C$A\e(B)
+       (#xec2 . ?\e$(C$B\e(B)
+       (#xec3 . ?\e$(C$C\e(B)
+       (#xec4 . ?\e$(C$D\e(B)
+       (#xec5 . ?\e$(C$E\e(B)
+       (#xec6 . ?\e$(C$F\e(B)
+       (#xec7 . ?\e$(C$G\e(B)
+       (#xec8 . ?\e$(C$H\e(B)
+       (#xec9 . ?\e$(C$I\e(B)
+       (#xeca . ?\e$(C$J\e(B)
+       (#xecb . ?\e$(C$K\e(B)
+       (#xecc . ?\e$(C$L\e(B)
+       (#xecd . ?\e$(C$M\e(B)
+       (#xece . ?\e$(C$N\e(B)
+       (#xecf . ?\e$(C$O\e(B)
+       (#xed0 . ?\e$(C$P\e(B)
+       (#xed1 . ?\e$(C$Q\e(B)
+       (#xed2 . ?\e$(C$R\e(B)
+       (#xed3 . ?\e$(C$S\e(B)
+       (#xed4 . ?\e$,1LH\e(B)
+       (#xed5 . ?\e$,1LI\e(B)
+       (#xed6 . ?\e$,1LJ\e(B)
+       (#xed7 . ?\e$,1LK\e(B)
+       (#xed8 . ?\e$,1LL\e(B)
+       (#xed9 . ?\e$,1LM\e(B)
+       (#xeda . ?\e$,1LN\e(B)
+       (#xedb . ?\e$,1LO\e(B)
+       (#xedc . ?\e$,1LP\e(B)
+       (#xedd . ?\e$,1LQ\e(B)
+       (#xede . ?\e$,1LR\e(B)
+       (#xedf . ?\e$,1LS\e(B)
+       (#xee0 . ?\e$,1LT\e(B)
+       (#xee1 . ?\e$,1LU\e(B)
+       (#xee2 . ?\e$,1LV\e(B)
+       (#xee3 . ?\e$,1LW\e(B)
+       (#xee4 . ?\e$,1LX\e(B)
+       (#xee5 . ?\e$,1LY\e(B)
+       (#xee6 . ?\e$,1LZ\e(B)
+       (#xee7 . ?\e$,1L[\e(B)
+       (#xee8 . ?\e$,1L\\e(B)
+       (#xee9 . ?\e$,1L]\e(B)
+       (#xeea . ?\e$,1L^\e(B)
+       (#xeeb . ?\e$,1L_\e(B)
+       (#xeec . ?\e$,1L`\e(B)
+       (#xeed . ?\e$,1La\e(B)
+       (#xeee . ?\e$,1Lb\e(B)
+       (#xeef . ?\e$(C$]\e(B)
+       (#xef0 . ?\e$(C$a\e(B)
+       (#xef1 . ?\e$(C$h\e(B)
+       (#xef2 . ?\e$(C$o\e(B)
+       (#xef3 . ?\e$(C$q\e(B)
+       (#xef4 . ?\e$(C$t\e(B)
+       (#xef5 . ?\e$(C$v\e(B)
+       (#xef6 . ?\e$(C$}\e(B)
+       (#xef7 . ?\e$(C$~\e(B)
+       (#xef8 . ?\e$,1M+\e(B)
+       (#xef9 . ?\e$,1M0\e(B)
+       (#xefa . ?\e$,1M9\e(B)
+       (#xeff . ?\e$,1tI\e(B)
+       ;; Latin-5
+       ;; Latin-6
+       ;; Latin-7
+       ;; Latin-8
+       ;; Latin-9
+       (#x13bc . ?\e,b<\e(B)
+       (#x13bd . ?\e,b=\e(B)
+       (#x13be . ?\e,b>\e(B)
+       ;; Currency
+       (#x20a0 . ?\e$,1t@\e(B)
+       (#x20a1 . ?\e$,1tA\e(B)
+       (#x20a2 . ?\e$,1tB\e(B)
+       (#x20a3 . ?\e$,1tC\e(B)
+       (#x20a4 . ?\e$,1tD\e(B)
+       (#x20a5 . ?\e$,1tE\e(B)
+       (#x20a6 . ?\e$,1tF\e(B)
+       (#x20a7 . ?\e$,1tG\e(B)
+       (#x20a8 . ?\e$,1tH\e(B)
+       (#x20aa . ?\e$,1tJ\e(B)
+       (#x20ab . ?\e$,1tK\e(B)
+       (#x20ac . ?\e,b$\e(B)))
+  (puthash (car pair) (cdr pair) x-keysym-table))
+
+;; The following keysym codes for graphics are listed in the document
+;; as not having unicodes available:
+
+;; #x08b1      TOP LEFT SUMMATION      Technical
+;; #x08b2      BOTTOM LEFT SUMMATION   Technical
+;; #x08b3      TOP VERTICAL SUMMATION CONNECTOR        Technical
+;; #x08b4      BOTTOM VERTICAL SUMMATION CONNECTOR     Technical
+;; #x08b5      TOP RIGHT SUMMATION     Technical
+;; #x08b6      BOTTOM RIGHT SUMMATION  Technical
+;; #x08b7      RIGHT MIDDLE SUMMATION  Technical
+;; #x0aac      SIGNIFICANT BLANK SYMBOL        Publish
+;; #x0abd      DECIMAL POINT   Publish
+;; #x0abf      MARKER  Publish
+;; #x0acb      TRADEMARK SIGN IN CIRCLE        Publish
+;; #x0ada      HEXAGRAM        Publish
+;; #x0aff      CURSOR  Publish
+;; #x0dde      THAI MAIHANAKAT Thai
+
 \f
 ;;;; Selections and cut buffers
 
-;;; We keep track of the last text selected here, so we can check the
-;;; current selection against it, and avoid passing back our own text
-;;; from x-cut-buffer-or-selection-value.
-(defvar x-last-selected-text nil)
+;; We keep track of the last text selected here, so we can check the
+;; current selection against it, and avoid passing back our own text
+;; from x-cut-buffer-or-selection-value.  We track all three
+;; seperately in case another X application only sets one of them
+;; (say the cut buffer) we aren't fooled by the PRIMARY or
+;; CLIPBOARD selection staying the same.
+(defvar x-last-selected-text-clipboard nil
+  "The value of the CLIPBOARD X selection last time we selected or
+pasted text.")
+(defvar x-last-selected-text-primary nil
+  "The value of the PRIMARY X selection last time we selected or
+pasted text.")
+(defvar x-last-selected-text-cut nil
+  "The value of the X cut buffer last time we selected or pasted text.
+The actual text stored in the X cut buffer is what encoded from this value.")
+(defvar x-last-selected-text-cut-encoded nil
+  "The value of the X cut buffer last time we selected or pasted text.
+This is the actual text stored in the X cut buffer.")
 
-;;; It is said that overlarge strings are slow to put into the cut buffer.
-;;; Note this value is overridden below.
-(defvar x-cut-buffer-max 20000
-  "Max number of characters to put in the cut buffer.")
+(defvar x-cut-buffer-max 20000 ; Note this value is overridden below.
+  "Max number of characters to put in the cut buffer.
+It is said that overlarge strings are slow to put into the cut buffer.")
 
 (defcustom x-select-enable-clipboard nil
   "Non-nil means cutting and pasting uses the clipboard.
@@ -1190,72 +2149,239 @@ This is in addition to, but in preference to, the primary selection."
   :type 'boolean
   :group 'killing)
 
-;;; Make TEXT, a string, the primary X selection.
-;;; Also, set the value of X cut buffer 0, for backward compatibility
-;;; with older X applications.
-;;; gildea@stop.mail-abuse.org says it's not desirable to put kills
-;;; in the clipboard.
 (defun x-select-text (text &optional push)
+  "Make TEXT, a string, the primary X selection.
+Also, set the value of X cut buffer 0, for backward compatibility
+with older X applications.
+gildea@stop.mail-abuse.org says it's not desirable to put kills
+in the clipboard."
   ;; Don't send the cut buffer too much text.
   ;; It becomes slow, and if really big it causes errors.
-  (if (< (length text) x-cut-buffer-max)
-      (x-set-cut-buffer text push)
-    (x-set-cut-buffer "" push))
+  (cond ((>= (length text) x-cut-buffer-max)
+        (x-set-cut-buffer "" push)
+        (setq x-last-selected-text-cut ""
+              x-last-selected-text-cut-encoded ""))
+       (t
+        (setq x-last-selected-text-cut text
+              x-last-selected-text-cut-encoded
+              ;; ICCCM says cut buffer always contain ISO-Latin-1
+              (encode-coding-string text 'iso-latin-1))
+        (x-set-cut-buffer x-last-selected-text-cut-encoded push)))
   (x-set-selection 'PRIMARY text)
-  (if x-select-enable-clipboard
-      (x-set-selection 'CLIPBOARD text))
-  (setq x-last-selected-text text))
-
-;;; Return the value of the current X selection.
-;;; Consult the selection, then the cut buffer.  Treat empty strings
-;;; as if they were unset.
-;;; If this function is called twice and finds the same text,
-;;; it returns nil the second time.  This is so that a single
-;;; selection won't be added to the kill ring over and over.
-(defun x-cut-buffer-or-selection-value ()
+  (setq x-last-selected-text-primary text)
+  (when x-select-enable-clipboard
+    (x-set-selection 'CLIPBOARD text)
+    (setq x-last-selected-text-clipboard text))
+  )
+
+(defvar x-select-request-type nil
+  "*Data type request for X selection.
+The value is nil, one of the following data types, or a list of them:
+  `COMPOUND_TEXT', `UTF8_STRING', `STRING', `TEXT'
+
+If the value is nil, try `COMPOUND_TEXT' and `UTF8_STRING', and
+use the more appropriate result.  If both fail, try `STRING', and
+then `TEXT'.
+
+If the value is one of the above symbols, try only the specified
+type.
+
+If the value is a list of them, try each of them in the specified
+order until succeed.")
+
+;; Helper function for x-selection-value.  Select UTF8 or CTEXT
+;; whichever is more appropriate.  Here, we use this heurisitcs.
+;;
+;;   (1) If their lengthes are different, select the longer one.  This
+;;   is because an X client may just cut off unsupported characters.
+;;
+;;   (2) Otherwise, if the Nth character of CTEXT is an ASCII
+;;   character that is different from the Nth character of UTF8,
+;;   select UTF8.  This is because an X client may replace unsupported
+;;   characters with some ASCII character (typically ` ' or `?') in
+;;   CTEXT.
+;;
+;;   (3) Otherwise, select CTEXT.  This is because legacy charsets are
+;;   better for the current Emacs, especially when the selection owner
+;;   is also Emacs.
+
+(defun x-select-utf8-or-ctext (utf8 ctext)
+  (let ((len-utf8 (length utf8))
+       (len-ctext (length ctext))
+       (selected ctext)
+       (i 0)
+       char)
+    (if (/= len-utf8 len-ctext)
+       (if (> len-utf8 len-ctext) utf8 ctext)
+      (let ((result (compare-strings utf8 0 len-utf8 ctext 0 len-ctext)))
+       (if (or (eq result t)
+               (>= (aref ctext (1- (abs result))) 128))
+           ctext
+         utf8)))))
+
+;; Get a selection value of type TYPE by calling x-get-selection with
+;; an appropiate DATA-TYPE argument decidd by `x-select-request-type'.
+;; The return value is already decoded.  If x-get-selection causes an
+;; error, this function return nil.
+
+(defun x-selection-value (type)
   (let (text)
+    (cond ((null x-select-request-type)
+          (let (utf8 ctext utf8-coding)
+            ;; We try both UTF8_STRING and COMPOUND_TEXT, and choose
+            ;; the more appropriate one.  If both fail, try STRING.
+
+            ;; At first try UTF8_STRING.
+            (setq utf8 (condition-case nil
+                           (x-get-selection type 'UTF8_STRING)
+                         (error nil))
+                  utf8-coding last-coding-system-used)
+            (if utf8
+                ;; If it is a local selection, or it contains only
+                ;; ASCII characers, choose it.
+                (if (or (not (get-text-property 0 'foreign-selection utf8))
+                        (= (length utf8) (string-bytes utf8)))
+                    (setq text utf8)))
+            ;; If not yet decided, try COMPOUND_TEXT.
+            (if (not text)
+                (if (setq ctext (condition-case nil
+                                    (x-get-selection type 'COMPOUND_TEXT)
+                                  (error nil)))
+                    ;; If UTF8_STRING was also successful, choose the
+                    ;; more appropriate one from UTF8 and CTEXT.
+                    (if utf8
+                        (setq text (x-select-utf8-or-ctext utf8 ctext))
+                      ;; Othewise, choose CTEXT.
+                      (setq text ctext))
+                  (setq text utf8)))
+            ;; If not yet decided, try STRING.
+            (or text
+                (setq text (condition-case nil
+                               (x-get-selection type 'STRING)
+                             (error nil))))
+            (if (eq text utf8)
+                (setq last-coding-system-used utf8-coding))))
+
+         ((consp x-select-request-type)
+          (let ((tail x-select-request-type))
+            (while (and tail (not text))
+              (condition-case nil
+                  (setq text (x-get-selection type (car tail)))
+                (error nil))
+              (setq tail (cdr tail)))))
+
+         (t
+          (condition-case nil
+              (setq text (x-get-selection type x-select-request-type))
+            (error nil))))
+
+    (if text
+       (remove-text-properties 0 (length text) '(foreign-selection nil) text))
+    text))
+
+;; Return the value of the current X selection.
+;; Consult the selection, and the cut buffer.  Treat empty strings
+;; as if they were unset.
+;; If this function is called twice and finds the same text,
+;; it returns nil the second time.  This is so that a single
+;; selection won't be added to the kill ring over and over.
+(defun x-cut-buffer-or-selection-value ()
+  (let (clip-text primary-text cut-text)
     (when x-select-enable-clipboard
-      (if (null text) 
-         (condition-case c
-             (setq text (x-get-selection 'CLIPBOARD 'COMPOUND_TEXT))
-           (error nil)))
-      (if (null text) 
-         (condition-case c
-             (setq text (x-get-selection 'CLIPBOARD 'STRING))
-           (error nil)))
-      (if (string= text "") (setq text nil)))
-
-    ;; Don't die if x-get-selection signals an error.
-    (if (null text) 
-       (condition-case c
-           (setq text (x-get-selection 'PRIMARY 'COMPOUND_TEXT))
-         (error nil)))
-    (if (null text) 
-       (condition-case c
-           (setq text (x-get-selection 'PRIMARY 'STRING))
-         (error nil)))
-    (if (string= text "") (setq text nil))
-
-    (or text (setq text (x-get-cut-buffer 0)))
-    (if (string= text "") (setq text nil))
-
-    (cond
-     ((not text) nil)
-     ((eq text x-last-selected-text) nil)
-     ((string= text x-last-selected-text)
-      ;; Record the newer string, so subsequent calls can use the `eq' test.
-      (setq x-last-selected-text text)
-      nil)
-     (t
-      (setq x-last-selected-text text)))))
+      (setq clip-text (x-selection-value 'CLIPBOARD))
+      (if (string= clip-text "") (setq clip-text nil))
+
+      ;; Check the CLIPBOARD selection for 'newness', is it different
+      ;; from what we remebered them to be last time we did a
+      ;; cut/paste operation.
+      (setq clip-text
+           (cond;; check clipboard
+            ((or (not clip-text) (string= clip-text ""))
+             (setq x-last-selected-text-clipboard nil))
+            ((eq      clip-text x-last-selected-text-clipboard) nil)
+            ((string= clip-text x-last-selected-text-clipboard)
+             ;; Record the newer string,
+             ;; so subsequent calls can use the `eq' test.
+             (setq x-last-selected-text-clipboard clip-text)
+             nil)
+            (t
+             (setq x-last-selected-text-clipboard clip-text))))
+      )
+
+    (setq primary-text (x-selection-value 'PRIMARY))
+    ;; Check the PRIMARY selection for 'newness', is it different
+    ;; from what we remebered them to be last time we did a
+    ;; cut/paste operation.
+    (setq primary-text
+         (cond;; check primary selection
+          ((or (not primary-text) (string= primary-text ""))
+           (setq x-last-selected-text-primary nil))
+          ((eq      primary-text x-last-selected-text-primary) nil)
+          ((string= primary-text x-last-selected-text-primary)
+           ;; Record the newer string,
+           ;; so subsequent calls can use the `eq' test.
+           (setq x-last-selected-text-primary primary-text)
+           nil)
+          (t
+           (setq x-last-selected-text-primary primary-text))))
+
+    (setq cut-text (x-get-cut-buffer 0))
+
+    ;; Check the x cut buffer for 'newness', is it different
+    ;; from what we remebered them to be last time we did a
+    ;; cut/paste operation.
+    (setq cut-text
+         (cond;; check cut buffer
+          ((or (not cut-text) (string= cut-text ""))
+           (setq x-last-selected-text-cut nil))
+          ;; This short cut doesn't work because x-get-cut-buffer
+          ;; always returns a newly created string.
+          ;; ((eq      cut-text x-last-selected-text-cut) nil)
+          ((string= cut-text x-last-selected-text-cut-encoded)
+           ;; See the comment above.  No need of this recording.
+           ;; Record the newer string,
+           ;; so subsequent calls can use the `eq' test.
+           ;; (setq x-last-selected-text-cut cut-text)
+           nil)
+          (t
+           (setq x-last-selected-text-cut-encoded cut-text
+                 x-last-selected-text-cut
+                 ;; ICCCM says cut buffer always contain ISO-Latin-1
+                 (decode-coding-string cut-text 'iso-latin-1)))))
+
+    ;; As we have done one selection, clear this now.
+    (setq next-selection-coding-system nil)
+
+    ;; At this point we have recorded the current values for the
+    ;; selection from clipboard (if we are supposed to) primary,
+    ;; and cut buffer.  So return the first one that has changed
+    ;; (which is the first non-null one).
+    ;;
+    ;; NOTE: There will be cases where more than one of these has
+    ;; changed and the new values differ.  This indicates that
+    ;; something like the following has happened since the last time
+    ;; we looked at the selections: Application X set all the
+    ;; selections, then Application Y set only one or two of them (say
+    ;; just the cut-buffer).  In this case since we don't have
+    ;; timestamps there is no way to know what the 'correct' value to
+    ;; return is.  The nice thing to do would be to tell the user we
+    ;; saw multiple possible selections and ask the user which was the
+    ;; one they wanted.
+    ;; This code is still a big improvement because now the user can
+    ;; futz with the current selection and get emacs to pay attention
+    ;; to the cut buffer again (previously as soon as clipboard or
+    ;; primary had been set the cut buffer would essentially never be
+    ;; checked again).
+    (or clip-text primary-text cut-text)
+    ))
 
 \f
-;;; Do the actual X Windows setup here; the above code just defines
-;;; functions and variables that we use now.
+;; Do the actual X Windows setup here; the above code just defines
+;; functions and variables that we use now.
 
 (setq command-line-args (x-handle-args command-line-args))
 
-;;; Make sure we have a valid resource name.
+;; Make sure we have a valid resource name.
 (or (stringp x-resource-name)
     (let (i)
       (setq x-resource-name (invocation-name))
@@ -1265,61 +2391,47 @@ This is in addition to, but in preference to, the primary selection."
       (while (setq i (string-match "[.*]" x-resource-name))
        (aset x-resource-name i ?-))))
 
-;; For the benefit of older Emacses (19.27 and earlier) that are sharing
-;; the same lisp directory, don't pass the third argument unless we seem
-;; to have the multi-display support.
-(if (fboundp 'x-close-connection)
-    (x-open-connection (or x-display-name
-                          (setq x-display-name (getenv "DISPLAY")))
-                      x-command-line-resources
-                      ;; Exit Emacs with fatal error if this fails.
-                      t)
-  (x-open-connection (or x-display-name
-                        (setq x-display-name (getenv "DISPLAY")))
-                    x-command-line-resources))
+(x-open-connection (or x-display-name
+                      (setq x-display-name (getenv "DISPLAY")))
+                  x-command-line-resources
+                  ;; Exit Emacs with fatal error if this fails.
+                  t)
 
 (setq frame-creation-function 'x-create-frame-with-faces)
 
 (setq x-cut-buffer-max (min (- (/ (x-server-max-request-size) 2) 100)
                            x-cut-buffer-max))
 
-(if (fboundp 'new-fontset)
-    (progn
-      ;; Create the standard fontset.
-      (create-fontset-from-fontset-spec standard-fontset-spec t)
-
-      ;; Create fontset specified in X resources "Fontset-N" (N is 0, 1, ...).
-      (create-fontset-from-x-resource)
-
-      ;; Try to create a fontset from a font specification which comes
-      ;; from initial-frame-alist, default-frame-alist, or X resource.
-      ;; A font specification in command line argument (i.e. -fn XXXX)
-      ;; should be already in default-frame-alist as a `font'
-      ;; parameter.  However, any font specifications in site-start
-      ;; library, user's init file (.emacs), and default.el are not
-      ;; yet handled here.
-
-      (let ((font (or (cdr (assq 'font initial-frame-alist))
-                     (cdr (assq 'font default-frame-alist))
-                     (x-get-resource "font" "Font")))
-           xlfd-fields resolved-name)
-       (if (and font
-                (not (query-fontset font))
-                (setq resolved-name (x-resolve-font-name font))
-                (setq xlfd-fields (x-decompose-font-name font)))
-           (if (string= "fontset"
-                        (aref xlfd-fields xlfd-regexp-registry-subnum))
-               (new-fontset font (x-complement-fontset-spec xlfd-fields nil))
-             ;; Create a fontset from FONT.  The fontset name is
-             ;; generated from FONT.
-             (create-fontset-from-ascii-font font
-                                             resolved-name "startup"))))))
-
-;; Sun expects the menu bar cut and paste commands to use the clipboard.
-;; This has ,? to match both on Sunos and on Solaris.
-(if (string-match "Sun Microsystems,? Inc\\."
-                 (x-server-vendor))
-    (menu-bar-enable-clipboard))
+;; Setup the default fontset.
+(setup-default-fontset)
+
+;; Create the standard fontset.
+(create-fontset-from-fontset-spec standard-fontset-spec t)
+
+;; Create fontset specified in X resources "Fontset-N" (N is 0, 1, ...).
+(create-fontset-from-x-resource)
+
+;; Try to create a fontset from a font specification which comes
+;; from initial-frame-alist, default-frame-alist, or X resource.
+;; A font specification in command line argument (i.e. -fn XXXX)
+;; should be already in default-frame-alist as a `font'
+;; parameter.  However, any font specifications in site-start
+;; library, user's init file (.emacs), and default.el are not
+;; yet handled here.
+
+(let ((font (or (cdr (assq 'font initial-frame-alist))
+               (cdr (assq 'font default-frame-alist))
+               (x-get-resource "font" "Font")))
+      xlfd-fields resolved-name)
+  (if (and font
+          (not (query-fontset font))
+          (setq resolved-name (x-resolve-font-name font))
+          (setq xlfd-fields (x-decompose-font-name font)))
+      (if (string= "fontset" (aref xlfd-fields xlfd-regexp-registry-subnum))
+         (new-fontset font (x-complement-fontset-spec xlfd-fields nil))
+       ;; Create a fontset from FONT.  The fontset name is
+       ;; generated from FONT.
+       (create-fontset-from-ascii-font font resolved-name "startup"))))
 
 ;; Apply a geometry resource to the initial frame.  Put it at the end
 ;; of the alist, so that anything specified on the command line takes
@@ -1336,12 +2448,15 @@ This is in addition to, but in preference to, the primary selection."
                               (cons '(user-size . t) parsed))))
        ;; All geometry parms apply to the initial frame.
        (setq initial-frame-alist (append initial-frame-alist parsed))
-       ;; The size parms apply to all frames.
-       (if (assq 'height parsed)
+       ;; The size parms apply to all frames.  Don't set it if there are
+       ;; sizes there already (from command line).
+       (if (and (assq 'height parsed)
+                (not (assq 'height default-frame-alist)))
            (setq default-frame-alist
                  (cons (cons 'height (cdr (assq 'height parsed)))
                        default-frame-alist)))
-       (if (assq 'width parsed)
+       (if (and (assq 'width parsed)
+                (not (assq 'width default-frame-alist)))
            (setq default-frame-alist
                  (cons (cons 'width (cdr (assq 'width parsed)))
                        default-frame-alist))))))
@@ -1362,25 +2477,62 @@ This is in addition to, but in preference to, the primary selection."
       (setq x-selection-timeout (string-to-number res-selection-timeout))))
 
 (defun x-win-suspend-error ()
-  (error "Suspending an emacs running under X makes no sense"))
+  (error "Suspending an Emacs running under X makes no sense"))
 (add-hook 'suspend-hook 'x-win-suspend-error)
 
-;;; Arrange for the kill and yank functions to set and check the clipboard.
+;; Arrange for the kill and yank functions to set and check the clipboard.
 (setq interprogram-cut-function 'x-select-text)
 (setq interprogram-paste-function 'x-cut-buffer-or-selection-value)
 
-;;; Turn off window-splitting optimization; X is usually fast enough
-;;; that this is only annoying.
+;; Turn off window-splitting optimization; X is usually fast enough
+;; that this is only annoying.
 (setq split-window-keep-point t)
 
 ;; Don't show the frame name; that's redundant with X.
 (setq-default mode-line-frame-identification "  ")
 
-;;; Motif direct handling of f10 wasn't working right,
-;;; So temporarily we've turned it off in lwlib-Xm.c
-;;; and turned the Emacs f10 back on.
-;;; ;; Motif normally handles f10 itself, so don't try to handle it a second time.
-;;; (if (featurep 'motif)
-;;;     (global-set-key [f10] 'ignore))
+;; Motif direct handling of f10 wasn't working right,
+;; So temporarily we've turned it off in lwlib-Xm.c
+;; and turned the Emacs f10 back on.
+;; ;; Motif normally handles f10 itself, so don't try to handle it a second time.
+;; (if (featurep 'motif)
+;;     (global-set-key [f10] 'ignore))
+
+;; Turn on support for mouse wheels.
+(mouse-wheel-mode 1)
+
+
+;; Enable CLIPBOARD copy/paste through menu bar commands.
+(menu-bar-enable-clipboard)
+
+;; Override Paste so it looks at CLIPBOARD first.
+(defun x-clipboard-yank ()
+  "Insert the clipboard contents, or the last stretch of killed text."
+  (interactive "*")
+  (let ((clipboard-text (x-selection-value 'CLIPBOARD))
+       (x-select-enable-clipboard t))
+    (if (and clipboard-text (> (length clipboard-text) 0))
+       (kill-new clipboard-text))
+    (yank)))
+
+(define-key menu-bar-edit-menu [paste]
+  '(menu-item "Paste" x-clipboard-yank
+             :enable (not buffer-read-only)
+             :help "Paste (yank) text most recently cut/copied"))
+
+;; Initiate drag and drop
+(add-hook 'after-make-frame-functions 'x-dnd-init-frame)
+(define-key special-event-map [drag-n-drop] 'x-dnd-handle-drag-n-drop-event)
+
+;; Let F10 do menu bar navigation.
+(defun x-menu-bar-open (&optional frame)
+  "Open the menu bar if `menu-bar-mode' is on. otherwise call `tmm-menubar'."
+  (interactive "i")
+  (if menu-bar-mode (menu-bar-open frame)
+    (tmm-menubar)))
+                  
+(and (fboundp 'menu-bar-open)
+     (global-set-key [f10] 'x-menu-bar-open))
 
+;; arch-tag: f1501302-db8b-4d95-88e3-116697d89f78
 ;;; x-win.el ends here