]> code.delx.au - gnu-emacs/blobdiff - lisp/language/ethio-util.el
(enum event_kind) [MAC_OS]: Update comment for MAC_APPLE_EVENT.
[gnu-emacs] / lisp / language / ethio-util.el
index 37dc4c40a6c67d251997240a9a4e3f227b285f3f..413ad3c318347531752bdbd05e27da086d457df1 100644 (file)
@@ -1,7 +1,10 @@
-;;; ethio-util.el --- utilities for Ethiopic
+;;; ethio-util.el --- utilities for Ethiopic -*- coding: iso-2022-7bit; -*-
 
-;; Copyright (C) 1997 Electrotechnical Laboratory, JAPAN.
-;; Licensed to the Free Software Foundation.
+;; Copyright (C) 1997, 1998, 2002
+;;   Free Software Foundation, Inc.
+;; Copyright (C) 1997, 1998, 1999, 2001, 2004, 2005
+;;   National Institute of Advanced Industrial Science and Technology (AIST)
+;;   Registration Number H14PRO021
 
 ;; Keywords: mule, multilingual, Ethiopic
 
 
 ;; 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.
 
-;; Author: TAKAHASHI Naoto <ntakahas@etl.go.jp>
+;; Author: TAKAHASHI Naoto <ntakahas@m17n.org>
+
+;;; Commentary:
 
 ;;; Code:
 
+(defvar rmail-current-message)
+(defvar rmail-message-vector)
+
 ;; Information for exiting Ethiopic environment.
 (defvar exit-ethiopic-environment-data nil)
 
-;;;###autoload
-(defun setup-ethiopic-environment ()
-  "Setup multilingual environment for Ethiopic."
-  (set-language-environment "Ethiopic"))
-
 ;;;###autoload
 (defun setup-ethiopic-environment-internal ()
   (let ((key-bindings '((" " . ethio-insert-space)
                        ([?\S- ] . ethio-insert-ethio-space)
                        ([?\C-'] . ethio-gemination)
-                       ([f2] . ethio-toggle-space)
-                       ([S-f2] . ethio-replace-space) ; as requested
-                       ([f3] . ethio-toggle-punctuation)
+
+                       ;; these old bindings conflict
+                       ;; with Emacs' binding policy
+
+                       ;; ([f2] . ethio-toggle-space)
+                       ;; ([S-f2] . ethio-replace-space) ; as requested
+                       ;; ([f3] . ethio-toggle-punctuation)
+                       ;; ([f4] . ethio-sera-to-fidel-buffer)
+                       ;; ([S-f4] . ethio-sera-to-fidel-region)
+                       ;; ([C-f4] . ethio-sera-to-fidel-mail-or-marker)
+                       ;; ([f5] . ethio-fidel-to-sera-buffer)
+                       ;; ([S-f5] . ethio-fidel-to-sera-region)
+                       ;; ([C-f5] . ethio-fidel-to-sera-mail-or-marker)
+                       ;; ([f6] . ethio-modify-vowel)
+                       ;; ([f7] . ethio-replace-space)
+                       ;; ([f8] . ethio-input-special-character)
+
+                       ;; this is the rewritten bindings
+
+                       ([f3] . ethio-fidel-to-sera-buffer)
+                       ([S-f3] . ethio-fidel-to-sera-region)
+                       ([C-f3] . ethio-fidel-to-sera-mail-or-marker)
                        ([f4] . ethio-sera-to-fidel-buffer)
                        ([S-f4] . ethio-sera-to-fidel-region)
                        ([C-f4] . ethio-sera-to-fidel-mail-or-marker)
-                       ([f5] . ethio-fidel-to-sera-buffer)
-                       ([S-f5] . ethio-fidel-to-sera-region)
-                       ([C-f5] . ethio-fidel-to-sera-mail-or-marker)
-                       ([f6] . ethio-modify-vowel)
-                       ([f7] . ethio-replace-space)
-                       ([f8] . ethio-input-special-character)))
+                       ([S-f5] . ethio-toggle-punctuation)
+                       ([S-f6] . ethio-modify-vowel)
+                       ([S-f7] . ethio-replace-space)
+                       ([S-f8] . ethio-input-special-character)
+                       ([C-f9] . ethio-toggle-space)
+                       ([S-f9] . ethio-replace-space) ; as requested
+                       ))
        kb)
     (while key-bindings
       (setq kb (car (car key-bindings)))
       (global-set-key kb (cdr (car key-bindings)))
       (setq key-bindings (cdr key-bindings))))
 
