diff options
| author | Kenichi Handa | 2005-01-30 11:29:37 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2005-01-30 11:29:37 +0000 |
| commit | 16400c3222eb0f671f8f42b60701ee40023a9ddf (patch) | |
| tree | 0071522a863baf53b0d60d642bfdafd36cf2fa07 | |
| parent | 3cd944674a318f83a18c4ad919c1c0ad3600f88e (diff) | |
| download | emacs-16400c3222eb0f671f8f42b60701ee40023a9ddf.tar.gz emacs-16400c3222eb0f671f8f42b60701ee40023a9ddf.zip | |
(set-language-environment): Check :ascii-compatible-p property of
nonascii charset instead of its dimension.
(char-code-property-alist): New variable.
(define-char-code-property): New function.
(get-char-code-property): Handle a char-table registerd in
char-code-property-alist.
(put-char-code-property): Likewise.
| -rw-r--r-- | lisp/international/mule-cmds.el | 112 |
1 files changed, 96 insertions, 16 deletions
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el index 573481d71d0..5953d499755 100644 --- a/lisp/international/mule-cmds.el +++ b/lisp/international/mule-cmds.el | |||
| @@ -1750,7 +1750,7 @@ specifies the character set for the major languages of Western Europe." | |||
| 1750 | (if (eq window-system 'pc) | 1750 | (if (eq window-system 'pc) |
| 1751 | (setq nonascii (intern "cp%d" dos-codepage))) | 1751 | (setq nonascii (intern "cp%d" dos-codepage))) |
| 1752 | (or (and (charsetp nonascii) | 1752 | (or (and (charsetp nonascii) |
| 1753 | (= (charset-dimension nonascii) 1)) | 1753 | (get-charset-property nonascii :ascii-compatible-p)) |
| 1754 | (setq nonascii 'iso-8859-1)) | 1754 | (setq nonascii 'iso-8859-1)) |
| 1755 | (set-unibyte-charset nonascii)) | 1755 | (set-unibyte-charset nonascii)) |
| 1756 | 1756 | ||
| @@ -2441,32 +2441,112 @@ system codeset `%s' for this locale." coding-system codeset)))))))) | |||
| 2441 | 'a4)))))) | 2441 | 'a4)))))) |
| 2442 | nil) | 2442 | nil) |
| 2443 | 2443 | ||
| 2444 | ;;; Character code property | 2444 | ;;; Character property |
| 2445 | (put 'char-code-property-table 'char-table-extra-slots 0) | 2445 | |
| 2446 | ;; Each element has the form (PROP . TABLE). | ||
| 2447 | ;; PROP is a symbol representing a character property. | ||
| 2448 | ;; TABLE is a char-table containing the property value for each character. | ||
| 2449 | ;; TABLE may be a name of file to load to build a char-table. | ||
| 2450 | ;; Don't modify this variable directly but use `define-char-code-property'. | ||
| 2451 | |||
| 2452 | (defvar char-code-property-alist nil | ||
| 2453 | "Alist of character property name vs char-table containing property values. | ||
| 2454 | Internal use only.") | ||
| 2455 | |||
| 2456 | (put 'char-code-property-table 'char-table-extra-slots 5) | ||
| 2457 | |||
| 2458 | (defun define-char-code-property (name table &optional docstring) | ||
| 2459 | "Define NAME as a character code property given by TABLE. | ||
| 2460 | TABLE is a char-table of purpose `char-code-property-table' with | ||
| 2461 | these extra slots: | ||
| 2462 | 1st: NAME. | ||
| 2463 | 2nd: Function to call to get a property value of a character. | ||
| 2464 | It is called with three arugments CHAR, VAL, and TABLE, where | ||
| 2465 | CHAR is a character, VAL is the value of (aref TABLE CHAR). | ||
| 2466 | 3rd: Function to call to put a property value of a character. | ||
| 2467 | It is called with the same arguments as above. | ||
| 2468 | 4th: Function to call to get a description string of a property value. | ||
| 2469 | It is called with one argument VALUE, a property value. | ||
| 2470 | 5th: Data used by the above functions. | ||
| 2471 | |||
| 2472 | TABLE may be a name of file to load to build a char-table. The | ||
| 2473 | file should contain a call of `define-char-code-property' with a | ||
| 2474 | char-table of the above format as the argument TABLE. | ||
| 2475 | |||
| 2476 | TABLE may also be nil, in which case no property value is pre-assigned. | ||
| 2477 | |||
| 2478 | Optional 3rd argment DOCSTRING is a documentation string of the property. | ||
| 2479 | |||
| 2480 | See also the documentation of `get-char-code-property' and | ||
| 2481 | `put-char-code-property'." | ||
| 2482 | (or (symbolp name) | ||
| 2483 | (error "Not a symbol: %s" name)) | ||
| 2484 | (if (char-table-p table) | ||
| 2485 | (or (and (eq (char-table-subtype table) 'char-code-property-table) | ||
| 2486 | (eq (char-table-extra-slot table 0) name)) | ||
| 2487 | (error "Invalid char-table: %s" table)) | ||
| 2488 | (or (stringp table) | ||
| 2489 | (error "Not a char-table nor a file name: %s" table))) | ||
| 2490 | (let ((slot (assq name char-code-property-alist))) | ||
| 2491 | (if slot | ||
| 2492 | (setcdr slot table) | ||
| 2493 | (setq char-code-property-alist | ||
| 2494 | (cons (cons name table) char-code-property-alist)))) | ||
| 2495 | (put name 'char-code-property-documentation docstring)) | ||
| 2446 | 2496 | ||
| 2447 | (defvar char-code-property-table | 2497 | (defvar char-code-property-table |
| 2448 | (make-char-table 'char-code-property-table) | 2498 | (make-char-table 'char-code-property-table) |
| 2449 | "Char-table containing a property list of each character code. | 2499 | "Char-table containing a property list of each character code. |
| 2450 | 2500 | This table is used for properties not listed in `char-code-property-alist'. | |
| 2451 | See also the documentation of `get-char-code-property' and | 2501 | See also the documentation of `get-char-code-property' and |
| 2452 | `put-char-code-property'.") | 2502 | `put-char-code-property'.") |
| 2453 | 2503 | ||
| 2454 | (defun get-char-code-property (char propname) | 2504 | (defun get-char-code-property (char propname) |
| 2455 | "Return the value of CHAR's PROPNAME property in `char-code-property-table'." | 2505 | "Return the value of CHAR's PROPNAME property." |
| 2456 | (let ((plist (aref char-code-property-table char))) | 2506 | (let ((slot (assq propname char-code-property-alist))) |
| 2457 | (if (listp plist) | 2507 | (if slot |
| 2458 | (car (cdr (memq propname plist)))))) | 2508 | (let (table value func) |
| 2509 | (if (stringp (cdr slot)) | ||
| 2510 | (load (cdr slot))) | ||
| 2511 | (setq table (cdr slot) | ||
| 2512 | value (aref table char) | ||
| 2513 | func (char-table-extra-slot table 1)) | ||
| 2514 | (if (functionp func) | ||
| 2515 | (setq value (funcall func char value table))) | ||
| 2516 | value) | ||
| 2517 | (plist-get (aref char-code-property-table char) propname)))) | ||
| 2459 | 2518 | ||
| 2460 | (defun put-char-code-property (char propname value) | 2519 | (defun put-char-code-property (char propname value) |
| 2461 | "Store CHAR's PROPNAME property with VALUE in `char-code-property-table'. | 2520 | "Store CHAR's PROPNAME property with VALUE. |
| 2462 | It can be retrieved with `(get-char-code-property CHAR PROPNAME)'." | 2521 | It can be retrieved with `(get-char-code-property CHAR PROPNAME)'." |
| 2463 | (let ((plist (aref char-code-property-table char))) | 2522 | (let ((slot (assq propname char-code-property-alist))) |
| 2464 | (if plist | 2523 | (if slot |
| 2465 | (let ((slot (memq propname plist))) | 2524 | (let (table func) |
| 2466 | (if slot | 2525 | (if (stringp (cdr slot)) |
| 2467 | (setcar (cdr slot) value) | 2526 | (load (cdr slot))) |
| 2468 | (nconc plist (list propname value)))) | 2527 | (setq table (cdr slot) |
| 2469 | (aset char-code-property-table char (list propname value))))) | 2528 | func (char-table-extra-slot table 2)) |
| 2529 | (if (functionp func) | ||
| 2530 | (funcall func char value table) | ||
| 2531 | (aset table char value))) | ||
| 2532 | (let* ((plist (aref char-code-property-table char)) | ||
| 2533 | (x (plist-put plist propname value))) | ||
| 2534 | (or (eq x plist) | ||
| 2535 | (aset char-code-property-table char x)))) | ||
| 2536 | value)) | ||
| 2537 | |||
| 2538 | (defun char-code-property-description (prop value) | ||
| 2539 | "Return a description string of character property PROP's value VALUE. | ||
| 2540 | If there's no description string for VALUE, return nil." | ||
| 2541 | (let ((slot (assq prop char-code-property-alist))) | ||
| 2542 | (if slot | ||
| 2543 | (let (table func) | ||
| 2544 | (if (stringp (cdr slot)) | ||
| 2545 | (load (cdr slot))) | ||
| 2546 | (setq table (cdr slot) | ||
| 2547 | func (char-table-extra-slot table 3)) | ||
| 2548 | (if (functionp func) | ||
| 2549 | (funcall func value)))))) | ||
| 2470 | 2550 | ||
| 2471 | 2551 | ||
| 2472 | ;; Pretty description of encoded string | 2552 | ;; Pretty description of encoded string |