]> code.delx.au - gnu-emacs/blobdiff - lisp/language/cyrillic.el
Restore comma mistakenly removed in last change.
[gnu-emacs] / lisp / language / cyrillic.el
index 9c9c2fd54eb861a3009f173b41443b44e39486fe..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, 2003  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:
 
@@ -186,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
@@ -204,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.")
 
@@ -216,6 +229,7 @@ This works whether or not the table is Unicode-based or
                            'translation-table))
                   (coding-system cyrillic-koi8)
                   (coding-priority cyrillic-koi8 cyrillic-iso-8bit)
+                  (ctext-non-standard-encodings "koi8-r")
                   (input-method . "russian-typewriter")
                   (features cyril-util)
                   (unibyte-display . cyrillic-koi8)
@@ -463,9 +477,51 @@ Support for Russian using koi8-r and the russian-computer input method.")
         ?\\e$,1(V\e(B ?\\e$,1(W\e(B ?\\e$,1(X\e(B ?\\e$,1(Y\e(B ?\\e$,1(Z\e(B ?\\e$,1([\e(B ?\\e$,1(\\e(B ?\\e$,1(]\e(B ?\\e$,1(^\e(B ?\\e$,1(_\e(B ?\\e$,1(`\e(B ?\\e$,1(a\e(B ?\\e$,1(b\e(B ?\\e$,1(c\e(B ?\\e$,1(d\e(B ?\\e$,1(e\e(B ?\\e$,1(f\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")
@@ -477,6 +533,12 @@ Support for Russian using koi8-r and the russian-computer input method.")
 (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")