Changeset 3500

Show
Ignore:
Timestamp:
10/11/04 11:07:08 (4 years ago)
Author:
miyoshi
Message:

* ccl.c: Sync up with Emacs CVS HEAD.

* ccl.h: Ditto.

* data.c (Fdefalias): Ditto.

* lisp/international/ccl.el: Ditto.

* lisp/international/mule.el: Ditto.

* lisp/international/ucs-tables.el: Ditto.

* lisp/international/utf-16.el: Ditto.

* lisp/international/utf-8.el: Ditto.

* lisp/international/utf-7.el: New file from Emacs CVS HEAD.

* cus-load.el: Update.

* loaddefs.el: Ditto.

* files.el (set-auto-mode-1): New function from Emacs CVS HEAD.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/2.2/lisp/ChangeLog.Meadow

    r3484 r3500  
     12004-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 
    1232004-10-03  MIYOSHI Masanori  <miyoshi@meadowy.org> 
    224 
  • branches/2.2/lisp/cus-load.el

    r3480 r3500  
    564564(put 'viper-search 'custom-loads '("viper-init")) 
    565565(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")) 
    567567(put 'glasses 'custom-loads '("glasses")) 
    568568(put 'vhdl-style 'custom-loads '("vhdl-mode")) 
     
    676676(custom-put-if-not 'ps-line-number-color 'custom-version "21.1") 
    677677(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) 
    678680(custom-put-if-not 'confirm-kill-emacs 'custom-version "21.1") 
    679681(custom-put-if-not 'confirm-kill-emacs 'standard-value t) 
     
    803805(custom-put-if-not 'gnus-extra-headers 'custom-version "21.1") 
    804806(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) 
    805809(custom-put-if-not 'speedbar-use-images 'custom-version "21.1") 
    806810(custom-put-if-not 'speedbar-use-images 'standard-value t) 
     
    10211025(custom-put-if-not 'rmail-movemail-flags 'custom-version "20.3") 
    10221026(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") 
    10241028(custom-put-if-not 'keyboard-coding-system 'standard-value t) 
    10251029(custom-put-if-not 'sql-sybase-options 'custom-version "20.8") 
     
    11221126(custom-put-if-not 'eval-expression-print-level 'standard-value t) 
    11231127 
    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")) 
    11251129 "For internal use by custom.") 
    11261130 
  • branches/2.2/lisp/files.el

    r3408 r3500  
    17661766                        (funcall (cdr elt)))))))))))) 
    17671767 
     1768 
     1769(defun set-auto-mode-1 () 
     1770  "Find the -*- spec in the buffer. 
     1771Call with point at the place to start searching from. 
     1772If one is found, set point to the beginning 
     1773and return the position of the end. 
     1774Otherwise, 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 
    17681816(defun hack-local-variables-prop-line () 
    17691817  "Set local variables specified in the -*- line. 
  • branches/2.2/lisp/international/ccl.el

    r3212 r3500  
    33;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN. 
    44;; Licensed to the Free Software Foundation. 
     5;; Copyright (C) 2002 Free Software Foundation, Inc. 
    56 
    67;; Keywords: CCL, mule, multilingual, character set, coding-system 
     
    2627 
    2728;; CCL (Code Conversion Language) is a simple programming language to 
    28 ;; be used for various kind of code conversion.  CCL program is 
    29 ;; compiled to CCL code (vector of integers) and executed by CCL 
    30 ;; interpreter of Emacs. 
     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. 
    3132;; 
    3233;; 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 for 
    34 ;; 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
    3536;; However, since CCL is designed as a powerful programming language, 
    3637;; it can be used for more generic calculation.  For instance, 
    3738;; combination of three or more arithmetic operations can be 
    38 ;; calculated faster than Emacs Lisp. 
     39;; calculated faster than in Emacs Lisp. 
    3940;; 
    40 ;; Syntax and semantics of CCL program is described in the 
     41;; The syntax and semantics of CCL programs are described in the 
    4142;; documentation of `define-ccl-program'. 
    4243 
     
    5354      read-multibyte-character write-multibyte-character 
    5455      translate-character 
    55       iterate-multiple-map map-multiple map-single] 
     56      iterate-multiple-map map-multiple map-single lookup-integer 
     57      lookup-character] 
    5658  "Vector of CCL commands (symbols).") 
    5759 
     
    108110   map-multiple 
    109111   map-single 
     112   lookup-int-const-tbl 
     113   lookup-char-const-tbl 
    110114   ] 
    111115  "Vector of CCL extended compiled codes (symbols).") 
     
    197201;; Embed pair of SYMBOL and PROP where (get SYMBOL PROP) should give 
    198202;; proper index number for SYMBOL.  PROP should be 
    199 ;; `translation-table-id', `code-conversion-map-id', or 
    200 ;; `ccl-program-idx'. 
     203;; `translation-table-id', `translation-hash-table-id' 
     204;; `code-conversion-map-id', or `ccl-program-idx'. 
    201205(defun ccl-embed-symbol (symbol prop) 
    202206  (ccl-embed-data (cons symbol prop))) 
     
    771775               (ccl-embed-code 'write-expr-register 0 
    772776                               (logior (ash op 3) 
    773                                        (get right 'ccl-register-number)))))) 
     777                                       (get right 'ccl-register-number)) 
     778                               left)))) 
    774779 
    775780          (t 
     
    832837           (ccl-check-register Rrr cmd) 
    833838           (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)))) 
    834879  nil) 
    835880 
     
    906951 
    907952  
    908 ;;; CCL dump staffs 
     953;;; CCL dump stuff 
    909954 
    910955;; To avoid byte-compiler warning. 
     
    10761121 
    10771122(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)))) 
    10791125 
    10801126(defun ccl-dump-write-const-string (rrr cc) 
     
    11931239    (insert (format "translation table(%S) r%d r%d\n" tbl RRR rrr)))) 
    11941240 
     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 
    11951249(defun ccl-dump-iterate-multiple-map (rrr RRR Rrr) 
    11961250  (let ((notbl (ccl-get-next-code)) 
     
    12721326STATEMENT := 
    12731327        SET | IF | BRANCH | LOOP | REPEAT | BREAK | READ | WRITE | CALL 
    1274         | TRANSLATE | END 
     1328        | TRANSLATE | MAP | LOOKUP | END 
    12751329 
    12761330SET :=  (REG = EXPRESSION) 
     
    14391493        | (translate-character SYMBOL REG(charset) REG(codepoint)) 
    14401494        ;; SYMBOL must refer to a table defined by `define-translation-table'. 
     1495LOOKUP := 
     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'. 
    14411499MAP := 
    14421500     (iterate-multiple-map REG REG MAP-IDs) 
     
    14841542(provide 'ccl) 
    14851543 
     1544;;; arch-tag: 836bcd27-63a1-4a56-b232-1145ecf823fb 
    14861545;;; ccl.el ends here 
  • branches/2.2/lisp/international/mule.el

    r3326 r3500  
    22 
    33;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN. 
    4 ;; Copyright (C) 2001 Free Software Foundation, Inc. 
    54;; Licensed to the Free Software Foundation. 
     5;; Copyright (C) 2001, 2002 Free Software Foundation, Inc. 
    66 
    77;; Keywords: mule, multilingual, character set, coding system 
     
    6565          (message "Loading %s..." file))) 
    6666      (when purify-flag 
    67         (setq preloaded-file-list (cons file preloaded-file-list))) 
     67        (push file preloaded-file-list)) 
    6868      (unwind-protect 
    6969          (let ((load-file-name fullname) 
     
    270270code in CHARSET. 
    271271 
    272 If CODE1 or CODE2 are invalid (out of range), this function signals an error." 
     272If CODE1 or CODE2 are invalid (out of range), this function signals an 
     273error.  However, the eighth bit of both CODE1 and CODE2 is zeroed 
     274before they are used to index CHARSET.  Thus you may use, say, the 
     275actual ISO 8859 character code rather than subtracting 128, as you 
     276would need to index the corresponding Emacs charset." 
    273277  (make-char-internal (charset-id charset) code1 code2)) 
    274278 
     
    304308Return nil if such a character is not supported. 
    305309Currently the only supported coded character set is `ucs' (ISO/IEC 
    306 10646: Universal Multi-Octet Coded Character Set). 
     31010646: Universal Multi-Octet Coded Character Set), and the result is 
     311translated through the translation-table named 
     312`utf-translation-table-for-decode' or the translation-hash-table named 
     313`utf-subst-table-for-decode'. 
    307314 
    308315Optional argument RESTRICTION specifies a way to map the pair of CCS 
    309316and 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))))))) 
    328342 
    329343(defun encode-char (char ccs &optional restriction) 
     
    33334710646: Universal Multi-Octet Coded Character Set), and CHAR is first 
    334348translated 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'. 
    336351 
    337352CHAR should be in one of these charsets: 
     
    343358code-point in CCS.  Currently not supported and just ignored." 
    344359  (let* ((split (split-char char)) 
    345          (charset (car split))) 
     360         (charset (car split)) 
     361         trans) 
    346362    (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)))))))) 
    368385 
    369386  
     
    495512  (get coding-system 'eol-type)) 
    496513 
     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 
    497525(defun coding-system-lessp (x y) 
    498526  (cond ((eq x 'no-conversion) t) 
     
    563591                 (make-char charset (+ i start) (+ start chars -1))))))) 
    564592 
    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. 
     600It exists just for backward compatibility, and the value is always nil.") 
    581601 
    582602(defun make-subsidiary-coding-system (coding-system) 
     
    692712TYPE is an integer value indicating the type of the coding system as follows: 
    693713  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
    695715  2: ISO-2022 including many variants, 
    696   3: Big5 used mainly on Chinese PC
     716  3: Big5 used mainly on Chinese PCs
    697717  4: private, CCL programs provide encoding/decoding algorithm, 
    698718  5: Raw-text, which means that text contains random 8-bit codes. 
     
    744764 
    745765  o post-read-conversion 
    746   
     766 
    747767  The value is a function to call after some text is inserted and 
    748768  decoded by the coding system itself and before any functions in 
     
    751771  `after-insert-file-functions', i.e. LENGTH of the text inserted, 
    752772  with point at the head of the text to be decoded. 
    753   
     773 
    754774  o pre-write-conversion 
    755   
     775 
    756776  The value is a function to call after all functions in 
    757777  `write-region-annotate-functions' and `buffer-file-format' are 
     
    760780  in `write-region-annotate-functions', i.e. FROM and TO, specifying 
    761781  a region of text. 
    762   
     782 
    763783  o translation-table-for-decode 
    764   
     784 
    765785  The value is a translation table to be applied on decoding.  See 
    766786  the function `make-translation-table' for the format of translation 
    767787  table.  This is not applicable to type 4 (CCL-based) coding systems. 
    768   
     788 
    769789  o translation-table-for-encode 
    770   
     790 
    771791  The value is a translation table to be applied on encoding.  This is 
    772792  not applicable to type 4 (CCL-based) coding systems. 
    773   
     793 
    774794  o safe-chars 
    775   
     795 
    776796  The value is a char table.  If a character has non-nil value in it, 
    777797  the character is safely supported by the coding system.  This 
     
    786806  it just means that some other receiver of text encoded 
    787807  in the coding system won't be able to handle that charset. 
    788   
     808 
    789809  o mime-charset 
    790   
    791   The value is a symbol of which name is `MIME-charset' parameter of 
     810 
     811  The value is a symbol whose name is the `MIME-charset' parameter of 
    792812  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 
    794819  o valid-codes (meaningful only for a coding system based on CCL) 
    795   
     820 
    796821  The value is a list to indicate valid byte ranges of the encoded 
    797822  file.  Each element of the list is an integer or a cons of integer. 
    798823  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. 
    800830 
    801831These properties are set in PLIST, a property list.  This function 
     
    9931023                         (get val 'translation-table)) 
    9941024                    (setq safe-chars (get val 'translation-table))) 
    995                 (register-char-codings coding-system safe-chars) 
    9961025                (setq val safe-chars))) 
    9971026          (plist-put plist prop val))) 
     
    10271056  (put coding-system 'eol-type eol-type) 
    10281057 
     1058  (define-coding-system-internal coding-system) 
     1059 
    10291060  ;; At last, register CODING-SYSTEM in `coding-system-list' and 
    10301061  ;; `coding-system-alist'. 
     
    10551086  coding-system) 
    10561087 
     1088(put 'safe-chars 'char-table-extra-slots 0) 
     1089 
    10571090(defun define-coding-system-alias (alias coding-system) 
    10581091  "Define ALIAS as an alias for coding system CODING-SYSTEM." 
    10591092  (put alias 'coding-system (coding-system-spec coding-system)) 
    1060   (nconc (coding-system-get alias 'alias-coding-systems) (list alias)) 
    10611093  (add-to-coding-system-list alias) 
    10621094  (setq coding-system-alist (cons (list (symbol-name alias)) 
     
    10641096  (let ((eol-type (coding-system-eol-type coding-system))) 
    10651097    (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))) 
    10671101      (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. 
     1105Return 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 
     1121FROM 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))) 
    10681125 
    10691126(defun set-buffer-file-coding-system (coding-system &optional force) 
     
    10731130use \\[list-coding-systems]. 
    10741131 
    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. 
     1132If CODING-SYSTEM leaves the text conversion unspecified, or if it 
     1133leaves the end-of-line conversion unspecified, FORCE controls what to 
     1134do.  If FORCE is nil, get the unspecified aspect (or aspects) from the 
     1135buffer's previous `buffer-file-coding-system' value (if it is 
     1136specified there).  Otherwise, leave it unspecified. 
    10851137 
    10861138This marks the buffer modified so that the succeeding \\[save-buffer] 
     
    10881140don't want to mark the buffer modified, just set the variable 
    10891141`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. 
     1157For a list of possible values of CODING-SYSTEM, use \\[list-coding-systems]. 
     1158 
     1159If CODING-SYSTEM leaves the text conversion unspecified, or if it 
     1160leaves the end-of-line conversion unspecified, FORCE controls what to 
     1161do.  If FORCE is nil, get the unspecified aspect (or aspects) from the 
     1162buffer's previous `buffer-file-coding-system' value (if it is 
     1163specified there).  Otherwise, determine it from the file contents as 
     1164usual for visiting a file." 
    10901165  (interactive "zCoding system for visited file (default, nil): \nP") 
    10911166  (check-coding-system coding-system) 
    10921167  (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. 
     1175It actually just set the variable `file-name-coding-system' (which 
     1176see) 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)) 
    11091180 
    11101181(defvar default-terminal-coding-system nil 
     
    11721243See Info node `Specify Coding' and Info node `Single-Byte Character Support'. 
    11731244 
     1245On non-windowing terminals, this is set from the locale by default. 
     1246 
    11741247Setting this variable directly does not take effect; 
    1175 use either M-x customize or \\[set-keyboard-coding-system]." 
     1248use either \\[customize] or \\[set-keyboard-coding-system]." 
    11761249  :type '(coding-system :tag "Coding system") 
    11771250  :link '(info-link "(emacs)Specify Coding") 
     
    11821255             (set-keyboard-coding-system value) 
    11831256           (set-default 'keyboard-coding-system nil))) ; must initialize 
    1184   :version "21.1
     1257  :version "21.4
    11851258  :group 'keyboard 
    11861259  :group 'mule) 
     
    12511324    (set-coding-priority-internal))) 
    12521325 
     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 
     1334It controls how extended segments of a compound text are handled 
     1335by the coding system `compound-text-with-extensions'. 
     1336 
     1337Each element has the form (ENCODING-NAME CODING-SYSTEM N-OCTET CHARSET). 
     1338 
     1339ENCODING-NAME is an encoding name of an \"extended segments\". 
     1340 
     1341CODING-SYSTEM is the coding-system to encode (or decode) the 
     1342characters into (or from) the extended segment. 
     1343 
     1344N-OCTET is the number of octets (bytes) that encodes a character 
     1345in the segment.  It can be 0 (meaning the number of octets per 
     1346character is variable), 1, 2, 3, or 4. 
     1347 
     1348CHARSET is a charater set containing characters that are encoded 
     1349in the segment.  It can be a list of character sets.  It can also 
     1350be a char-table, in which case characters that have non-nil value 
     1351in the char-table are the target. 
     1352 
     1353On decoding CTEXT, all encoding names listed here are recognized. 
     1354 
     1355On encoding CTEXT, encoding names in the variable 
     1356`ctext-non-standard-encodings' (which see) and in the information 
     1357listed 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. 
     1363Each 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 
     1452If FROM is a string, or if the current buffer is not the one set up for us 
     1453by encode-coding-string, generate a new temp buffer, insert the 
     1454text, 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