]> code.delx.au - gnu-emacs/blobdiff - lisp/language/cyrillic.el
Restore comma mistakenly removed in last change.
[gnu-emacs] / lisp / language / cyrillic.el
index e5fd697f4c3b441505a1161c4ef33e4fa44ed12a..3af35f602a5a08925f55b1e5ec915fe5ccf38571 100644 (file)
@@ -1,8 +1,11 @@
 ;;; cyrillic.el --- support for Cyrillic -*- coding: iso-2022-7bit; -*-
 
-;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
-;; Licensed to the Free Software Foundation.
-;; Copyright (C) 2001, 2002  Free Software Foundation, Inc.
+;; Copyright (C) 1997, 1998, 2001, 2002, 2003, 2004, 2005, 2006, 2007
+;;   Free Software Foundation, Inc.
+;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+;;   2005, 2006, 2007
+;;   National Institute of Advanced Industrial Science and Technology (AIST)
+;;   Registration Number H14PRO021
 
 ;; Author: Kenichi Handa <handa@etl.go.jp>
 ;; Keywords: multilingual, Cyrillic, i18n
@@ -11,7 +14,7 @@
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
@@ -21,8 +24,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
@@ -58,7 +61,7 @@
  'cyrillic-iso-8bit 2 ?5
  "ISO 2022 based 8-bit encoding for Cyrillic script (MIME:ISO-8859-5)."
  '(ascii cyrillic-iso8859-5  nil nil
