diff options
| author | Kenichi Handa | 2003-11-17 03:57:03 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2003-11-17 03:57:03 +0000 |
| commit | 6d2b6635c8ce3af204d2be86e4f9f12c89ed9feb (patch) | |
| tree | 77ae45a87fe3d00d89b0420368b7b6decf94c506 | |
| parent | a925ac43865a490d0f2f4a5d3918d6446276d127 (diff) | |
| download | emacs-6d2b6635c8ce3af204d2be86e4f9f12c89ed9feb.tar.gz emacs-6d2b6635c8ce3af204d2be86e4f9f12c89ed9feb.zip | |
(private-char-area-1-min)
(private-char-area-1-max, private-char-area-2-min)
(private-char-area-2-max, emacs-mule-charset-table): New
variables.
(convert-define-charset-argument): New function.
(define-charset): Handle the old calling style. Update
emacs-mule-charset-table.
(make-char-internal): New function.
| -rw-r--r-- | lisp/international/mule.el | 81 |
1 files changed, 74 insertions, 7 deletions
diff --git a/lisp/international/mule.el b/lisp/international/mule.el index cf1d26d2d52..143f3342879 100644 --- a/lisp/international/mule.el +++ b/lisp/international/mule.el | |||
| @@ -36,15 +36,58 @@ Version number and name of this version of MULE (multilingual environment).") | |||
| 36 | (defconst mule-version-date "2003.9.1" "\ | 36 | (defconst mule-version-date "2003.9.1" "\ |
| 37 | Distribution date of this version of MULE (multilingual environment).") | 37 | Distribution date of this version of MULE (multilingual environment).") |
| 38 | 38 | ||
| 39 | |||
| 40 | |||
| 41 | ;;; CHARACTER | ||
| 42 | (defalias 'char-valid-p 'characterp) | ||
| 43 | (make-obsolete 'char-valid-p 'characterp "22.1") | ||
| 44 | |||
| 45 | 39 | ||
| 46 | ;;; CHARSET | 40 | ;;; CHARSET |
| 47 | 41 | ||
| 42 | ;; Backward compatibility code for handling emacs-mule charsets. | ||
| 43 | (defvar private-char-area-1-min #xF0000) | ||
| 44 | (defvar private-char-area-1-max #xFFFFE) | ||
| 45 | (defvar private-char-area-2-min #x100000) | ||
| 46 | (defvar private-char-area-2-max #x10FFFE) | ||
| 47 | |||
| 48 | ;; Table of emacs-mule charsets indexed by their emacs-mule ID. | ||
| 49 | (defvar emacs-mule-charset-table (make-vector 256 nil)) | ||
| 50 | (aset emacs-mule-charset-table 0 'ascii) | ||
| 51 | |||
| 52 | ;; Convert the argument of old-style calll of define-charset to a | ||
| 53 | ;; property list used by the new-style. | ||
| 54 | ;; INFO-VECTOR is a vector of the format: | ||
| 55 | ;; [DIMENSION CHARS WIDTH DIRECTION ISO-FINAL-CHAR ISO-GRAPHIC-PLANE | ||
| 56 | ;; SHORT-NAME LONG-NAME DESCRIPTION] | ||
| 57 | |||
| 58 | (defun convert-define-charset-argument (emacs-mule-id info-vector) | ||
| 59 | (let* ((dim (aref info-vector 0)) | ||
| 60 | (chars (aref info-vector 1)) | ||
| 61 | (total (if (= dim 1) chars (* chars chars))) | ||
| 62 | (code-space (if (= dim 1) (if (= chars 96) [32 127] [33 126]) | ||
| 63 | (if (= chars 96) [32 127 32 127] [33 126 33 126]))) | ||
| 64 | code-offset) | ||
| 65 | (if (integerp emacs-mule-id) | ||
| 66 | (or (= emacs-mule-id 0) | ||
| 67 | (and (>= emacs-mule-id 129) (< emacs-mule-id 256)) | ||
| 68 | (error "Invalid CHARSET-ID: %d" emacs-mule-id)) | ||
| 69 | (let (from-id to-id) | ||
| 70 | (if (= dim 1) (setq from-id 160 to-id 224) | ||
| 71 | (setq from-id 224 to-id 255)) | ||
| 72 | (while (and (< from-id to-id) | ||
| 73 | (not (aref emacs-mule-charset-table from-id))) | ||
| 74 | (setq from-id (1+ from-id))) | ||
| 75 | (if (= from-id to-id) | ||
| 76 | (error "No more room for the new Emacs-mule charset")) | ||
| 77 | (setq emacs-mule-id from-id))) | ||
| 78 | (if (> (- private-char-area-1-max private-char-area-1-min) total) | ||
| 79 | (setq code-offset private-char-area-1-min | ||
| 80 | private-char-area-1-min (+ private-char-area-1-min total)) | ||
| 81 | (if (> (- private-char-area-2-max private-char-area-2-min) total) | ||
| 82 | (setq code-offset private-char-area-2-min | ||
| 83 | private-char-area-2-min (+ private-char-area-2-min total)) | ||
| 84 | (error "No more space for a new charset."))) | ||
| 85 | (list :dimension dim | ||
| 86 | :code-space code-space | ||
| 87 | :iso-final-char (aref info-vector 4) | ||
| 88 | :code-offset code-offset | ||
| 89 | :emacs-mule-id emacs-mule-id))) | ||
| 90 | |||
| 48 | (defun define-charset (name docstring &rest props) | 91 | (defun define-charset (name docstring &rest props) |
| 49 | "Define NAME (symbol) as a charset with DOCSTRING. | 92 | "Define NAME (symbol) as a charset with DOCSTRING. |
| 50 | The remaining arguments must come in pairs ATTRIBUTE VALUE. ATTRIBUTE | 93 | The remaining arguments must come in pairs ATTRIBUTE VALUE. ATTRIBUTE |
| @@ -103,7 +146,7 @@ number of the charset for ISO-2022 encoding. | |||
| 103 | 146 | ||
| 104 | `:emacs-mule-id' | 147 | `:emacs-mule-id' |
| 105 | 148 | ||
| 106 | VALUE must be an integer of 0, 128..255. If omitted, the charset | 149 | VALUE must be an integer of 0, 129..255. If omitted, the charset |
| 107 | can't be encoded by coding-systems of type `emacs-mule'. | 150 | can't be encoded by coding-systems of type `emacs-mule'. |
| 108 | 151 | ||
| 109 | `:ascii-compatible-p' | 152 | `:ascii-compatible-p' |
| @@ -172,6 +215,14 @@ corresponding Unicode character code. | |||
| 172 | If it is a string, it is a name of file that contains the above | 215 | If it is a string, it is a name of file that contains the above |
| 173 | information. The file format is the same as what described for `:map' | 216 | information. The file format is the same as what described for `:map' |
| 174 | attribute." | 217 | attribute." |
| 218 | (when (vectorp (car props)) | ||
| 219 | ;; Old style code: | ||
| 220 | ;; (define-charset CHARSET-ID CHARSET-SYMBOL INFO-VECTOR) | ||
| 221 | ;; Convert the argument to make it fit with the current style. | ||
| 222 | (let ((vec (car props))) | ||
| 223 | (setq props (convert-define-charset-argument name vec) | ||
| 224 | name docstring | ||
| 225 | docstring (aref vec 8)))) | ||
| 175 | (let ((attrs (mapcar 'list '(:dimension | 226 | (let ((attrs (mapcar 'list '(:dimension |
| 176 | :code-space | 227 | :code-space |
| 177 | :min-code | 228 | :min-code |
| @@ -196,6 +247,11 @@ attribute." | |||
| 196 | (setq dimension (/ (length (plist-get props :code-space)) 2)) | 247 | (setq dimension (/ (length (plist-get props :code-space)) 2)) |
| 197 | (setq props (plist-put props :dimension dimension))))) | 248 | (setq props (plist-put props :dimension dimension))))) |
| 198 | 249 | ||
| 250 | ;; If :emacs-mule-id is specified, update emacs-mule-charset-table. | ||
| 251 | (let ((emacs-mule-id (plist-get props :emacs-mule-id))) | ||
| 252 | (if (integerp emacs-mule-id) | ||
| 253 | (aset emacs-mule-charset-table emacs-mule-id name))) | ||
| 254 | |||
| 199 | (dolist (slot attrs) | 255 | (dolist (slot attrs) |
| 200 | (setcdr slot (plist-get props (car slot)))) | 256 | (setcdr slot (plist-get props (car slot)))) |
| 201 | 257 | ||
| @@ -405,10 +461,21 @@ Now we have the variable `charset-list'." | |||
| 405 | charset-list) | 461 | charset-list) |
| 406 | (make-obsolete 'charset-list "Use variable `charset-list'" "22.1") | 462 | (make-obsolete 'charset-list "Use variable `charset-list'" "22.1") |
| 407 | 463 | ||
| 464 | |||
| 465 | ;;; CHARACTER | ||
| 466 | (defalias 'char-valid-p 'characterp) | ||
| 467 | (make-obsolete 'char-valid-p 'characterp "22.1") | ||
| 468 | |||
| 408 | (defun generic-char-p (char) | 469 | (defun generic-char-p (char) |
| 409 | "Always return nil. This is provided for backward compatibility." | 470 | "Always return nil. This is provided for backward compatibility." |
| 410 | nil) | 471 | nil) |
| 411 | (make-obsolete 'generic-char-p "Generic characters no longer exist" "22.1") | 472 | (make-obsolete 'generic-char-p "Generic characters no longer exist" "22.1") |
| 473 | |||
| 474 | (defun make-char-internal (charset-id &optional code1 code2) | ||
| 475 | (let ((charset (aref emacs-mule-charset-table charset-id))) | ||
| 476 | (or charset | ||
| 477 | (error "Invalid Emacs-mule charset ID: %d" charset-id)) | ||
| 478 | (make-char charset code1 code2))) | ||
| 412 | 479 | ||
| 413 | ;; Coding system stuff | 480 | ;; Coding system stuff |
| 414 | 481 | ||