Changeset 3500
- Timestamp:
- 10/11/04 11:07:08 (4 years ago)
- Files:
-
- branches/2.2/lisp/ChangeLog.Meadow (modified) (1 diff)
- branches/2.2/lisp/cus-load.el (modified) (5 diffs)
- branches/2.2/lisp/files.el (modified) (1 diff)
- branches/2.2/lisp/international/ccl.el (modified) (13 diffs)
- branches/2.2/lisp/international/mule.el (modified) (35 diffs)
- branches/2.2/lisp/international/ucs-tables.el (modified) (16 diffs)
- branches/2.2/lisp/international/utf-16.el (modified) (6 diffs)
- branches/2.2/lisp/international/utf-7.el (added)
- branches/2.2/lisp/international/utf-8.el (modified) (8 diffs)
- branches/2.2/lisp/loaddefs.el (modified) (25 diffs)
- branches/2.2/src/ChangeLog.Meadow (modified) (1 diff)
- branches/2.2/src/ccl.c (modified) (57 diffs)
- branches/2.2/src/ccl.h (modified) (2 diffs)
- branches/2.2/src/data.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/2.2/lisp/ChangeLog.Meadow
r3484 r3500 1 2004-10-11 MIYOSHI Masanori <miyoshi@meadowy.org> 2 3 * international/ccl.el: Sync up with Emacs CVS HEAD. 4 5 * lisp/international/ccl.el: Ditto. 6 7 * lisp/international/mule.el: Ditto. 8 9 * lisp/international/ucs-tables.el: Ditto. 10 11 * lisp/international/utf-16.el: Ditto. 12 13 * lisp/international/utf-8.el: Ditto. 14 15 * lisp/international/utf-7.el: New file from Emacs CVS HEAD. 16 17 * cus-load.el: Update. 18 19 * loaddefs.el: Ditto. 20 21 * files.el (set-auto-mode-1): New function from Emacs CVS HEAD. 22 1 23 2004-10-03 MIYOSHI Masanori <miyoshi@meadowy.org> 2 24 branches/2.2/lisp/cus-load.el
r3480 r3500 564 564 (put 'viper-search 'custom-loads '("viper-init")) 565 565 (put 'ls-lisp 'custom-loads '("ls-lisp")) 566 (put 'mule 'custom-loads '("mule" "mule-cmds" " kkc"))566 (put 'mule 'custom-loads '("mule" "mule-cmds" "utf-8" "kkc")) 567 567 (put 'glasses 'custom-loads '("glasses")) 568 568 (put 'vhdl-style 'custom-loads '("vhdl-mode")) … … 676 676 (custom-put-if-not 'ps-line-number-color 'custom-version "21.1") 677 677 (custom-put-if-not 'ps-line-number-color 'standard-value t) 678 (custom-put-if-not 'utf-fragment-on-decoding 'custom-version "21.4") 679 (custom-put-if-not 'utf-fragment-on-decoding 'standard-value t) 678 680 (custom-put-if-not 'confirm-kill-emacs 'custom-version "21.1") 679 681 (custom-put-if-not 'confirm-kill-emacs 'standard-value t) … … 803 805 (custom-put-if-not 'gnus-extra-headers 'custom-version "21.1") 804 806 (custom-put-if-not 'gnus-extra-headers 'standard-value t) 807 (custom-put-if-not 'utf-8-compose-scripts 'custom-version "21.4") 808 (custom-put-if-not 'utf-8-compose-scripts 'standard-value t) 805 809 (custom-put-if-not 'speedbar-use-images 'custom-version "21.1") 806 810 (custom-put-if-not 'speedbar-use-images 'standard-value t) … … 1021 1025 (custom-put-if-not 'rmail-movemail-flags 'custom-version "20.3") 1022 1026 (custom-put-if-not 'rmail-movemail-flags 'standard-value t) 1023 (custom-put-if-not 'keyboard-coding-system 'custom-version "21. 1")1027 (custom-put-if-not 'keyboard-coding-system 'custom-version "21.4") 1024 1028 (custom-put-if-not 'keyboard-coding-system 'standard-value t) 1025 1029 (custom-put-if-not 'sql-sybase-options 'custom-version "20.8") … … 1122 1126 (custom-put-if-not 'eval-expression-print-level 'standard-value t) 1123 1127 1124 (defvar custom-versions-load-alist '(("20.3.3" "dos-vars") ("20.4" "files" "help" "sh-script" "compile") ("21.3" "ange-ftp") ("21.4" " dired" "ange-ftp") ("20.3" "desktop" "easymenu" "dabbrev" "ffap" "rmail" "paren" "mailabbrev" "frame" "uce" "mouse" "diary-lib" "sendmail" "simple" "debug" "hexl" "vcursor" "vc" "compile" "etags" "browse-url" "add-log" "find-func" "cus-edit" "replace") ("21.1" "server" "debug" "rmailedit" "dabbrev" "isearch" "gnus-start" "mule" "hideshow" "sendmail" "paths" "sgml-mode" "net-utils" "cperl-mode" "rmail" "ange-ftp" "font-lock" "gnus-nocem" "vc-hooks" "paren" "faces" "fortran" "vc" "etags" "cus-edit" "frame" "vc-sccs" "gnus-group" "gnus-sum" "smtpmail" "add-log" "wid-edit" "vc-rcs" "files" "nnmail" "message" "ps-print" "vc-cvs" "simple" "gnus-agent" "flyspell" "gnus-art" "browse-url" "speedbar") ("20.8" "sql"))1128 (defvar custom-versions-load-alist '(("20.3.3" "dos-vars") ("20.4" "files" "help" "sh-script" "compile") ("21.3" "ange-ftp") ("21.4" "mule" "dired" "ange-ftp" "utf-8") ("20.3" "desktop" "easymenu" "dabbrev" "ffap" "rmail" "paren" "mailabbrev" "frame" "uce" "mouse" "diary-lib" "sendmail" "simple" "debug" "hexl" "vcursor" "vc" "compile" "etags" "browse-url" "add-log" "find-func" "cus-edit" "replace") ("21.1" "server" "debug" "rmailedit" "dabbrev" "isearch" "gnus-start" "hideshow" "sendmail" "paths" "sgml-mode" "net-utils" "cperl-mode" "rmail" "ange-ftp" "font-lock" "gnus-nocem" "vc-hooks" "paren" "faces" "fortran" "vc" "etags" "cus-edit" "frame" "vc-sccs" "gnus-group" "gnus-sum" "smtpmail" "add-log" "wid-edit" "vc-rcs" "files" "nnmail" "message" "ps-print" "vc-cvs" "simple" "gnus-agent" "flyspell" "gnus-art" "browse-url" "speedbar") ("20.8" "sql")) 1125 1129 "For internal use by custom.") 1126 1130 branches/2.2/lisp/files.el
r3408 r3500 1766 1766 (funcall (cdr elt)))))))))))) 1767 1767 1768 1769 (defun set-auto-mode-1 () 1770 "Find the -*- spec in the buffer. 1771 Call with point at the place to start searching from. 1772 If one is found, set point to the beginning 1773 and return the position of the end. 1774 Otherwise, return nil; point may be changed." 1775 (let (beg end) 1776 (and 1777 ;; Don't look for -*- if this file name matches any 1778 ;; of the regexps in inhibit-first-line-modes-regexps. 1779 (let ((temp inhibit-first-line-modes-regexps) 1780 (name (if buffer-file-name 1781 (file-name-sans-versions buffer-file-name) 1782 (buffer-name)))) 1783 (while (let ((sufs inhibit-first-line-modes-suffixes)) 1784 (while (and sufs (not (string-match (car sufs) name))) 1785 (setq sufs (cdr sufs))) 1786 sufs) 1787 (setq name (substring name 0 (match-beginning 0)))) 1788 (while (and temp 1789 (not (string-match (car temp) name))) 1790 (setq temp (cdr temp))) 1791 (not temp)) 1792 1793 (search-forward "-*-" (save-excursion 1794 ;; If the file begins with "#!" 1795 ;; (exec interpreter magic), look 1796 ;; for mode frobs in the first two 1797 ;; lines. You cannot necessarily 1798 ;; put them in the first line of 1799 ;; such a file without screwing up 1800 ;; the interpreter invocation. 1801 (end-of-line (and (looking-at "^#!") 2)) 1802 (point)) t) 1803 (progn 1804 (skip-chars-forward " \t") 1805 (setq beg (point)) 1806 (search-forward "-*-" 1807 (save-excursion (end-of-line) (point)) 1808 t)) 1809 (progn 1810 (forward-char -3) 1811 (skip-chars-backward " \t") 1812 (setq end (point)) 1813 (goto-char beg) 1814 end)))) 1815 1768 1816 (defun hack-local-variables-prop-line () 1769 1817 "Set local variables specified in the -*- line. branches/2.2/lisp/international/ccl.el
r3212 r3500 3 3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN. 4 4 ;; Licensed to the Free Software Foundation. 5 ;; Copyright (C) 2002 Free Software Foundation, Inc. 5 6 6 7 ;; Keywords: CCL, mule, multilingual, character set, coding-system … … 26 27 27 28 ;; CCL (Code Conversion Language) is a simple programming language to 28 ;; be used for various kind of code conversion. CCL program is29 ;; compiled to CCL code (vector of integers) and executed by CCL30 ;; interpreter ofEmacs.29 ;; be used for various kind of code conversion. A CCL program is 30 ;; compiled to CCL code (vector of integers) and executed by the CCL 31 ;; interpreter in Emacs. 31 32 ;; 32 33 ;; CCL is used for code conversion at process I/O and file I/O for 33 ;; non-standard coding-system . In addition, it is used for34 ;; calculating a code point of X's font from a character code.34 ;; non-standard coding-systems. In addition, it is used for 35 ;; calculating code points of X fonts from character codes. 35 36 ;; However, since CCL is designed as a powerful programming language, 36 37 ;; it can be used for more generic calculation. For instance, 37 38 ;; combination of three or more arithmetic operations can be 38 ;; calculated faster than Emacs Lisp.39 ;; calculated faster than in Emacs Lisp. 39 40 ;; 40 ;; Syntax and semantics of CCL program isdescribed in the41 ;; The syntax and semantics of CCL programs are described in the 41 42 ;; documentation of `define-ccl-program'. 42 43 … … 53 54 read-multibyte-character write-multibyte-character 54 55 translate-character 55 iterate-multiple-map map-multiple map-single] 56 iterate-multiple-map map-multiple map-single lookup-integer 57 lookup-character] 56 58 "Vector of CCL commands (symbols).") 57 59 … … 108 110 map-multiple 109 111 map-single 112 lookup-int-const-tbl 113 lookup-char-const-tbl 110 114 ] 111 115 "Vector of CCL extended compiled codes (symbols).") … … 197 201 ;; Embed pair of SYMBOL and PROP where (get SYMBOL PROP) should give 198 202 ;; proper index number for SYMBOL. PROP should be 199 ;; `translation-table-id', ` code-conversion-map-id', or200 ;; `c cl-program-idx'.203 ;; `translation-table-id', `translation-hash-table-id' 204 ;; `code-conversion-map-id', or `ccl-program-idx'. 201 205 (defun ccl-embed-symbol (symbol prop) 202 206 (ccl-embed-data (cons symbol prop))) … … 771 775 (ccl-embed-code 'write-expr-register 0 772 776 (logior (ash op 3) 773 (get right 'ccl-register-number)))))) 777 (get right 'ccl-register-number)) 778 left)))) 774 779 775 780 (t … … 832 837 (ccl-check-register Rrr cmd) 833 838 (ccl-embed-extended-command 'translate-character rrr RRR Rrr)))) 839 nil) 840 841 ;; Compile lookup-integer 842 (defun ccl-compile-lookup-integer (cmd) 843 (if (/= (length cmd) 4) 844 (error "CCL: Invalid number of arguments: %s" cmd)) 845 (let ((Rrr (nth 1 cmd)) 846 (RRR (nth 2 cmd)) 847 (rrr (nth 3 cmd))) 848 (ccl-check-register RRR cmd) 849 (ccl-check-register rrr cmd) 850 (cond ((and (symbolp Rrr) (not (get Rrr 'ccl-register-number))) 851 (ccl-embed-extended-command 'lookup-int-const-tbl 852 rrr RRR 0) 853 (ccl-embed-symbol Rrr 'translation-hash-table-id)) 854 (t 855 (error "CCL: non-constant table: %s" cmd) 856 ;; not implemented: 857 (ccl-check-register Rrr cmd) 858 (ccl-embed-extended-command 'lookup-int rrr RRR 0)))) 859 nil) 860 861 ;; Compile lookup-character 862 (defun ccl-compile-lookup-character (cmd) 863 (if (/= (length cmd) 4) 864 (error "CCL: Invalid number of arguments: %s" cmd)) 865 (let ((Rrr (nth 1 cmd)) 866 (RRR (nth 2 cmd)) 867 (rrr (nth 3 cmd))) 868 (ccl-check-register RRR cmd) 869 (ccl-check-register rrr cmd) 870 (cond ((and (symbolp Rrr) (not (get Rrr 'ccl-register-number))) 871 (ccl-embed-extended-command 'lookup-char-const-tbl 872 rrr RRR 0) 873 (ccl-embed-symbol Rrr 'translation-hash-table-id)) 874 (t 875 (error "CCL: non-constant table: %s" cmd) 876 ;; not implemented: 877 (ccl-check-register Rrr cmd) 878 (ccl-embed-extended-command 'lookup-char rrr RRR 0)))) 834 879 nil) 835 880 … … 906 951 907 952 908 ;;; CCL dump st affs953 ;;; CCL dump stuff 909 954 910 955 ;; To avoid byte-compiler warning. … … 1076 1121 1077 1122 (defun ccl-dump-call (ignore cc) 1078 (insert (format "call subroutine #%d\n" cc))) 1123 (let ((subroutine (car (ccl-get-next-code)))) 1124 (insert (format "call subroutine `%s'\n" subroutine)))) 1079 1125 1080 1126 (defun ccl-dump-write-const-string (rrr cc) … … 1193 1239 (insert (format "translation table(%S) r%d r%d\n" tbl RRR rrr)))) 1194 1240 1241 (defun ccl-dump-lookup-int-const-tbl (rrr RRR Rrr) 1242 (let ((tbl (ccl-get-next-code))) 1243 (insert (format "hash table(%S) r%d r%d\n" tbl RRR rrr)))) 1244 1245 (defun ccl-dump-lookup-char-const-tbl (rrr RRR Rrr) 1246 (let ((tbl (ccl-get-next-code))) 1247 (insert (format "hash table(%S) r%d r%d\n" tbl RRR rrr)))) 1248 1195 1249 (defun ccl-dump-iterate-multiple-map (rrr RRR Rrr) 1196 1250 (let ((notbl (ccl-get-next-code)) … … 1272 1326 STATEMENT := 1273 1327 SET | IF | BRANCH | LOOP | REPEAT | BREAK | READ | WRITE | CALL 1274 | TRANSLATE | END1328 | TRANSLATE | MAP | LOOKUP | END 1275 1329 1276 1330 SET := (REG = EXPRESSION) … … 1439 1493 | (translate-character SYMBOL REG(charset) REG(codepoint)) 1440 1494 ;; SYMBOL must refer to a table defined by `define-translation-table'. 1495 LOOKUP := 1496 (lookup-character SYMBOL REG(charset) REG(codepoint)) 1497 | (lookup-integer SYMBOL REG(integer)) 1498 ;; SYMBOL refers to a table defined by `define-translation-hash-table'. 1441 1499 MAP := 1442 1500 (iterate-multiple-map REG REG MAP-IDs) … … 1484 1542 (provide 'ccl) 1485 1543 1544 ;;; arch-tag: 836bcd27-63a1-4a56-b232-1145ecf823fb 1486 1545 ;;; ccl.el ends here branches/2.2/lisp/international/mule.el
r3326 r3500 2 2 3 3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN. 4 ;; Copyright (C) 2001 Free Software Foundation, Inc.5 4 ;; Licensed to the Free Software Foundation. 5 ;; Copyright (C) 2001, 2002 Free Software Foundation, Inc. 6 6 7 7 ;; Keywords: mule, multilingual, character set, coding system … … 65 65 (message "Loading %s..." file))) 66 66 (when purify-flag 67 ( setq preloaded-file-list (cons file preloaded-file-list)))67 (push file preloaded-file-list)) 68 68 (unwind-protect 69 69 (let ((load-file-name fullname) … … 270 270 code in CHARSET. 271 271 272 If CODE1 or CODE2 are invalid (out of range), this function signals an error." 272 If CODE1 or CODE2 are invalid (out of range), this function signals an 273 error. However, the eighth bit of both CODE1 and CODE2 is zeroed 274 before they are used to index CHARSET. Thus you may use, say, the 275 actual ISO 8859 character code rather than subtracting 128, as you 276 would need to index the corresponding Emacs charset." 273 277 (make-char-internal (charset-id charset) code1 code2)) 274 278 … … 304 308 Return nil if such a character is not supported. 305 309 Currently the only supported coded character set is `ucs' (ISO/IEC 306 10646: Universal Multi-Octet Coded Character Set). 310 10646: Universal Multi-Octet Coded Character Set), and the result is 311 translated through the translation-table named 312 `utf-translation-table-for-decode' or the translation-hash-table named 313 `utf-subst-table-for-decode'. 307 314 308 315 Optional argument RESTRICTION specifies a way to map the pair of CCS 309 316 and CODE-POINT to a character. Currently not supported and just ignored." 310 (cond ((eq ccs 'ucs) 311 (cond ((< code-point 160) 312 code-point) 313 ((< code-point 256) 314 (make-char 'latin-iso8859-1 code-point)) 315 ((< code-point #x2500) 316 (setq code-point (- code-point #x0100)) 317 (make-char 'mule-unicode-0100-24ff 318 (+ (/ code-point 96) 32) (+ (% code-point 96) 32))) 319 ((< code-point #x3400) 320 (setq code-point (- code-point #x2500)) 321 (make-char 'mule-unicode-2500-33ff 322 (+ (/ code-point 96) 32) (+ (% code-point 96) 32))) 323 ((and (>= code-point #xe000) (< code-point #x10000)) 324 (setq code-point (- code-point #xe000)) 325 (make-char 'mule-unicode-e000-ffff 326 (+ (/ code-point 96) 32) (+ (% code-point 96) 32))) 327 )))) 317 (cond 318 ((eq ccs 'ucs) 319 (or (utf-lookup-subst-table-for-decode code-point) 320 (let ((c (cond 321 ((< code-point 160) 322 code-point) 323 ((< code-point 256) 324 (make-char 'latin-iso8859-1 code-point)) 325 ((< code-point #x2500) 326 (setq code-point (- code-point #x0100)) 327 (make-char 'mule-unicode-0100-24ff 328 (+ (/ code-point 96) 32) (+ (% code-point 96) 32))) 329 ((< code-point #x3400) 330 (setq code-point (- code-point #x2500)) 331 (make-char 'mule-unicode-2500-33ff 332 (+ (/ code-point 96) 32) (+ (% code-point 96) 32))) 333 ((and (>= code-point #xe000) (< code-point #x10000)) 334 (setq code-point (- code-point #xe000)) 335 (make-char 'mule-unicode-e000-ffff 336 (+ (/ code-point 96) 32) 337 (+ (% code-point 96) 32)))))) 338 (when c 339 (or (aref (get 'utf-translation-table-for-decode 340 'translation-table) c) 341 c))))))) 328 342 329 343 (defun encode-char (char ccs &optional restriction) … … 333 347 10646: Universal Multi-Octet Coded Character Set), and CHAR is first 334 348 translated through the translation-table named 335 `utf-translation-table-for-encode'. 349 `utf-translation-table-for-encode' or the translation-hash-table named 350 `utf-subst-table-for-encode'. 336 351 337 352 CHAR should be in one of these charsets: … … 343 358 code-point in CCS. Currently not supported and just ignored." 344 359 (let* ((split (split-char char)) 345 (charset (car split))) 360 (charset (car split)) 361 trans) 346 362 (cond ((eq ccs 'ucs) 347 (let* ((table (get 'utf-translation-table-for-encode 348 'translation-table)) 349 (trans (aref table char))) 350 (if trans 351 (setq split (split-char trans) 352 charset (car split))) 353 (cond ((eq charset 'ascii) 354 char) 355 ((eq charset 'latin-iso8859-1) 356 (+ (nth 1 split) 128)) 357 ((eq charset 'mule-unicode-0100-24ff) 358 (+ #x0100 (+ (* (- (nth 1 split) 32) 96) 359 (- (nth 2 split) 32)))) 360 ((eq charset 'mule-unicode-2500-33ff) 361 (+ #x2500 (+ (* (- (nth 1 split) 32) 96) 362 (- (nth 2 split) 32)))) 363 ((eq charset 'mule-unicode-e000-ffff) 364 (+ #xe000 (+ (* (- (nth 1 split) 32) 96) 365 (- (nth 2 split) 32)))) 366 ((eq charset 'eight-bit-control) 367 char))))))) 363 (or (utf-lookup-subst-table-for-encode char) 364 (let ((table (get 'utf-translation-table-for-encode 365 'translation-table))) 366 (setq trans (aref table char)) 367 (if trans 368 (setq split (split-char trans) 369 charset (car split))) 370 (cond ((eq charset 'ascii) 371 (or trans char)) 372 ((eq charset 'latin-iso8859-1) 373 (+ (nth 1 split) 128)) 374 ((eq charset 'mule-unicode-0100-24ff) 375 (+ #x0100 (+ (* (- (nth 1 split) 32) 96) 376 (- (nth 2 split) 32)))) 377 ((eq charset 'mule-unicode-2500-33ff) 378 (+ #x2500 (+ (* (- (nth 1 split) 32) 96) 379 (- (nth 2 split) 32)))) 380 ((eq charset 'mule-unicode-e000-ffff) 381 (+ #xe000 (+ (* (- (nth 1 split) 32) 96) 382 (- (nth 2 split) 32)))) 383 ((eq charset 'eight-bit-control) 384 char)))))))) 368 385 369 386 … … 495 512 (get coding-system 'eol-type)) 496 513 514 (defun coding-system-eol-type-mnemonic (coding-system) 515 "Return the string indicating end-of-line format of CODING-SYSTEM." 516 (let* ((eol-type (coding-system-eol-type coding-system)) 517 (val (cond ((eq eol-type 0) eol-mnemonic-unix) 518 ((eq eol-type 1) eol-mnemonic-dos) 519 ((eq eol-type 2) eol-mnemonic-mac) 520 (t eol-mnemonic-undecided)))) 521 (if (stringp val) 522 val 523 (char-to-string val)))) 524 497 525 (defun coding-system-lessp (x y) 498 526 (cond ((eq x 'no-conversion) t) … … 563 591 (make-char charset (+ i start) (+ start chars -1))))))) 564 592 565 (defun register-char-codings (coding-system safe-chars) 566 (let ((general (char-table-extra-slot char-coding-system-table 0))) 567 (if (eq safe-chars t) 568 (or (memq coding-system general) 569 (set-char-table-extra-slot char-coding-system-table 0 570 (cons coding-system general))) 571 (map-char-table 572 (function 573 (lambda (key val) 574 (if (and (>= key 128) val) 575 (let ((codings (aref char-coding-system-table key))) 576 (or (memq coding-system codings) 577 (aset char-coding-system-table key 578 (cons coding-system codings))))))) 579 safe-chars)))) 580 593 (defalias 'register-char-codings 'ignore "") 594 (make-obsolete 'register-char-codings 595 "it exists just for backward compatibility, and does nothing." 596 "21.3") 597 598 (defconst char-coding-system-table nil 599 "This is an obsolete variable. 600 It exists just for backward compatibility, and the value is always nil.") 581 601 582 602 (defun make-subsidiary-coding-system (coding-system) … … 692 712 TYPE is an integer value indicating the type of the coding system as follows: 693 713 0: Emacs internal format, 694 1: Shift-JIS (or MS-Kanji) used mainly on Japanese PC ,714 1: Shift-JIS (or MS-Kanji) used mainly on Japanese PCs, 695 715 2: ISO-2022 including many variants, 696 3: Big5 used mainly on Chinese PC ,716 3: Big5 used mainly on Chinese PCs, 697 717 4: private, CCL programs provide encoding/decoding algorithm, 698 718 5: Raw-text, which means that text contains random 8-bit codes. … … 744 764 745 765 o post-read-conversion 746 766 747 767 The value is a function to call after some text is inserted and 748 768 decoded by the coding system itself and before any functions in … … 751 771 `after-insert-file-functions', i.e. LENGTH of the text inserted, 752 772 with point at the head of the text to be decoded. 753 773 754 774 o pre-write-conversion 755 775 756 776 The value is a function to call after all functions in 757 777 `write-region-annotate-functions' and `buffer-file-format' are … … 760 780 in `write-region-annotate-functions', i.e. FROM and TO, specifying 761 781 a region of text. 762 782 763 783 o translation-table-for-decode 764 784 765 785 The value is a translation table to be applied on decoding. See 766 786 the function `make-translation-table' for the format of translation 767 787 table. This is not applicable to type 4 (CCL-based) coding systems. 768 788 769 789 o translation-table-for-encode 770 790 771 791 The value is a translation table to be applied on encoding. This is 772 792 not applicable to type 4 (CCL-based) coding systems. 773 793 774 794 o safe-chars 775 795 776 796 The value is a char table. If a character has non-nil value in it, 777 797 the character is safely supported by the coding system. This … … 786 806 it just means that some other receiver of text encoded 787 807 in the coding system won't be able to handle that charset. 788 808 789 809 o mime-charset 790 791 The value is a symbol of which name is`MIME-charset' parameter of810 811 The value is a symbol whose name is the `MIME-charset' parameter of 792 812 the coding system. 793 813 814 o mime-text-unsuitable 815 816 A non-nil value means the `mime-charset' property names a charset 817 which is unsuitable for the top-level media type \"text\". 818 794 819 o valid-codes (meaningful only for a coding system based on CCL) 795 820 796 821 The value is a list to indicate valid byte ranges of the encoded 797 822 file. Each element of the list is an integer or a cons of integer. 798 823 In the former case, the integer value is a valid byte code. In the 799 latter case, the integers specifies the range of valid byte codes. 824 latter case, the integers specify the range of valid byte codes. 825 826 o composition (meaningful only when TYPE is 0 or 2) 827 828 If the value is non-nil, the coding system preserves composition 829 information. 800 830 801 831 These properties are set in PLIST, a property list. This function … … 993 1023 (get val 'translation-table)) 994 1024 (setq safe-chars (get val 'translation-table))) 995 (register-char-codings coding-system safe-chars)996 1025 (setq val safe-chars))) 997 1026 (plist-put plist prop val))) … … 1027 1056 (put coding-system 'eol-type eol-type) 1028 1057 1058 (define-coding-system-internal coding-system) 1059 1029 1060 ;; At last, register CODING-SYSTEM in `coding-system-list' and 1030 1061 ;; `coding-system-alist'. … … 1055 1086 coding-system) 1056 1087 1088 (put 'safe-chars 'char-table-extra-slots 0) 1089 1057 1090 (defun define-coding-system-alias (alias coding-system) 1058 1091 "Define ALIAS as an alias for coding system CODING-SYSTEM." 1059 1092 (put alias 'coding-system (coding-system-spec coding-system)) 1060 (nconc (coding-system-get alias 'alias-coding-systems) (list alias))1061 1093 (add-to-coding-system-list alias) 1062 1094 (setq coding-system-alist (cons (list (symbol-name alias)) … … 1064 1096 (let ((eol-type (coding-system-eol-type coding-system))) 1065 1097 (if (vectorp eol-type) 1066 (put alias 'eol-type (make-subsidiary-coding-system alias)) 1098 (progn 1099 (nconc (coding-system-get alias 'alias-coding-systems) (list alias)) 1100 (put alias 'eol-type (make-subsidiary-coding-system alias))) 1067 1101 (put alias 'eol-type eol-type)))) 1102 1103 (defun merge-coding-systems (first second) 1104 "Fill in any unspecified aspects of coding system FIRST from SECOND. 1105 Return the resulting coding system." 1106 (let ((base (coding-system-base second)) 1107 (eol (coding-system-eol-type second))) 1108 ;; If FIRST doesn't specify text conversion, merge with that of SECOND. 1109 (if (eq (coding-system-base first) 'undecided) 1110 (setq first (coding-system-change-text-conversion first base))) 1111 ;; If FIRST doesn't specify eol conversion, merge with that of SECOND. 1112 (if (and (vectorp (coding-system-eol-type first)) 1113 (numberp eol) (>= eol 0) (<= eol 2)) 1114 (setq first (coding-system-change-eol-conversion 1115 first eol))) 1116 first)) 1117 1118 (defun autoload-coding-system (symbol form) 1119 "Define SYMBOL as a coding-system that is defined on demand. 1120 1121 FROM is a form to evaluate to define the coding-system." 1122 (put symbol 'coding-system-define-form form) 1123 (setq coding-system-alist (cons (list (symbol-name symbol)) 1124 coding-system-alist))) 1068 1125 1069 1126 (defun set-buffer-file-coding-system (coding-system &optional force) … … 1073 1130 use \\[list-coding-systems]. 1074 1131 1075 If the buffer's previous file coding-system value specifies end-of-line 1076 conversion, and CODING-SYSTEM does not specify one, CODING-SYSTEM is 1077 merged with the already-specified end-of-line conversion. 1078 1079 If the buffer's previous file coding-system value specifies text 1080 conversion, and CODING-SYSTEM does not specify one, CODING-SYSTEM is 1081 merged with the already-specified text conversion. 1082 1083 However, if the optional prefix argument FORCE is non-nil, then 1084 CODING-SYSTEM is used exactly as specified. 1132 If CODING-SYSTEM leaves the text conversion unspecified, or if it 1133 leaves the end-of-line conversion unspecified, FORCE controls what to 1134 do. If FORCE is nil, get the unspecified aspect (or aspects) from the 1135 buffer's previous `buffer-file-coding-system' value (if it is 1136 specified there). Otherwise, leave it unspecified. 1085 1137 1086 1138 This marks the buffer modified so that the succeeding \\[save-buffer] … … 1088 1140 don't want to mark the buffer modified, just set the variable 1089 1141 `buffer-file-coding-system' directly." 1142 (interactive "zCoding system for saving file (default, nil): \nP") 1143 (check-coding-system coding-system) 1144 (if (and coding-system buffer-file-coding-system (null force)) 1145 (setq coding-system 1146 (merge-coding-systems coding-system buffer-file-coding-system))) 1147 (setq buffer-file-coding-system coding-system) 1148 ;; This is in case of an explicit call. Normally, `normal-mode' and 1149 ;; `set-buffer-major-mode-hook' take care of setting the table. 1150 (if (fboundp 'ucs-set-table-for-input) ; don't lose when building 1151 (ucs-set-table-for-input)) 1152 (set-buffer-modified-p t) 1153 (force-mode-line-update)) 1154 1155 (defun revert-buffer-with-coding-system (coding-system &optional force) 1156 "Visit the current buffer's file again using coding system CODING-SYSTEM. 1157 For a list of possible values of CODING-SYSTEM, use \\[list-coding-systems]. 1158 1159 If CODING-SYSTEM leaves the text conversion unspecified, or if it 1160 leaves the end-of-line conversion unspecified, FORCE controls what to 1161 do. If FORCE is nil, get the unspecified aspect (or aspects) from the 1162 buffer's previous `buffer-file-coding-system' value (if it is 1163 specified there). Otherwise, determine it from the file contents as 1164 usual for visiting a file." 1090 1165 (interactive "zCoding system for visited file (default, nil): \nP") 1091 1166 (check-coding-system coding-system) 1092 1167 (if (and coding-system buffer-file-coding-system (null force)) 1093 (let ((base (coding-system-base buffer-file-coding-system)) 1094 (eol (coding-system-eol-type buffer-file-coding-system))) 1095 ;; If CODING-SYSTEM doesn't specify text conversion, merge 1096 ;; with that of buffer-file-coding-system. 1097 (if (eq (coding-system-base coding-system) 'undecided) 1098 (setq coding-system (coding-system-change-text-conversion 1099 coding-system base))) 1100 ;; If CODING-SYSTEM doesn't specify eol conversion, merge with 1101 ;; that of buffer-file-coding-system. 1102 (if (and (vectorp (coding-system-eol-type coding-system)) 1103 (numberp eol) (>= eol 0) (<= eol 2)) 1104 (setq coding-system (coding-system-change-eol-conversion 1105 coding-system eol))))) 1106 (setq buffer-file-coding-system coding-system) 1107 (set-buffer-modified-p t) 1108 (force-mode-line-update)) 1168 (setq coding-system 1169 (merge-coding-systems coding-system buffer-file-coding-system))) 1170 (let ((coding-system-for-read coding-system)) 1171 (revert-buffer))) 1172 1173 (defun set-file-name-coding-system (coding-system) 1174 "Set coding system for decoding and encoding file names to CODING-SYSTEM. 1175 It actually just set the variable `file-name-coding-system' (which 1176 see) to CODING-SYSTEM." 1177 (interactive "zCoding system for file names (default, nil): ") 1178 (check-coding-system coding-system) 1179 (setq file-name-coding-system coding-system)) 1109 1180 1110 1181 (defvar default-terminal-coding-system nil … … 1172 1243 See Info node `Specify Coding' and Info node `Single-Byte Character Support'. 1173 1244 1245 On non-windowing terminals, this is set from the locale by default. 1246 1174 1247 Setting this variable directly does not take effect; 1175 use either M-x customizeor \\[set-keyboard-coding-system]."1248 use either \\[customize] or \\[set-keyboard-coding-system]." 1176 1249 :type '(coding-system :tag "Coding system") 1177 1250 :link '(info-link "(emacs)Specify Coding") … … 1182 1255 (set-keyboard-coding-system value) 1183 1256 (set-default 'keyboard-coding-system nil))) ; must initialize 1184 :version "21. 1"1257 :version "21.4" 1185 1258 :group 'keyboard 1186 1259 :group 'mule) … … 1251 1324 (set-coding-priority-internal))) 1252 1325 1326 ;;; X selections 1327 1328 (defvar ctext-non-standard-encodings-alist 1329 '(("big5-0" big5 2 (chinese-big5-1 chinese-big5-2)) 1330 ("ISO8859-14" iso-8859-14 1 latin-iso8859-14) 1331 ("ISO8859-15" iso-8859-15 1 latin-iso8859-15)) 1332 "Alist of non-standard encoding names vs the corresponding usages in CTEXT. 1333 1334 It controls how extended segments of a compound text are handled 1335 by the coding system `compound-text-with-extensions'. 1336 1337 Each element has the form (ENCODING-NAME CODING-SYSTEM N-OCTET CHARSET). 1338 1339 ENCODING-NAME is an encoding name of an \"extended segments\". 1340 1341 CODING-SYSTEM is the coding-system to encode (or decode) the 1342 characters into (or from) the extended segment. 1343 1344 N-OCTET is the number of octets (bytes) that encodes a character 1345 in the segment. It can be 0 (meaning the number of octets per 1346 character is variable), 1, 2, 3, or 4. 1347 1348 CHARSET is a charater set containing characters that are encoded 1349 in the segment. It can be a list of character sets. It can also 1350 be a char-table, in which case characters that have non-nil value 1351 in the char-table are the target. 1352 1353 On decoding CTEXT, all encoding names listed here are recognized. 1354 1355 On encoding CTEXT, encoding names in the variable 1356 `ctext-non-standard-encodings' (which see) and in the information 1357 listed for the current language environment under the key 1358 `ctext-non-standard-encodings' are used.") 1359 1360 (defvar ctext-non-standard-encodings 1361 '("big5-0") 1362 "List of non-standard encoding names used in extended segments of CTEXT. 1363 Each element must be one of the names listed in the variable 1364 `ctext-non-standard-encodings-alist' (which see).") 1365 1366 (defvar ctext-non-standard-encodings-regexp 1367 (string-to-multibyte 1368 (concat 1369 ;; For non-standard encodings. 1370 "\\(\e%/[0-4][\200-\377][\200-\377]\\([^\002]+\\)\002\\)" 1371 "\\|" 1372 ;; For UTF-8 encoding. 1373 "\\(\e%G[^\e]*\e%@\\)"))) 1374 1375 ;; Functions to support "Non-Standard Character Set Encodings" defined 1376 ;; by the COMPOUND-TEXT spec. They also support "The UTF-8 encoding" 1377 ;; described in the section 7 of the documentation of COMPOUND-TEXT 1378 ;; distributed with XFree86. 1379 1380 (defun ctext-post-read-conversion (len) 1381 "Decode LEN characters encoded as Compound Text with Extended Segments." 1382 (save-match-data 1383 (save-restriction 1384 (let ((case-fold-search nil) 1385 (in-workbuf (string= (buffer-name) " *code-converting-work*")) 1386 last-coding-system-used 1387 pos bytes) 1388 (or in-workbuf 1389 (narrow-to-region (point) (+ (point) len))) 1390 (if in-workbuf 1391 (set-buffer-multibyte t)) 1392 (while (re-search-forward ctext-non-standard-encodings-regexp 1393 nil 'move) 1394 (setq pos (match-beginning 0)) 1395 (if (match-beginning 1) 1396 ;; ESC % / [0-4] M L --ENCODING-NAME-- \002 --BYTES-- 1397 (let* ((M (char-after (+ pos 4))) 1398 (L (char-after (+ pos 5))) 1399 (encoding (match-string 2)) 1400 (encoding-info (assoc-string 1401 encoding 1402 ctext-non-standard-encodings-alist t)) 1403 (coding (if encoding-info 1404 (nth 1 encoding-info) 1405 (setq encoding (intern (downcase encoding))) 1406 (and (coding-system-p encoding) 1407 encoding)))) 1408 (setq bytes (- (+ (* (- M 128) 128) (- L 128)) 1409 (- (point) (+ pos 6)))) 1410 (when coding 1411 (delete-region pos (point)) 1412 (forward-char bytes) 1413 (decode-coding-region (- (point) bytes) (point) coding))) 1414 ;; ESC % G --UTF-8-BYTES-- ESC % @ 1415 (delete-char -3) 1416 (delete-region pos (+ pos 3)) 1417 (decode-coding-region pos (point) 'utf-8)))) 1418 (goto-char (point-min)) 1419 (- (point-max) (point))))) 1420 1421 ;; Return a char table of extended segment usage for each character. 1422 ;; Each value of the char table is nil, one of the elements of 1423 ;; `ctext-non-standard-encodings-alist', or the symbol `utf-8'. 1424 1425 (defun ctext-non-standard-encodings-table () 1426 (let ((table (make-char-table 'translation-table))) 1427 (aset table (make-char 'mule-unicode-0100-24ff) 'utf-8) 1428 (aset table (make-char 'mule-unicode-2500-33ff) 'utf-8) 1429 (aset table (make-char 'mule-unicode-e000-ffff) 'utf-8) 1430 (dolist (encoding (reverse 1431 (append 1432 (get-language-info current-language-environment 1433 'ctext-non-standard-encodings) 1434 ctext-non-standard-encodings))) 1435 (let* ((slot (assoc encoding ctext-non-standard-encodings-alist)) 1436 (charset (nth 3 slot))) 1437 (if charset 1438 (cond ((charsetp charset) 1439 (aset table (make-char charset) slot)) 1440 ((listp charset) 1441 (dolist (elt charset) 1442 (aset table (make-char elt) slot))) 1443 ((char-table-p charset) 1444 (map-char-table #'(lambda (k v) 1445 (if (and v (> k 128)) (aset table k slot))) 1446 charset)))))) 1447 table)) 1448 1449 (defun ctext-pre-write-conversion (from to) 1450 "Encode characters between FROM and TO as Compound Text w/Extended Segments. 1451 1452 If FROM is a string, or if the current buffer is not the one set up for us 1453 by encode-coding-string, generate a new temp buffer, insert the 1454 text, and convert it in the temporary buffer. Otherwise, convert in-place." 1455 (save-match-data 1456 ;; Setup a working buffer if necessary. 1457 (cond ((stringp from) 1458 (let ((buf (current-buffer))) 1459 (set-buffer (generate-new-buffer " *temp")) 1460 (set-buffer-multibyte (multibyte-string-p from)) 1461 (insert from))) 1462 ((not (string= (buffer-name) " *code-converting-work*")) 1463 (let ((buf (current-buffer)) 1464 (multibyte enable-multibyte-characters)) 1465 (set-buffer (generate-new-buffer " *temp")) 1466 (set-buffer-multibyte multibyte) 1467 (insert-buffer-substring buf from to)))) 1468 1469 ;; Now we can encode the whole buffer. 1470 (let ((encoding-table (ctext-non-standard-encodings-table)) 1471 last-coding-system-used 1472 last-pos last-encoding-info 1473 encoding-info end-pos) 1474 (goto-char (setq last-pos (point-min))) 1475 (setq end-pos (point-marker)) 1476 (while (re-search-forward "[^\000-\177]+" nil t) 1477 ;; Found a sequence of non-ASCII characters. 1478 (setq last-pos (match-beginning 0) 1479 last-encoding-info (aref encoding-table (char-after last-pos))) 1480 (set-marker end-pos (match-end 0)) 1481 (goto-char (1+ last-pos)) 1482 (catch 'tag 1483 (while t 1484 (setq encoding-info