-   nil nil nil nil nil nil nil)
+   nil nil nil nil nil nil nil nil nil nil nil t)
  '((safe-charsets ascii cyrillic-iso8859-5)
    (mime-charset . iso-8859-5)))
 
     ((loop
       (read-multibyte-character r0 r1)
       (translate-character cyrillic-koi8-r-encode-table r0 r1)
+      (if (r0 != ,(charset-id 'ascii))
+         (if (r0 != ,(charset-id 'eight-bit-graphic))
+             (if (r0 != ,(charset-id 'eight-bit-control))
+                 (r1 = ??))))
       (write-repeat r1))))
   "CCL program to encode KOI8-R.")
 
@@ -182,6 +189,13 @@ This works whether or not the table is Unicode-based or
 (define-coding-system-alias 'koi8 'cyrillic-koi8)
 (define-coding-system-alias 'cp878 'cyrillic-koi8)
 
+(let ((elt `("koi8-r" koi8-r 1
+            ,(get 'cyrillic-koi8-r-encode-table 'translation-table)))
+      (slot (assoc "koi8-r" ctext-non-standard-encodings-alist)))
+  (if slot
+      (setcdr slot (cdr elt))
+    (push elt ctext-non-standard-encodings-alist)))
+
 ;; Allow displaying some of KOI & al with an 8859-5-encoded font.  We
 ;; won't bother about the exceptions when encoding the font, since
 ;; NBSP will fall through below and work anyhow, and we'll have
@@ -200,6 +214,9 @@ This works whether or not the table is Unicode-based or
 ;; The table is set up later to encode both Unicode and 8859-5.
 (define-ccl-program ccl-encode-koi8-font
   `(0
+    (if (r2 >= 0)
+       ((r1 <<= 7)
+        (r1 += r2)))
     (translate-character cyrillic-koi8-r-encode-table r0 r1))
   "CCL program to encode Cyrillic chars to KOI font.")
 
@@ -212,13 +229,30 @@ This works whether or not the table is Unicode-based or
                            'translation-table))
                   (coding-system cyrillic-koi8)
                   (coding-priority cyrillic-koi8 cyrillic-iso-8bit)
-                  (input-method . "cyrillic-jcuken")
+                  (ctext-non-standard-encodings "koi8-r")
+                  (input-method . "russian-typewriter")
                   (features cyril-util)
                   (unibyte-display . cyrillic-koi8)
                   (sample-text . "Russian (\e,L@caaZXY\e(B)      \e,L7T`PRabRcYbU\e(B!")
                   (documentation . "Support for Cyrillic KOI8-R."))
  '("Cyrillic"))
 
+(set-language-info-alist
+ "Russian" `((charset cyrillic-iso8859-5)
+            (nonascii-translation
+             . ,(get 'cyrillic-koi8-r-nonascii-translation-table
+                     'translation-table))
+            (coding-system cyrillic-koi8)
+            (coding-priority cyrillic-koi8 cyrillic-iso-8bit)
+            (input-method . "russian-computer")
+            (features cyril-util)
+            (unibyte-display . cyrillic-koi8)
+            (sample-text . "Russian (\e,L@caaZXY\e(B)    \e,L7T`PRabRcYbU\e(B!")
+            (documentation . "\
+Support for Russian using koi8-r and the russian-computer input method.")
+            (tutorial . "TUTORIAL.ru"))
+ '("Cyrillic"))
+
 
 (defvar cyrillic-koi8-u-decode-table
   [
@@ -277,6 +311,10 @@ This works whether or not the table is Unicode-based or
     ((loop
       (read-multibyte-character r0 r1)
       (translate-character cyrillic-koi8-u-encode-table r0 r1)
+      (if (r0 != ,(charset-id 'ascii))
+         (if (r0 != ,(charset-id 'eight-bit-graphic))
+             (if (r0 != ,(charset-id 'eight-bit-control))
+                 (r1 = ??))))
       (write-repeat r1))))
   "CCL program to encode KOI8-U.")
 
@@ -305,7 +343,6 @@ This works whether or not the table is Unicode-based or
                . ,(get 'cyrillic-koi8-u-nonascii-translation-table
                        'translation-table))
               (input-method . "ukrainian-computer")
-              (features code-pages)
               (documentation
                . "Support for Ukrainian with KOI8-U character set."))
  '("Cyrillic"))
@@ -375,6 +412,10 @@ This works whether or not the table is Unicode-based or
     ((loop
       (read-multibyte-character r0 r1)
       (translate-character cyrillic-alternativnyj-encode-table r0 r1)
+      (if (r0 != ,(charset-id 'ascii))
+         (if (r0 != ,(charset-id 'eight-bit-graphic))
+             (if (r0 != ,(charset-id 'eight-bit-control))
+                 (r1 = ??))))
       (write-repeat r1))))
   "CCL program to encode Alternativnyj.")
 
@@ -412,44 +453,95 @@ This works whether or not the table is Unicode-based or
                  (documentation . "Support for Cyrillic ALTERNATIVNYJ."))
  '("Cyrillic"))
 
-(set-language-info-alist
- "Windows-1251" `((coding-system windows-1251)
-                 (coding-priority windows-1251)
-                 (nonascii-translation
-                  . ,(get 'decode-windows-1252 'translation-table))
-                 (input-method . "russian-typewriter") ; fixme?
-                 (features code-pages)
-                 (documentation . "Support for windows-1251 character set."))
- '("Cyrillic"))
-
 (set-language-info-alist
  "Tajik" `((coding-system cyrillic-koi8-t)
-                    (coding-priority cyrillic-koi8-t)
-                    (nonascii-translation
-                     . ,(get 'decode-koi8-t 'translation-table))
-                    (input-method . "russian-typewriter") ; fixme?
-                    (features code-pages)
-                    (documentation . "Support for Tajik using KOI8-T."))
+          (coding-priority cyrillic-koi8-t)
+          (nonascii-translation
+           . ,(get 'decode-koi8-t 'translation-table))
+          (input-method . "russian-typewriter") ; fixme?
+          (features code-pages)
+          (documentation . "Support for Tajik using KOI8-T."))
  '("Cyrillic"))
 
+(eval-and-compile
+  (setq
+   non-iso-charset-alist
+   (cp-make-coding-system
+    windows-1251
+    [?\\e$,1("\e(B ?\\e$,1(#\e(B ?\\e$,1rz\e(B ?\\e$,1(s\e(B ?\\e$,1r~\e(B ?\\e$,1s&\e(B ?\\e$,1s \e(B ?\\e$,1s!\e(B ?\\e$,1tL\e(B ?\\e$,1s0\e(B ?\\e$,1()\e(B ?\\e$,1s9\e(B ?\\e$,1(*\e(B ?\\e$,1(,\e(B ?\\e$,1(+\e(B ?\\e$,1(/\e(B ?\\e$,1(r\e(B
+        ?\\e$,1rx\e(B ?\\e$,1ry\e(B ?\\e$,1r|\e(B ?\\e$,1r}\e(B ?\\e$,1s"\e(B ?\\e$,1rs\e(B ?\\e$,1rt\e(B nil ?\\e$,1ub\e(B ?\\e$,1(y\e(B ?\\e$,1s:\e(B ?\\e$,1(z\e(B ?\\e$,1(|\e(B ?\\e$,1({\e(B ?\\e$,1(\7f\e(B ?\\e,A \e(B ?\\e$,1(.\e(B
+        ?\\e$,1(~\e(B ?\\e$,1((\e(B ?\\e,A$\e(B ?\\e$,1)P\e(B ?\\e,A&\e(B ?\\e,A'\e(B ?\\e$,1(!\e(B ?\\e,A)\e(B ?\\e$,1($\e(B ?\\e,A+\e(B ?\\e,A,\e(B ?\\e,A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e(B
+        ?\\e$,1(g\e(B ?\\e$,1(h\e(B ?\\e$,1(i\e(B ?\\e$,1(j\e(B ?\\e$,1(k\e(B ?\\e$,1(l\e(B ?\\e$,1(m\e(B ?\\e$,1(n\e(B ?\\e$,1(o\e(B] nil ?b)))
+
+;; Register cyrillic-iso8859-5 characters in the encode table of
+;; windows-1251.
+(let ((table (get 'encode-windows-1251 'translation-table))
+      ;; Nth element is a cyrillic-iso8859-5 character encoded to a
+      ;; code (128 + N), or nil.
+      (vec [?\\e,L"\e(B ?\\e,L#\e(B nil ?\\e,Ls\e(B nil nil nil nil nil nil ?\\e,L)\e(B nil ?\\e,L*\e(B ?\\e,L,\e(B ?\\e,L+\e(B ?\\e,L/\e(B
+           ?\\e,Lr\e(B nil nil nil nil nil nil nil nil nil ?\\e,Ly\e(B nil ?\\e,Lz\e(B ?\\e,L|\e(B ?\\e,L{\e(B ?\\e,L\7f\e(B
+           nil ?\\e,L.\e(B ?\\e,L~\e(B ?\\e,L(\e(B nil nil nil nil ?\\e,L!\e(B nil ?\\e,L$\e(B nil nil nil nil ?\\e,L'\e(B
+           nil nil ?\\e,L&\e(B ?\\e,Lv\e(B nil nil nil nil ?\\e,Lq\e(B ?\\e,Lp\e(B ?\\e,Lt\e(B nil ?\\e,Lx\e(B ?\\e,L%\e(B ?\\e,Lu\e(B ?\\e,Lw\e(B
+           ?\\e,L0\e(B ?\\e,L1\e(B ?\\e,L2\e(B ?\\e,L3\e(B ?\\e,L4\e(B ?\\e,L5\e(B ?\\e,L6\e(B ?\\e,L7\e(B ?\\e,L8\e(B ?\\e,L9\e(B ?\\e,L:\e(B ?\\e,L;\e(B ?\\e,L<\e(B ?\\e,L=\e(B ?\\e,L>\e(B ?\\e,L?\e(B
+           ?\\e,L@\e(B ?\\e,LA\e(B ?\\e,LB\e(B ?\\e,LC\e(B ?\\e,LD\e(B ?\\e,LE\e(B ?\\e,LF\e(B ?\\e,LG\e(B ?\\e,LH\e(B ?\\e,LI\e(B ?\\e,LJ\e(B ?\\e,LK\e(B ?\\e,LL\e(B ?\\e,LM\e(B ?\\e,LN\e(B ?\\e,LO\e(B
+           ?\\e,LP\e(B ?\\e,LQ\e(B ?\\e,LR\e(B ?\\e,LS\e(B ?\\e,LT\e(B ?\\e,LU\e(B ?\\e,LV\e(B ?\\e,LW\e(B ?\\e,LX\e(B ?\\e,LY\e(B ?\\e,LZ\e(B ?\\e,L[\e(B ?\\e,L\\e(B ?\\e,L]\e(B ?\\e,L^\e(B ?\\e,L_\e(B
+           ?\\e,L`\e(B ?\\e,La\e(B ?\\e,Lb\e(B ?\\e,Lc\e(B ?\\e,Ld\e(B ?\\e,Le\e(B ?\\e,Lf\e(B ?\\e,Lg\e(B ?\\e,Lh\e(B ?\\e,Li\e(B ?\\e,Lj\e(B ?\\e,Lk\e(B ?\\e,Ll\e(B ?\\e,Lm\e(B ?\\e,Ln\e(B ?\\e,Lo\e(B]))
+  (dotimes (i (length vec))
+    (if (aref vec i)
+       (aset table (aref vec i) (+ 128 i)))))
+
+(define-coding-system-alias 'cp1251 'windows-1251)
+
+(let ((elt `("microsoft-cp1251" windows-1251 1
+            ,(get 'encode-windows-1251 'translation-table)))
+      (slot (assoc "microsoft-cp1251" ctext-non-standard-encodings-alist)))
+  (if slot
+      (setcdr slot (cdr elt))
+    (push elt ctext-non-standard-encodings-alist)))
+
+(define-ccl-program ccl-encode-windows-1251-font
+  `(0
+    ((if (r0 == ,(charset-id 'mule-unicode-0100-24ff))
+        ((r1 <<= 7)
+         (r1 += r2)))
+     (translate-character encode-windows-1251 r0 r1))))
+
+(add-to-list 'font-ccl-encoder-alist
+            '("microsoft-cp1251" . ccl-encode-windows-1251-font))
+
 (set-language-info-alist
  "Bulgarian" `((coding-system windows-1251)
-                 (coding-priority windows-1251)
+              (coding-priority windows-1251)
+              (ctext-non-standard-encodings "microsoft-cp1251")
+              (overriding-fontspec
+               (,(get 'encode-windows-1251 'translation-table)
+                . (nil . "microsoft-cp1251"))
+               (,(get 'cyrillic-koi8-r-encode-table 'translation-table)
+                . (nil . "koi8-r")))
               (nonascii-translation
                . ,(get 'decode-windows-1251 'translation-table))
               (input-method . "bulgarian-bds")
-                 (features code-pages)
               (documentation
-               . "Support for Bulgarian with windows-1251 character set."))
+               . "Support for Bulgarian with windows-1251 character set.")
+              (tutorial . "TUTORIAL.bg"))
  '("Cyrillic"))
 
 (set-language-info-alist
  "Belarusian" `((coding-system windows-1251)
                (coding-priority windows-1251)
+               (ctext-non-standard-encodings "microsoft-cp1251")
+               (overriding-fontspec
+                (,(get 'encode-windows-1251 'translation-table)
+                 . (nil . "microsoft-cp1251"))
+                (,(get 'cyrillic-koi8-r-encode-table 'translation-table)
+                 . (nil . "koi8-r")))
                (nonascii-translation
                 . ,(get 'decode-windows-1251 'translation-table))
                (input-method . "belarusian")
-               (features code-pages)
                (documentation
                 . "Support for Belarusian with windows-1251 character set.
 \(The name Belarusian replaced Byelorussian in the early 1990s.)"))
@@ -457,4 +549,5 @@ This works whether or not the table is Unicode-based or
 
 (provide 'cyrillic)
 
+;;; arch-tag: bda71ae0-ba41-4cb6-a6e0-1dff542313d3
 ;;; cyrillic.el ends here