(devanagari-range): Renamed from `range'. All calls changed.
[bpt/emacs.git] / lisp / language / european.el
index 30d31a4..64664a5 100644 (file)
@@ -1,7 +1,8 @@
-;;; european.el --- European languages -*- coding: iso-2022-7bit; -*-
+;;; european.el --- support for European languages -*- coding: iso-2022-7bit; -*-
 
-;; Copyright (C) 1995, 1997 Electrotechnical Laboratory, JAPAN.
+;; Copyright (C) 1995, 1997, 2001 Electrotechnical Laboratory, JAPAN.
 ;; Licensed to the Free Software Foundation.
+;; Copyright (C) 2001 Free Software Foundation, Inc.
 
 ;; Keywords: multilingual, European
 
@@ -24,7 +25,8 @@
 
 ;;; Commentary:
 
-;; For Europeans, character sets ISO8859-1,2,3,4,9,14,15 are supported.
+;; For European scripts, character sets ISO8859-1,2,3,4,9,14,15 are
+;; supported.
 
 ;;; Code:
 
@@ -59,7 +61,11 @@ character set which supports the following European languages:
  German, Greenlandic, Icelandic, Irish Gaelic (new orthography),
  Italian, Latin, Luxemburgish, Norwegian, Portuguese, Rhaeto-Romanic,
  Scottish Gaelic, Spanish, and Swedish.
-We also have a German specific language environment \"German\".
+We also have specific language environments for the following languages:
+  For Dutch, \"Dutch\".
+  For German, \"German\".
+  For Spanish, \"Spanish\".
+  For French, \"French\".
 
 Latin-1 also covers several written languages outside Europe, including
 Indonesian/Malay, Tagalog (Philippines), Swahili and Afrikaans."))
@@ -148,7 +154,7 @@ These languages are supported with the Latin-3 (ISO-8859-3) character set:
             (nonascii-translation . latin-iso8859-4)
             (unibyte-syntax . "latin-4")
             (unibyte-display . iso-8859-4)
-            (input-method . "latin-4-prefix")
+            (input-method . "latin-4-postfix")
             (documentation . "\
 These languages are supported with the Latin-4 (ISO-8859-4) character set:
  Danish, English, Estonian, Finnish, German, Greenlandic, Lappish,
@@ -176,7 +182,7 @@ These languages are supported with the Latin-4 (ISO-8859-4) character set:
             (nonascii-translation . latin-iso8859-9)
             (unibyte-syntax . "latin-5")
             (unibyte-display . iso-latin-5)
-            (input-method . "latin-5-prefix")
+            (input-method . "latin-5-postfix")
             (documentation . "\
 These languages are supported with the Latin-5 (ISO-8859-9) character set:
 Bulgarian, Byelorussian, (Slavic) Macedonian, Russian, Serbian and
@@ -260,7 +266,22 @@ German (Deutsch Nord)      Guten Tag
 German (Deutsch S\e,A|\e(Bd)     Gr\e,A|_\e(B Gott")
            (documentation . "\
 This language environment is almost the same as Latin-1,
-but default input method is set to \"german-postfix\"."))
+but the default input method is set to \"german-postfix\"."))
+ '("European"))
+
+(set-language-info-alist
+ "French" '((tutorial . "TUTORIAL.fr")
+           (charset ascii latin-iso8859-1)
+           (coding-system iso-latin-1)
+           (coding-priority iso-latin-1)
+           (nonascii-translation . latin-iso8859-1)
+           (unibyte-syntax . "latin-1")
+           (unibyte-display . iso-latin-1)
+           (input-method . "latin-1-prefix")
+           (sample-text . "French (Fran\e,Ag\e(Bais)     Bonjour, Salut")
+           (documentation . "\
+This language environment is almost the same as Latin-1,
+but the tutorial is set to \"TUTORIAL.fr\"."))
  '("European"))
 
 (set-language-info-alist
@@ -276,6 +297,36 @@ but default input method is set to \"german-postfix\"."))
              (documentation . t))
  '("European"))
 
+(set-language-info-alist
+ "Spanish" '((tutorial . "TUTORIAL.es")
+           (charset ascii latin-iso8859-1)
+           (coding-system iso-latin-1)
+           (coding-priority iso-latin-1)
+           (input-method . "spanish-postfix")
+           (nonascii-translation . iso-latin-1)
+           (unibyte-syntax . "latin-1")
+           (unibyte-display . iso-latin-1)
+           (sample-text . "Spanish (Espa\e,Aq\e(Bol)     \e,A!\e(BHola!")
+           (documentation . "\
+This language environment is almost the same as Latin-1,
+but the default input method is set to \"spanish-postfix\",
+and it selects the Spanish tutorial."))
+ '("European"))
+
+(set-language-info-alist
+ "Dutch" '((tutorial . "TUTORIAL.nl")
+          (charset ascii latin-iso8859-1)
+          (coding-system iso-latin-1)
+          (coding-priority iso-latin-1)
+          (nonascii-translation . iso-latin-1)
+          (unibyte-syntax . "latin-1")
+          (unibyte-display . iso-latin-1)
+          (sample-text . "Er is een aantal manieren waarop je dit kan doen")
+          (documentation . "\
+This language environment is almost the same as Latin-1,
+but select's the Dutch tutorial."))
+ '("European"))
+
 ;; For Turkish, the character set ISO-8859-9 (Latin-5) is used.  But,
 ;; before the introduction of ISO-8859-9 in 1988, ISO-8859-3 (Latin-3)
 ;; was used for Turkish.  Those who use Latin-3 for Turkish should use
@@ -305,10 +356,40 @@ but default input method is set to \"german-postfix\"."))
           (unibyte-syntax . "latin-2")
           (unibyte-display . iso-8859-2)
           (tutorial . "TUTORIAL.pl")
-          (sample-text . "\e,B1!fFjJ3#qQsS6&?/<,\e(B")
+          (sample-text . "P\e,Bs\e(Bjd\e,B<\e(B, ki\e,Bq\e(B-\e,B?\e(Be t\e,Bj\e(B chmurno\e,B6f\e(B w g\e,B31\e(Bb flaszy")
           (documentation . t))
  '("European"))
 
+(set-language-info-alist
+ "Welsh" `((coding-system utf-8 latin-8) ; the input method is Unicode-based
+          (coding-priority utf-8 latin-8)
+          (input-method . "welsh")
+          (documentation . "Support for Welsh, using Unicode."))
+ '("European"))
+
+(set-language-info-alist
+ "Latin-7" `((coding-system latin-7)
+            (coding-priority latin-7)
+            ;; Fixme: input-method
+            (features code-pages)
+            (documentation . "Support for Latin-7, e.g. Latvian, Lithuanian."))
+ '("European"))
+
+(set-language-info-alist
+ "Lithuanian" `((coding-system latin-7)
+               (coding-priority latin-7)
+               (input-method . "lithuanian-keyboard")
+               (features code-pages)
+               (documentation . "Support for Lithuanian."))
+ '("European"))
+
+(set-language-info-alist
+ "Latvian" `((coding-system latin-7)
+            (coding-priority latin-7)
+            (input-method . "latvian-keyboard")
+            (features code-pages)
+            (documentation . "Support for Latvian."))
+ '("European"))
 \f
 ;; Definitions for the Mac Roman character sets and coding system.
 ;; The Mac Roman encoding uses all 128 code points in the range 128 to
@@ -490,7 +571,63 @@ but default input method is set to \"german-postfix\"."))
  'mac-roman 4 ?M "Mac Roman Encoding"
  '(decode-mac-roman . encode-mac-roman)
  '((safe-chars . mac-roman-encoder)
-   (valid-codes (0 . 255))))
+   (valid-codes (0 . 255))
+   (mime-charset . macintosh)))                ; per IANA, rfc1345
+
+(defconst diacritic-composition-pattern "\\C^\\c^+")
+
+(defun diacritic-compose-region (beg end)
+  "Compose diacritic characters in the region.
+When called from a program, expects two arguments,
+positions (integers or markers) specifying the region."
+  (interactive "r")
+  (save-restriction
+    (narrow-to-region beg end)
+    (goto-char (point-min))
+    (while (re-search-forward diacritic-composition-pattern nil t)
+      (compose-region (match-beginning 0) (match-end 0)))))
+
+(defun diacritic-compose-string (string)
+  "Compose diacritic characters in STRING and return the resulting string."
+  (let ((idx 0))
+    (while (setq idx (string-match diacritic-composition-pattern string idx))
+      (compose-string string idx (match-end 0))
+      (setq idx (match-end 0))))
+  string)
+      
+(defun diacritic-compose-buffer ()
+  "Compose diacritic characters in the current buffer."
+  (interactive)
+  (diacritic-compose-region (point-min) (point-max)))
+
+(defun diacritic-post-read-conversion (len)
+  (diacritic-compose-region (point) (+ (point) len))
+  len)
+
+(defun diacritic-composition-function (from to pattern &optional string)
+  "Compose diacritic text in the region FROM and TO.
+The text matches the regular expression PATTERN.
+Optional 4th argument STRING, if non-nil, is a string containing text
+to compose.
+
+The return value is number of composed characters."
+  (if (< (1+ from) to)
+      (prog1 (- to from)
+       (if string
+           (compose-string string from to)
+         (compose-region from to))
+       (- to from))))
+
+;; Register a function to compose Unicode diacrtics and marks.
+(let ((patterns '(("\\C^\\c^+" . diacritic-composition-function))))
+  (let ((c #x300))
+    (while (<= c #x362)
+      (aset composition-function-table (decode-char 'ucs c) patterns)
+      (setq c (1+ c)))
+    (setq c #x20d0)
+    (while (<= c #x20e3)
+      (aset composition-function-table (decode-char 'ucs c) patterns)
+      (setq c (1+ c)))))
 
 (provide 'european)