]> code.delx.au - gnu-emacs/blobdiff - lisp/language/european.el
Add Unicode equivalents.
[gnu-emacs] / lisp / language / european.el
index 9e9e10ae40234f40775205c513e68f7961d11e4e..4020339376f5ed4d5a78c2e42b535eeccba7cd99 100644 (file)
@@ -1,4 +1,4 @@
-;;; european.el --- European languages -*- coding: iso-2022-7bit; -*-
+;;; european.el --- support for European languages -*- coding: iso-2022-7bit; -*-
 
 ;; Copyright (C) 1995, 1997, 2001 Electrotechnical Laboratory, JAPAN.
 ;; Licensed to the Free Software Foundation.
@@ -63,6 +63,7 @@ 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."))
@@ -263,7 +264,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
@@ -291,8 +307,8 @@ but default input method is set to \"german-postfix\"."))
            (sample-text . "Spanish (Espa\e,Aq\e(Bol)     \e,A!\e(BHola!")
            (documentation . "\
 This language environment is almost the same as Latin-1,
-but default input method is set to \"spanish-postfix\",
-and select's the Spanish tutorial."))
+but the default input method is set to \"spanish-postfix\",
+and it selects the Spanish tutorial."))
  '("European"))
 
 (set-language-info-alist
@@ -523,7 +539,68 @@ but select's the Dutch tutorial."))
  '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^+")
+
+;;;###autoload
+(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)))))
+
+;;;###autoload
+(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)
+      
+;;;###autoload
+(defun diacritic-compose-buffer ()
+  "Compose diacritic characters in the current buffer."
+  (interactive)
+  (diacritic-compose-region (point-min) (point-max)))
+
+;;;###autoload
+(defun diacritic-post-read-conversion (len)
+  (diacritic-compose-region (point) (+ (point) len))
+  len)
+
+;;;###autoload
+(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^+" . diacrtic-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)