-  (add-hook 'quail-mode-hook 'ethio-select-a-translation)
-  (add-hook 'find-file-hooks 'ethio-find-file)
-  (add-hook 'write-file-hooks 'ethio-write-file)
+  (add-hook 'quail-activate-hook 'ethio-select-a-translation)
+  (add-hook 'find-file-hook 'ethio-find-file)
+  (add-hook 'write-file-functions 'ethio-write-file)
   (add-hook 'after-save-hook 'ethio-find-file))
 
 (defun exit-ethiopic-environment ()
-  "Exit Ethiopic language environment"
+  "Exit Ethiopic language environment."
   (while exit-ethiopic-environment-data
     (global-set-key (car (car exit-ethiopic-environment-data))
                    (cdr (car exit-ethiopic-environment-data)))
     (setq exit-ethiopic-environment-data
          (cdr exit-ethiopic-environment-data)))
 
-  (remove-hook 'quail-mode-hook 'ethio-select-a-translation)
-  (remove-hook 'find-file-hooks 'ethio-find-file)
-  (remove-hook 'write-file-hooks 'ethio-write-file)
+  (remove-hook 'quail-activate-hook 'ethio-select-a-translation)
+  (remove-hook 'find-file-hook 'ethio-find-file)
+  (remove-hook 'write-file-functions 'ethio-write-file)
   (remove-hook 'after-save-hook 'ethio-find-file))
 
 ;;
 ;; but file I/O is done in SERA.
 ;;
 ;; If the filename ends in ".java", editing is done in fidel
-;; but file I/O is done in the \uXXXX style, where XXXX is 
+;; but file I/O is done in the \uXXXX style, where XXXX is
 ;; the Unicode codepoint for the Ethiopic character.
 ;;
 ;; If the filename ends in ".tex", editing is done in fidel
