comparison lisp/international/characters.el @ 103629:e9716d0e04ea

(cjk-char-width-table): Delete it. (cjk-char-width-table-list): New variable. (use-cjk-char-width-table): New arg local-name. (use-default-char-width-table): Fix for the case that Emacs is already using the default char-width-table.
author Kenichi Handa <handa@m17n.org>
date Tue, 30 Jun 2009 01:51:08 +0000
parents fdad8647e9ec
children 68c7ccee0204
comparison
equal deleted inserted replaced
103628:0aaf0f10bc11 103629:e9716d0e04ea
1026 'indian-2-column) 1026 'indian-2-column)
1027 (map-charset-chars 1027 (map-charset-chars
1028 (lambda (range ignore) (set-char-table-range char-width-table range 2)) 1028 (lambda (range ignore) (set-char-table-range char-width-table range 2))
1029 'arabic-2-column) 1029 'arabic-2-column)
1030 1030
1031 (defvar cjk-char-width-table 1031 ;; Internal use only.
1032 (let ((table (make-char-table nil))) 1032 ;; Alist of locale symbol vs charsets. In a language environment
1033 (dolist (charset '(big5 chinese-gb2312 chinese-cns11643-1 1033 ;; corresponding to the locale, width of characters in the charsets is
1034 japanese-jisx0208 cp932-2-byte korean-ksc5601)) 1034 ;; set to 2. Each element has the form:
1035 (map-charset-chars #'(lambda (range arg) 1035 ;; (LOCALE TABLE (CHARSET (FROM-CODE . TO-CODE) ...) ...)
1036 (set-char-table-range table range 2)) 1036 ;; LOCALE: locale symbol
1037 charset)) 1037 ;; TABLE: char-table used for char-width-table, initially nil.
1038 (optimize-char-table table) 1038 ;; CAHRSET: character set
1039 (set-char-table-parent table char-width-table) 1039 ;; FROM-CODE, TO-CODE: range of code-points in CHARSET
1040 table) 1040
1041 "Character width table used in CJK language environment.") 1041 (defvar cjk-char-width-table-list
1042 1042 '((ja_JP nil (japanese-jisx0208 (#x2121 . #x287E))
1043 (defun use-cjk-char-width-table () 1043 (cp932-2-byte (#x8140 . #x879F)))
1044 "Internal use only. 1044 (zh_CN nil (chinese-gb2312 (#x2121 . #x297E)))
1045 Setup char-width-table appropriate for CJK language environment." 1045 (zh_HK nil (big5-hkscs (#xA140 . #xA3FE) (#xC6A0 . #xC8FE)))
1046 (setq char-width-table cjk-char-width-table)) 1046 (zh_TW nil (big5 (#xA140 . #xA3FE))
1047 (chinese-cns11643-1 (#x2121 . #x427E)))
1048 (ko_KR nil (korean-ksc5601 (#x2121 . #x2C7E)))))
1049
1050 ;; Internal use only.
1051 ;; Setup char-width-table appropriate for a language environment
1052 ;; corresponding to LOCALE-NAME (symbol).
1053
1054 (defun use-cjk-char-width-table (locale-name)
1055 (while (char-table-parent char-width-table)
1056 (setq char-width-table (char-table-parent char-width-table)))
1057 (let ((slot (assq locale-name cjk-char-width-table-list))
1058 table)
1059 (or slot (error "Unknown locale for CJK language environment: %s"
1060 locale-name))
1061 (unless (nth 1 slot)
1062 (let ((table (make-char-table nil)))
1063 (dolist (charset-info (nthcdr 2 slot))
1064 (let ((charset (car charset-info)))
1065 (dolist (code-range (cdr charset-info))
1066 (map-charset-chars #'(lambda (range arg)
1067 (set-char-table-range table range 2))
1068 charset nil
1069 (car code-range) (cdr code-range)))))
1070 (optimize-char-table table)
1071 (set-char-table-parent table char-width-table)
1072 (setcar (cdr slot) table)))
1073 (setq char-width-table (nth 1 slot))))
1047 1074
1048 (defun use-default-char-width-table () 1075 (defun use-default-char-width-table ()
1049 "Internal use only. 1076 "Internal use only.
1050 Setup char-width-table appropriate for non-CJK language environment." 1077 Setup char-width-table appropriate for non-CJK language environment."
1051 (setq char-width-table (char-table-parent cjk-char-width-table))) 1078 (while (char-table-parent char-width-table)
1079 (setq char-width-table (char-table-parent char-width-table))))
1052 1080
1053 (optimize-char-table (standard-case-table)) 1081 (optimize-char-table (standard-case-table))
1054 (optimize-char-table (standard-syntax-table)) 1082 (optimize-char-table (standard-syntax-table))
1055 1083
1056 1084