/[emacs]/emacs/lisp/international/ucs-tables.el
ViewVC logotype

Diff of /emacs/lisp/international/ucs-tables.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.17 by monnier, Thu Sep 19 04:58:46 2002 UTC revision 1.18 by handa, Mon Sep 30 06:38:13 2002 UTC
# Line 48  Line 48 
48  ;; all that users normally care about unifying although, for instance,  ;; all that users normally care about unifying although, for instance,
49  ;; Greek occurs in as many as nine Emacs charsets.  ;; Greek occurs in as many as nine Emacs charsets.
50    
51  ;; The translation table `ucs-mule-to-mule-unicode' is populated,  ;; The translation-table `utf-translation-table-for-encode' is
52  ;; which could be used for more general unification on decoding.  This  ;; populated, which could be used for more general unification on
53  ;; is used by the `mule-utf-8' coding system to encode extra  ;; decoding.  This is used by the `mule-utf-8' coding system to encode
54  ;; characters, and also by the coding systems set up by code-pages.el.  ;; extra characters, and also by the coding systems set up by
55  ;; The decoding tables here take account of  ;; code-pages.el.  The decoding tables here take account of
56  ;; `utf-8-fragment-on-decoding' which may specify decoding Greek and  ;; `utf-fragment-on-decoding' which may specify decoding Greek and
57  ;; Cyrillic into 8859 charsets.  ;; Cyrillic into 8859 charsets.
58    
59  ;; Unification also puts a `translation-table-for-input' property on  ;; Unification also puts a `translation-table-for-input' property on
# Line 89  Line 89 
89  ;;; Define tables, to be populated later.  ;;; Define tables, to be populated later.
90    
91  (defvar ucs-mule-8859-to-ucs-table (make-translation-table)  (defvar ucs-mule-8859-to-ucs-table (make-translation-table)
92    "Translation table from Emacs ISO-8859 characters to Unicode.    "Char table from Emacs ISO-8859 characters to Unicode.
93  This maps Emacs characters from the non-Latin-1  This maps Emacs characters from the non-Latin-1
94  ...-iso8859-... charsets to their Unicode code points.  This is a  ...-iso8859-... charsets to their Unicode code points.  This is a
95  many-to-one mapping.")  many-to-one mapping.")
96    
97  (defvar ucs-mule-8859-to-mule-unicode (make-translation-table)  (defvar ucs-mule-8859-to-mule-unicode (make-translation-table)
98    "Translation table from Emacs ISO-8859 characters to Mule Unicode.    "Char table from Emacs ISO-8859 characters to Mule Unicode.
99  This maps Emacs characters from the non-Latin-1  This maps Emacs characters from the non-Latin-1
100  ...-iso8859-... charsets to characters from the  ...-iso8859-... charsets to characters from the
101  mule-unicode-... charsets.  This is a many-to-one mapping.  The  mule-unicode-... charsets.  This is a many-to-one mapping.  The
# Line 157  Translates from the iso8859 charsets and Line 157  Translates from the iso8859 charsets and
157    "Used as `translation-table-for-encode' for iso-8859-15.    "Used as `translation-table-for-encode' for iso-8859-15.
158  Translates from the iso8859 charsets and `mule-unicode-0100-24ff'.")  Translates from the iso8859 charsets and `mule-unicode-0100-24ff'.")
159    
160    (defvar translation-table-for-input (make-translation-table))
161    
162  ;;; Set up the tables.  ;;; Set up the tables.
163    
164  ;; Most of these tables were derived from ones in Mule-UCS.  ;; Most of these tables were derived from ones in Mule-UCS.
# Line 1097  Translates from the iso8859 charsets and Line 1099  Translates from the iso8859 charsets and
1099             (setq i (1+ i)))             (setq i (1+ i)))
1100           (nreverse l))))           (nreverse l))))
1101    
1102      ;; Note: Here, using decode-char is safe because
1103      ;; utf-fragment-on-decoding is by default nil, thus the translation
1104      ;; table `utf-translation-table-for-decode' does nothing.
1105    
1106    ;; Convert the lists to the basic char tables.    ;; Convert the lists to the basic char tables.
1107    ;; Ensure `decode-char' doesn't use the fragmentation table.    (dolist (n (list 15 14 9 8 7 5 4 3 2 1))
1108    ;; Fixme: handa suggests using the RESTRICTION arg.      (let ((alist (symbol-value (intern (format "ucs-8859-%d-alist" n)))))
1109    (let ((utf-8-translation-table-for-decode (make-translation-table)))        (dolist (pair alist)
1110      (dolist (n (list 15 14 9 8 7 5 4 3 2 1))          (let ((mule (car pair))
1111        (let ((alist (symbol-value (intern (format "ucs-8859-%d-alist" n)))))                (uc (cdr pair))
1112          (dolist (pair alist)                (mu (decode-char 'ucs (cdr pair))))
1113            (let ((mule (car pair))            (aset ucs-mule-8859-to-ucs-table mule uc)
1114                  (uc (cdr pair))            ;;      (aset ucs-ucs-to-mule-8859-table uc mule)
1115                  (mu (decode-char 'ucs (cdr pair))))            ;;      (aset ucs-mule-unicode-to-mule-8859 mu mule)
1116              (aset ucs-mule-8859-to-ucs-table mule uc)            (aset ucs-mule-8859-to-mule-unicode mule mu)
1117              ;;    (aset ucs-ucs-to-mule-8859-table uc mule)            (aset ucs-mule-to-mule-unicode mule mu)))))
1118              ;;    (aset ucs-mule-unicode-to-mule-8859 mu mule)  
1119              (aset ucs-mule-8859-to-mule-unicode mule mu)    ;; Derive tables that can be used as per-coding-system
1120              (aset ucs-mule-to-mule-unicode mule mu)))))    ;; `translation-table-for-encode's.
1121      ;; Derive tables that can be used as per-coding-system    (dolist (n (list 15 14 9 8 7 5 4 3 2 1))
1122      ;; `translation-table-for-encode's.      (let* ((alist (symbol-value (intern (format "ucs-8859-%d-alist" n))))
1123      (dolist (n (list 15 14 9 8 7 5 4 3 2 1))             (encode-translator (set (intern (format "ucs-8859-%d-encode-table"
1124        (let* ((alist (symbol-value (intern (format "ucs-8859-%d-alist" n))))                                                     n))
1125               (encode-translator (set (intern (format "ucs-8859-%d-encode-table"                                     (make-translation-table)))
1126                                                       n))             (coding-system
1127                                       (make-translation-table)))              (coding-system-base (intern (format "iso-8859-%d" n))))
1128               elt)             (dependency (coding-system-get coding-system 'dependency))
1129          ;; Start with the mule-unicode component.             elt)
1130          (dolist (pair alist)        ;; Start with the mule-unicode component (except for latin-iso8859-1).
1131            (let ((mule (car pair))        (if (/= n 1)
1132                  (mu (decode-char 'ucs (cdr pair))))            (dolist (pair alist)
1133              (aset encode-translator mu mule)))              (let ((mule (car pair))
1134          ;; Find characters from other 8859 sets which map to the same                    (mu (decode-char 'ucs (cdr pair))))
1135          ;; unicode as some character in this set.                (aset encode-translator mu mule))))
1136          (map-char-table (lambda (k v)        ;; Find characters from other 8859 sets which map to the same
1137                            (if (and (setq elt (rassq v alist))        ;; unicode as some character in this set.
1138                                     (not (assq k alist)))        (map-char-table (lambda (k v)
1139                                (aset encode-translator k (car elt))))                          (if (and (setq elt (rassq v alist))
1140                          ucs-mule-8859-to-ucs-table)                                   (not (assq k alist)))
1141          (optimize-char-table encode-translator)))))                              (aset encode-translator k (car elt))))
1142                          ucs-mule-8859-to-ucs-table)
1143  ;; Register for use in CCL.        (optimize-char-table encode-translator)
1144  (define-translation-table 'ucs-mule-8859-to-mule-unicode  
1145    ucs-mule-8859-to-mule-unicode)        (or (memq 'unify-8859-on-encoding-mode dependency)
1146  (define-translation-table 'ucs-mule-to-mule-unicode            (setq dependency (cons 'unify-8859-on-encoding-mode dependency)))
1147    ucs-mule-to-mule-unicode)        (or (memq 'unify-8859-on-decoding-mode dependency)
1148              (setq dependency (cons 'unify-8859-on-decoding-mode dependency)))
1149          (coding-system-put coding-system 'dependency dependency))))
1150    
1151  (defun ucs-unify-8859 (&optional encode-only)  (defun ucs-unify-8859 (for-encode for-decode)
1152    "Set up translation tables for unifying characters from ISO 8859.    "Set up translation-tables for unifying characters from ISO 8859.
1153    
1154  On decoding, non-ASCII characters are mapped into the `iso-latin-1'  On decoding, non-ASCII characters are mapped into the `iso-latin-1'
1155  and `mule-unicode-0100-24ff' charsets.  On encoding, these are mapped  and `mule-unicode-0100-24ff' charsets.  On encoding, these are mapped
# Line 1149  back appropriate for the coding system. Line 1157  back appropriate for the coding system.
1157    
1158  With prefix arg, do unification on encoding only, i.e. don't unify  With prefix arg, do unification on encoding only, i.e. don't unify
1159  everything on input operations."  everything on input operations."
1160    (interactive "P")    (when for-decode
   (unless encode-only  
1161      ;; Unify 8859 on decoding.  (Non-CCL coding systems only.)      ;; Unify 8859 on decoding.  (Non-CCL coding systems only.)
1162      (if utf-8-fragment-on-decoding      (if utf-fragment-on-decoding
1163          (progn (map-char-table          (progn (map-char-table
1164                  (lambda (k v)                  (lambda (k v)
1165                    (if v (aset ucs-mule-to-mule-unicode v nil)))                    (if v (aset ucs-mule-8859-to-mule-unicode v nil)))
1166                  utf-8-translation-table-for-decode)                  utf-fragmentation-table)
1167                 (optimize-char-table ucs-mule-to-mule-unicode))                 (optimize-char-table ucs-mule-8859-to-mule-unicode))
1168        ;; Reset in case it was changed.        ;; Reset in case it was changed.
1169        (map-char-table        (map-char-table
1170         (lambda (k v)         (lambda (k v)
1171           (if v (aset ucs-mule-to-mule-unicode v k)))           (if v (aset ucs-mule-8859-to-mule-unicode v k)))
1172         utf-8-translation-table-for-decode))         utf-fragmentation-table))
1173    
1174        ;; For non-CCL coding systems (e.g. iso-latin-2).
1175      (set-char-table-parent standard-translation-table-for-decode      (set-char-table-parent standard-translation-table-for-decode
1176                             ucs-mule-8859-to-mule-unicode)                             ucs-mule-8859-to-mule-unicode)
1177        ;; For CCL coding systems other than mule-utf-*
1178        (define-translation-table 'ucs-translation-table-for-decode
1179          ucs-mule-8859-to-mule-unicode)
1180    
1181      ;; Translate Quail input globally.      ;; Translate Quail input globally.
1182      (setq-default translation-table-for-input ucs-mule-to-mule-unicode)      (setq-default translation-table-for-input ucs-mule-to-mule-unicode)
1183      ;; In case these are set up, but we should use the global      ;; In case these are set up, but we should use the global
1184      ;; translation table.      ;; translation-table.
1185      (remove-hook 'quail-activate-hook 'ucs-quail-activate)      (remove-hook 'quail-activate-hook 'ucs-quail-activate)
1186      (remove-hook 'minibuffer-setup-hook 'ucs-minibuffer-setup))      (remove-hook 'minibuffer-setup-hook 'ucs-minibuffer-setup))
   ;; Adjust the 8859 coding systems to fragment the unified characters  
   ;; on encoding.  
   (dolist (n '(1 2 3 4 5 7 8 9 14 15))  
     (let* ((coding-system  
             (coding-system-base (intern (format "iso-8859-%d" n))))  
            (table (symbol-value  
                    (intern (format "ucs-8859-%d-encode-table" n))))  
            (safe (coding-system-get coding-system 'safe-chars)))  
       ;; Actually, the coding system's safe-chars are not normally  
       ;; used after they've been registered, but we might as well  
       ;; record them.  Setting the parent here is a convenience.  
       (set-char-table-parent safe table)  
       ;; Update the table of what encodes to what.  
       (register-char-codings coding-system table)  
       (coding-system-put coding-system 'translation-table-for-encode table)  
       (coding-system-put coding-system 'translation-table-for-input table)))  
   ;; Arrange local translation tables for Quail input.  
   (add-hook 'quail-activate-hook 'ucs-quail-activate)  
   (add-hook 'minibuffer-setup-hook 'ucs-minibuffer-setup))  
1187    
1188  (defun ucs-fragment-8859 (&optional encode-only)    (when for-encode
1189        ;; Make mule-utf-* encode all characters in ucs-mule-to-mule-unicode.
1190        (let ((coding-list '(mule-utf-8 mule-utf-16-be mule-utf-16-le)))
1191          (define-translation-table 'utf-translation-table-for-encode
1192            ucs-mule-to-mule-unicode)
1193          (dolist (coding coding-list)
1194            (set-char-table-parent (coding-system-get coding 'safe-chars)
1195                                   ucs-mule-to-mule-unicode)
1196            (register-char-codings coding ucs-mule-to-mule-unicode)))
1197    
1198        ;; Adjust the 8859 coding systems to fragment the unified characters
1199        ;; on encoding.
1200        (dolist (n '(1 2 3 4 5 7 8 9 14 15))
1201          (let* ((coding-system
1202                  (coding-system-base (intern (format "iso-8859-%d" n))))
1203                 (table (symbol-value
1204                         (intern (format "ucs-8859-%d-encode-table" n))))
1205                 (safe (coding-system-get coding-system 'safe-chars)))
1206            ;; Actually, the coding system's safe-chars are not normally
1207            ;; used after they've been registered, but we might as well
1208            ;; record them.  Setting the parent here is a convenience.
1209            (set-char-table-parent safe table)
1210            ;; Update the table of what encodes to what.
1211            (register-char-codings coding-system table)
1212            (coding-system-put coding-system 'translation-table-for-encode table)
1213            (coding-system-put coding-system 'translation-table-for-input table)))
1214        ;; Arrange local translation-tables for Quail input.
1215        (add-hook 'quail-activate-hook 'ucs-quail-activate)
1216        (add-hook 'minibuffer-setup-hook 'ucs-minibuffer-setup)))
1217    
1218    (defun ucs-fragment-8859 (for-encode for-decode)
1219    "Undo the unification done by `ucs-unify-8859'.    "Undo the unification done by `ucs-unify-8859'.
1220  With prefix arg, undo unification on encoding only, i.e. don't undo  With prefix arg, undo unification on encoding only, i.e. don't undo
1221  unification on input operations."  unification on input operations."
1222    (interactive "P")    (when for-decode
1223    ;; Maybe fix decoding.      ;; Don't Unify 8859 on decoding.
1224    (unless encode-only      ;; For non-CCL coding systems (e.g. iso-latin-2).
     ;; Unify 8859 on decoding.  (Non-CCL coding systems only.)  
1225      (set-char-table-parent standard-translation-table-for-decode nil)      (set-char-table-parent standard-translation-table-for-decode nil)
1226        ;; For CCL coding systems other than mule-utf-* (e.g. cyrillic-koi8).
1227        (define-translation-table 'ucs-translation-table-for-decode)
1228        ;; For Quail input.
1229      (setq-default translation-table-for-input nil))      (setq-default translation-table-for-input nil))
1230    ;; Fix encoding.  For each charset, remove the entries in  
1231    ;; `char-coding-system-table' added to its safe-chars table (as its    (when for-encode
1232    ;; parent).      ;; Make mule-utf-* disabled for all characters in
1233    (dolist (n '(1 2 3 4 5 7 8 9 14 15))      ;; ucs-mule-to-mule-unicode but what originally supported and what
1234      (let* ((coding-system      ;; translated bt utf-translation-table-for-decode when
1235              (coding-system-base (intern (format "iso-8859-%d" n))))      ;; `utf-fragment-on-decoding' is non-nil.
1236             (table (symbol-value      (let ((coding-list '(mule-utf-8 mule-utf-16-be mule-utf-16-le))
1237                     (intern (format "ucs-8859-%d-encode-table" n))))            (safe (coding-system-get 'mule-utf-8 'safe-chars)))
1238             (safe (coding-system-get coding-system 'safe-chars)))        (dolist (coding coding-list)
1239            (set-char-table-parent (coding-system-get coding 'safe-chars) nil))
1240          ;; Here we assume that all mule-utf-* have the same character
1241          ;; repertory, thus we can use SAFE for all of them.
1242        (map-char-table        (map-char-table
1243         (lambda (key val)         (lambda (key val)
1244           (if (and (>= key 128) val)           (if (and (>= key 128) val
1245               (let ((codings (aref char-coding-system-table key)))                    (not (aref safe key)))
1246                 (aset char-coding-system-table key               (aset char-coding-system-table key
1247                       (delq coding-system codings)))))                     (delq 'mule-utf-8
1248         (char-table-parent safe))                           (delq 'mule-utf-16-le
1249        (set-char-table-parent safe nil)                                 (delq 'mule-utf-16-be
1250        (coding-system-put coding-system 'translation-table-for-encode nil)                                       (aref char-coding-system-table key)))))))
1251        (coding-system-put coding-system 'translation-table-for-input nil)))         ucs-mule-to-mule-unicode)
1252    (optimize-char-table char-coding-system-table)      
1253    (remove-hook 'quail-activate-hook 'ucs-quail-activate)        (if (not utf-fragment-on-decoding)
1254    (remove-hook 'minibuffer-setup-hook 'ucs-minibuffer-setup))            (define-translation-table 'utf-translation-table-for-encode)
1255            (define-translation-table 'utf-translation-table-for-encode
1256  (define-minor-mode unify-8859-on-encoding-mode            utf-defragmentation-table)
1257    "Set up translation tables for unifying ISO 8859 characters on encoding.          (dolist (coding coding-list)
1258              (register-char-codings coding utf-defragmentation-table))))
1259  The ISO 8859 characters sets overlap, e.g. 8859-1 (Latin-1) and  
1260  8859-15 (Latin-9) differ only in a few characters.  Emacs normally      ;; For each charset, remove the entries in
1261  distinguishes equivalent characters from those ISO-8859 character sets      ;; `char-coding-system-table' added to its safe-chars table (as
1262  which are built in to Emacs.  This behaviour is essentially inherited      ;; its parent).
1263  from the European-originated international standards.  Treating them      (dolist (n '(1 2 3 4 5 7 8 9 14 15))
1264  equivalently, by translating to and from a single representation is        (let* ((coding-system
1265  called `unification'.  (The `utf-8' coding system treats the                (coding-system-base (intern (format "iso-8859-%d" n))))
1266  characters of European scripts in a unified manner.)               (table (symbol-value
1267                         (intern (format "ucs-8859-%d-encode-table" n))))
1268  In this mode, on encoding -- i.e. output operations -- non-ASCII               (safe (coding-system-get coding-system 'safe-chars)))
1269  characters from the built-in ISO 8859 and `mule-unicode-0100-24ff'          (when (char-table-parent safe)
1270  charsets are handled automatically by the coding system used if it can            (map-char-table
1271  represent them.  Thus, say, an e-acute from the Latin-1 charset (the             (lambda (key val)
1272  unified representation) in a buffer saved as Latin-9 will be encoded               (if (and (>= key 128) val)
1273  directly to a byte value 233.  By default, in contrast, you would be                   (let ((codings (aref char-coding-system-table key)))
1274  prompted for a general coding system to use for saving the file, which                     (aset char-coding-system-table key
1275  can cope with separate Latin-1 and Latin-9 representations of e-acute.                           (delq coding-system codings)))))
1276               (char-table-parent safe))
1277  Also sets hooks that arrange `translation-table-for-input' to be set            (set-char-table-parent safe nil))
1278  up locally when Quail input methods are activated.  This will often          (coding-system-put coding-system 'translation-table-for-encode nil)
1279  allow input generated by Quail input methods to conform with what the          (coding-system-put coding-system 'translation-table-for-input nil)))
1280  buffer's file coding system can encode.  Thus you could use a Latin-2      (optimize-char-table char-coding-system-table)
1281  input method to search for e-acute in a Latin-1 buffer.      (remove-hook 'quail-activate-hook 'ucs-quail-activate)
1282        (remove-hook 'minibuffer-setup-hook 'ucs-minibuffer-setup)))
 See also command `unify-8859-on-decoding-mode'."  
   :group 'mule  
   :global t  
   :init-value t  
   (if unify-8859-on-encoding-mode  
       (ucs-unify-8859 t)  
     (ucs-fragment-8859 t)))  
   
 (custom-add-version 'unify-8859-on-encoding-mode "21.4")  
   
 (define-minor-mode unify-8859-on-decoding-mode  
   "Set up translation tables for unifying ISO 8859 characters on decoding.  
 On decoding, i.e. input operations, non-ASCII characters from the  
 built-in ISO 8859 charsets are unified by mapping them into the  
 `iso-latin-1' and `mule-unicode-0100-24ff' charsets.  
   
 Also sets `translation-table-for-input' globally, so that Quail input  
 methods produce unified characters.  
   
 See also command `unify-8859-on-encoding-mode' and the user option  
 `utf-8-fragment-on-decoding'."  
   :group 'mule  
   :global t  
   :init-value nil  
   (if unify-8859-on-decoding-mode  
       (ucs-unify-8859)  
     (ucs-fragment-8859)))  
   
 (custom-add-dependencies 'unify-8859-on-decoding-mode  
                          '(utf-8-fragment-on-decoding))  
 (custom-add-version 'unify-8859-on-decoding-mode "21.4")  
1283    
1284  (defun ucs-insert (arg)  (defun ucs-insert (arg)
1285    "Insert the Emacs character representation of the given Unicode.    "Insert the Emacs character representation of the given Unicode.
# Line 2456  Interactively, prompts for a hex string Line 2454  Interactively, prompts for a hex string
2454                ((memq cs '(lao thai-tis620 tibetan-iso-8bit))                ((memq cs '(lao thai-tis620 tibetan-iso-8bit))
2455                 (coding-system-put cs 'translation-table-for-input cs)))))                 (coding-system-put cs 'translation-table-for-input cs)))))
2456      (dolist (c safe-charsets)      (dolist (c safe-charsets)
2457        (aset table (make-char c) t))        (aset table (make-char c) t))))
     (coding-system-put 'mule-utf-8 'safe-charsets  
                        (append (coding-system-get 'mule-utf-8 'safe-charsets)  
                                safe-charsets))  
     (register-char-codings 'mule-utf-8 table)))  
2458    
2459  (defvar translation-table-for-input (make-translation-table))  (define-minor-mode unify-8859-on-encoding-mode
2460      "Set up translation-tables for unifying ISO 8859 characters on encoding.
2461    
2462    The ISO 8859 characters sets overlap, e.g. 8859-1 (Latin-1) and
2463    8859-15 (Latin-9) differ only in a few characters.  Emacs normally
2464    distinguishes equivalent characters from those ISO-8859 character sets
2465    which are built in to Emacs.  This behaviour is essentially inherited
2466    from the European-originated international standards.  Treating them
2467    equivalently, by translating to and from a single representation is
2468    called `unification'.  (The `utf-8' coding system treats the
2469    characters of European scripts in a unified manner.)
2470    
2471    In this mode, on encoding -- i.e. output operations -- non-ASCII
2472    characters from the built-in ISO 8859 and `mule-unicode-0100-24ff'
2473    charsets are handled automatically by the coding system used if it can
2474    represent them.  Thus, say, an e-acute from the Latin-1 charset (the
2475    unified representation) in a buffer saved as Latin-9 will be encoded
2476    directly to a byte value 233.  By default, in contrast, you would be
2477    prompted for a general coding system to use for saving the file, which
2478    can cope with separate Latin-1 and Latin-9 representations of e-acute.
2479    
2480  ;; Arrange to set up the translation table for Quail.  This probably  Also sets hooks that arrange `translation-table-for-input' to be set
2481    up locally when Quail input methods are activated.  This will often
2482    allow input generated by Quail input methods to conform with what the
2483    buffer's file coding system can encode.  Thus you could use a Latin-2
2484    input method to search for e-acute in a Latin-1 buffer.
2485    
2486    See also command `unify-8859-on-decoding-mode'."
2487      :group 'mule
2488      :global t
2489      :init-value t
2490      (if unify-8859-on-encoding-mode
2491          (ucs-unify-8859 t nil)
2492        (ucs-fragment-8859 t nil)))
2493    
2494    (custom-add-version 'unify-8859-on-encoding-mode "21.3")
2495    
2496    (define-minor-mode unify-8859-on-decoding-mode
2497      "Set up translation-tables for unifying ISO 8859 characters on decoding.
2498    On decoding, i.e. input operations, non-ASCII characters from the
2499    built-in ISO 8859 charsets are unified by mapping them into the
2500    `iso-latin-1' and `mule-unicode-0100-24ff' charsets.
2501    
2502    Also sets `translation-table-for-input' globally, so that Quail input
2503    methods produce unified characters.
2504    
2505    See also command `unify-8859-on-encoding-mode' and the user option
2506    `utf-fragment-on-decoding'."
2507      :group 'mule
2508      :global t
2509      :init-value nil
2510      (if unify-8859-on-decoding-mode
2511          (ucs-unify-8859 nil t)
2512        (ucs-fragment-8859 nil t)))
2513    
2514    (custom-add-version 'unify-8859-on-decoding-mode "21.3")
2515    
2516    ;; Synchronize the status with the initial value of
2517    ;; unify-8859-on-encoding-mode and unify-8859-on-decoding-mode.
2518    (ucs-unify-8859 t nil)
2519    
2520    ;; Arrange to set up the translation-table for Quail.  This probably
2521  ;; isn't foolproof.  ;; isn't foolproof.
2522  (defun ucs-quail-activate ()  (defun ucs-quail-activate ()
2523    "Set up an appropriate `translation-table-for-input' for current buffer.    "Set up an appropriate `translation-table-for-input' for current buffer.
# Line 2489  Intended to be added to `minibuffer-setu Line 2542  Intended to be added to `minibuffer-setu
2542                                  (cadr (buffer-list))))                                  (cadr (buffer-list))))
2543           buffer-file-coding-system)))           buffer-file-coding-system)))
2544    
 ;; Modified to allow display of arbitrary characters with an  
 ;; iso-10646-encoded (`Unicode') font.  
 (define-ccl-program ccl-encode-unicode-font  
   `(0  
     ((if (r0 == ,(charset-id 'ascii))  
          ((r2 = r1)  
           (r1 = 0))  
        (  
         ;; Look for a translation for non-ASCII chars.  For a 2D  
         ;; charset, produce a single code for the translation.  
         ;; Official 2D sets are in the charset id range [#x90,#x99],  
         ;; private ones in the range [#xf0,#xfe] (with #xff not used).  
         ;; Fixme: Is there a better way to do this?  
         (r3 = (r0 >= #x90))  
         (r3 &= (r0 <= #x99))  
         (r3 |= (r0 >= #xf0))  
         (if r3                          ; 2D input  
             (r1 = ((r1 << 7) | r2)))  
         (translate-character ucs-mule-to-mule-unicode r0 r1)  
         (r3 = (r0 >= #x90))  
         (r3 &= (r0 <= #x99))  
         (r3 |= (r0 >= #xf0))  
         (if r3                          ; 2D translation  
             ((r2 = (r1 & 127))  
              (r1 = (r1 >> 7))))  
         (if (r0 == ,(charset-id 'latin-iso8859-1))  
             ((r2 = (r1 + 128))  
              (r1 = 0))  
           (if (r0 == ,(charset-id 'mule-unicode-0100-24ff))  
               ((r1 *= 96)  
                (r1 += r2)  
                (r1 += ,(- #x100 (* 32 96) 32))  
                (r1 >8= 0)  
                (r2 = r7))  
             (if (r0 == ,(charset-id 'mule-unicode-2500-33ff))  
                 ((r1 *= 96)  
                  (r1 += r2)  
                  (r1 += ,(- #x2500 (* 32 96) 32))  
                  (r1 >8= 0)  
                  (r2 = r7))  
               (if (r0 == ,(charset-id 'mule-unicode-e000-ffff))  
                   ((r1 *= 96)  
                    (r1 += r2)  
                    (r1 += ,(- #xe000 (* 32 96) 32))  
                    (r1 >8= 0)  
                    (r2 = r7))))))))))  
   "Encode characters for display with iso10646 font.  
 Translate through table `ucs-mule-to-mule-unicode' initially.")  
   
 (defalias 'ucs-tables-unload-hook 'ucs-fragment-8859)  
   
2545  (provide 'ucs-tables)  (provide 'ucs-tables)
2546    
2547  ;;; ucs-tables.el ends here  ;;; ucs-tables.el ends here

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.18

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26