@@ -121,7 +144,7 @@ variable.")
 
 (defvar ethio-use-three-dot-question nil
   "*Non-nil means associate ASCII question mark with Ethiopic old style question mark (three vertically stacked dots).
-If nil, associate ASCII question mark with Ethiopic stylised question
+If nil, associate ASCII question mark with Ethiopic stylized question
 mark.  All SERA <--> FIDEL converters refer this variable.")
 
 (defvar ethio-quote-vowel-always nil
@@ -151,7 +174,7 @@ If nil, use uppercases.")
 ;;
 ;; SERA to FIDEL
 ;;
+
 (defconst ethio-sera-to-fidel-table
   [
    nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
@@ -213,7 +236,7 @@ If nil, use uppercases.")
 ;;; I
    ("\e$(3"h\e(B" (?2 "\e$(3#:\e(B"))
 ;;; J
-   ("\e$(3#j\e(B" (?e "\e$(3#e\e(B") (?u "\e$(3#f\e(B") (?i "\e$(3#g\e(B") (?a "\e$(3#h\e(B") (?E "\e$(3#i\e(B") (?o "\e$(3#k\e(B") 
+   ("\e$(3#j\e(B" (?e "\e$(3#e\e(B") (?u "\e$(3#f\e(B") (?i "\e$(3#g\e(B") (?a "\e$(3#h\e(B") (?E "\e$(3#i\e(B") (?o "\e$(3#k\e(B")
          (?W "\e$(3#l\e(B" (?a "\e$(3#l\e(B")
                  (?e "\e$(3#j%n\e(B") (?u "\e$(3#j%r\e(B") (?i "\e$(3#j%o\e(B") (?E "\e$(3#j%q\e(B")))
 ;;; K
@@ -284,18 +307,18 @@ If nil, use uppercases.")
     (?! "\e$(3%t\e(B")
     (?e "\e$(3#5\e(B") (?u "\e$(3#6\e(B") (?U "\e$(3#6\e(B") (?i "\e$(3#7\e(B") (?a "\e$(3#8\e(B") (?A "\e$(3#8\e(B")
         (?E "\e$(3#9\e(B") (?I "\e$(3#:\e(B") (?o "\e$(3#;\e(B") (?O "\e$(3#;\e(B")
-    (?g "\e$(3%^\e(B" 
+    (?g "\e$(3%^\e(B"
         (?e "\e$(3%Y\e(B") (?u "\e$(3%Z\e(B") (?i "\e$(3%[\e(B") (?a "\e$(3%\\e(B") (?E "\e$(3%]\e(B") (?o "\e$(3%_\e(B"))
     (?h "\e$(3"H\e(B"
         (?e "\e$(3"C\e(B") (?u "\e$(3"D\e(B") (?i "\e$(3"E\e(B") (?a "\e$(3"F\e(B") (?E "\e$(3"G\e(B") (?o "\e$(3"I\e(B")
                  (?W "\e$(3"P\e(B" (?e "\e$(3"K\e(B") (?u "\e$(3"P\e(B") (?i "\e$(3"M\e(B") (?a "\e$(3"N\e(B") (?E "\e$(3"O\e(B")))
-    (?k "\e$(3%>\e(B" 
+    (?k "\e$(3%>\e(B"
         (?e "\e$(3%9\e(B") (?u "\e$(3%:\e(B") (?i "\e$(3%;\e(B") (?a "\e$(3%<\e(B") (?E "\e$(3%=\e(B") (?o "\e$(3%?\e(B"))
-    (?s "\e$(3!F\e(B" 
+    (?s "\e$(3!F\e(B"
         (?e "\e$(3!A\e(B") (?u "\e$(3!B\e(B") (?i "\e$(3!C\e(B") (?a "\e$(3!D\e(B") (?E "\e$(3!E\e(B") (?o "\e$(3!G\e(B")
        (?W "\e$(3!H\e(B" (?a "\e$(3!H\e(B")
                   (?e "\e$(3!F%n\e(B") (?u "\e$(3!F%r\e(B") (?i "\e$(3!F%o\e(B") (?E "\e$(3!F%q\e(B")))
-    (?S "\e$(3$L\e(B" 
+    (?S "\e$(3$L\e(B"
        (?e "\e$(3$G\e(B") (?u "\e$(3$H\e(B") (?i "\e$(3$I\e(B") (?a "\e$(3$J\e(B") (?E "\e$(3$K\e(B") (?o "\e$(3$M\e(B")
        (?W "\e$(3$F\e(B" (?a "\e$(3$F\e(B")
                 (?e "\e$(3$L%n\e(B") (?u "\e$(3$L%r\e(B") (?i "\e$(3$L%o\e(B") (?E "\e$(3$L%q\e(B")))
@@ -320,7 +343,7 @@ If nil, use uppercases.")
          (?W "\e$(3%d\e(B" (?e "\e$(3%4\e(B") (?u "\e$(3%d\e(B") (?i "\e$(3%D\e(B") (?a "\e$(3$V\e(B") (?E "\e$(3%T\e(B"))
         (?Y "\e$(3$a\e(B" (?a "\e$(3$a\e(B")))
 ;;; g
-   ("\e$(3#r\e(B" (?e "\e$(3#m\e(B") (?u "\e$(3#n\e(B") (?i "\e$(3#o\e(B") (?a "\e$(3#p\e(B") (?E "\e$(3#q\e(B") (?o "\e$(3#s\e(B") 
+   ("\e$(3#r\e(B" (?e "\e$(3#m\e(B") (?u "\e$(3#n\e(B") (?i "\e$(3#o\e(B") (?a "\e$(3#p\e(B") (?E "\e$(3#q\e(B") (?o "\e$(3#s\e(B")
          (?W "\e$(3#z\e(B" (?e "\e$(3#u\e(B") (?u "\e$(3#z\e(B") (?i "\e$(3#w\e(B") (?a "\e$(3#x\e(B") (?E "\e$(3#y\e(B"))
          (?2 "\e$(3%^\e(B" (?e "\e$(3%Y\e(B") (?u "\e$(3%Z\e(B") (?i "\e$(3%[\e(B") (?a "\e$(3%\\e(B") (?E "\e$(3%]\e(B") (?o "\e$(3%_\e(B")))
 ;;; h
@@ -331,7 +354,7 @@ If nil, use uppercases.")
 ;;; i
    ("\e$(3"e\e(B" (?2 "\e$(3#7\e(B"))
 ;;; j
-   ("\e$(3#j\e(B" (?e "\e$(3#e\e(B") (?u "\e$(3#f\e(B") (?i "\e$(3#g\e(B") (?a "\e$(3#h\e(B") (?E "\e$(3#i\e(B") (?o "\e$(3#k\e(B") 
+   ("\e$(3#j\e(B" (?e "\e$(3#e\e(B") (?u "\e$(3#f\e(B") (?i "\e$(3#g\e(B") (?a "\e$(3#h\e(B") (?E "\e$(3#i\e(B") (?o "\e$(3#k\e(B")
          (?W "\e$(3#l\e(B" (?a "\e$(3#l\e(B")
                  (?e "\e$(3#j%n\e(B") (?u "\e$(3#j%r\e(B") (?i "\e$(3#j%o\e(B") (?E "\e$(3#j%q\e(B")))
 ;;; k
@@ -400,6 +423,11 @@ If nil, use uppercases.")
    nil nil nil nil nil
    ])
 
+;; To avoid byte-compiler warnings.  It should never be set globally.
+(defvar ethio-sera-being-called-by-w3)
+;; This variable will be bound by some third-party package.
+(defvar sera-being-called-by-w3)
+
 ;;;###autoload
 (defun ethio-sera-to-fidel-region (beg end &optional secondary force)
   "Convert the characters in region from SERA to FIDEL.
@@ -407,7 +435,7 @@ The variable `ethio-primary-language' specifies the primary language
 and `ethio-secondary-language' specifies the secondary.
 
 If the 3rd parameter SECONDARY is given and non-nil, assume the region
-begins begins with the secondary language; otherwise with the primary
+begins with the secondary language; otherwise with the primary
 language.
 
 If the 4th parameter FORCE is given and non-nil, perform conversion
@@ -563,16 +591,18 @@ the conversion of \"a\"."
        start table table2 ch)
 
     (setcar (aref ethio-sera-to-fidel-table ?a)
-           (if (eq lang 'tigrigna) "\e$(3"f\e(B" "\e$(3"c\e(B"))     
+           (if (eq lang 'tigrigna) "\e$(3"f\e(B" "\e$(3"c\e(B"))
 
     (while (and (not (eobp)) (null new-language))
       (setq ch (following-char))
       (cond
 
        ;; skip from "<" to ">" (or from "&" to ";") if in w3-mode
-       ((and (boundp 'sera-being-called-by-w3)
-            sera-being-called-by-w3
-            (or (= ch ?<) (= ch ?&)))
+       ((and (or (= ch ?<) (= ch ?&))
+            (or (and (boundp 'ethio-sera-being-called-by-w3)
+                     ethio-sera-being-called-by-w3)
+                (and (boundp 'sera-being-called-by-w3)
+                     sera-being-called-by-w3)))
        (search-forward (if (= ch ?<) ">" ";")
                        nil 0))
 
@@ -699,7 +729,7 @@ changing anything."
 
 (defun ethio-tilde-escape nil
   "Handle a SERA tilde escape in Ethiopic section and delete it.
-Delete the escape even it is not recognised."
+Delete the escape even it is not recognized."
 
   (let ((p (point)) command)
     (skip-chars-forward "^ \t\n\\\\")
@@ -756,7 +786,7 @@ Delete the escape even it is not recognised."
    ((or (string= flag "ti") (string= flag "tir")) 'tigrigna)
    ((or (string= flag "am") (string= flag "amh")) 'amharic)
    (t nil)))
-  
+
 (defun ethio-convert-digit nil
   "Convert Arabic digits to Ethiopic digits."
   (let (ch z)
@@ -794,7 +824,7 @@ Delete the escape even it is not recognised."
 
 ;;;###autoload
 (defun ethio-sera-to-fidel-mail-or-marker (&optional arg)
-  "Execute ethio-sera-to-fidel-mail or ethio-sera-to-fidel-marker depending on the current major mode.
+  "Execute `ethio-sera-to-fidel-mail' or `ethio-sera-to-fidel-marker' depending on the current major mode.
 If in rmail-mode or in mail-mode, execute the former; otherwise latter."
 
   (interactive "P")
@@ -1097,7 +1127,7 @@ See also the descriptions of the variables
                fidel nil
                digit t))
 
-        ;; reduction = 2 and following 10s, 100s, 10000s 
+        ;; reduction = 2 and following 10s, 100s, 10000s
         ((and (= ethio-numeric-reduction 2)
               (memq ch '(370 379 380)))
          (insert (substring (aref ethio-fidel-to-sera-map ch) 1))
@@ -1157,9 +1187,11 @@ See also the descriptions of the variables
          (goto-char (1+ (match-end 0)))) ; because we inserted one byte (\)
 
         ;; skip from "<" to ">" (or from "&" to ";") if called from w3
-        ((and (boundp 'sera-being-called-by-w3)
-              sera-being-called-by-w3
-              (or (= ch ?<) (= ch ?&)))
+        ((and (or (= ch ?<) (= ch ?&))
+              (or (and (boundp 'ethio-sera-being-called-by-w3)
+                       ethio-sera-being-called-by-w3)
+                  (and (boundp 'sera-being-called-by-w3)
+                       sera-being-called-by-w3)))
          (search-forward (if (= ch ?<) ">" ";")
                          nil 0))
 
@@ -1182,7 +1214,7 @@ See also the descriptions of the variables
 
 ;;;###autoload
 (defun ethio-fidel-to-sera-mail-or-marker (&optional arg)
-  "Execute ethio-fidel-to-sera-mail or ethio-fidel-to-sera-marker depending on the current major mode.
+  "Execute `ethio-fidel-to-sera-mail' or `ethio-fidel-to-sera-marker' depending on the current major mode.
 If in rmail-mode or in mail-mode, execute the former; otherwise latter."
 
   (interactive "P")
@@ -1277,11 +1309,11 @@ The markers \"<sera>\" and \"</sera>\" themselves are not deleted."
     (cond
      ;; in case of gemination
      ((eq (char-charset ch) 'composition)
-      (setq ch (string-to-char (decompose-composite-char ch))
+      (setq ch (string-to-char (char-to-string ch))
            composite t))
      ;; neither gemination nor fidel
      ((not (eq (char-charset ch) 'ethiopic))
-      (error "Not a valid character.")))
+      (error "Not a valid character")))
 
     ;; set frequently referred character features
     (setq ch     (ethio-char-to-ethiocode ch)
@@ -1291,7 +1323,7 @@ The markers \"<sera>\" and \"</sera>\" themselves are not deleted."
     (if (or (and (>= ch 344) (<= ch 380)) ;; mYa - `10000
            (and (>= ch 448) (<= ch 452)) ;; \~X - \~A
            (>= ch 458))                  ;; private punctuations
-       (error "Not a valid character."))
+       (error "Not a valid character"))
 
     (setq
      newch
@@ -1794,7 +1826,7 @@ Otherwise, [0-9A-F]."
        (insert (ethio-ethiocode-to-char (- ucode 64560))))
        (t
        nil)))
-    
+
     ;; gemination
     (goto-char (point-min))
     (while (re-search-forward "\\ce\e$(3%s\e(B" nil 0)
@@ -1809,7 +1841,7 @@ Otherwise, [0-9A-F]."
 
 ;;;###autoload
 (defun ethio-find-file nil
-  "Transcribe file content into Ethiopic dependig on filename suffix."
+  "Transcribe file content into Ethiopic depending on filename suffix."
   (cond
 
    ((string-match "\\.sera$" (buffer-file-name))
@@ -1818,7 +1850,7 @@ Otherwise, [0-9A-F]."
       (set-buffer-modified-p nil)))
 
    ((string-match "\\.html$" (buffer-file-name))
-    (let ((sera-being-called-by-w3 t))
+    (let ((ethio-sera-being-called-by-w3 t))
       (save-excursion
        (ethio-sera-to-fidel-marker 'force)
        (goto-char (point-min))
@@ -1855,7 +1887,7 @@ Otherwise, [0-9A-F]."
 
    ((string-match "\\.html$" (buffer-file-name))
     (save-excursion
-      (let ((sera-being-called-by-w3 t)
+      (let ((ethio-sera-being-called-by-w3 t)
            (lq (aref ethio-fidel-to-sera-map 461))
            (rq (aref ethio-fidel-to-sera-map 462)))
        (aset ethio-fidel-to-sera-map 461 "&laquote;")
@@ -1900,6 +1932,8 @@ Otherwise, [0-9A-F]."
   (interactive)
   (setq ethio-prefer-ascii-space
        (not ethio-prefer-ascii-space))
+  (if (equal current-input-method "ethiopic")
+      (setq current-input-method-title (quail-title)))
   (force-mode-line-update))
 
 (defun ethio-insert-space (arg)
@@ -1955,6 +1989,8 @@ With ARG, insert that many delimiters."
       (quail-defrule (car keys) (car puncs) "ethiopic")
       (setq keys (cdr keys)
            puncs (cdr puncs)))
+    (if (equal current-input-method "ethiopic")
+       (setq current-input-method-title (quail-title)))
     (force-mode-line-update)))
 
 ;;
@@ -1963,7 +1999,7 @@ With ARG, insert that many delimiters."
 
 (defun ethio-gemination nil
   "Compose the character before the point with the Ethiopic gemination mark.
-If the characater is already composed, decompose it and remove the gemination
+If the character is already composed, decompose it and remove the gemination
 mark."
   (interactive "*")
   (cond
@@ -1984,4 +2020,5 @@ mark."
 ;;
 (provide 'ethio-util)
 
+;;; arch-tag: c8feb3d6-39bf-4b0a-b6ef-26f03fbc8140
 ;;; ethio-util.el ends here