aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa1997-09-10 13:14:45 +0000
committerKenichi Handa1997-09-10 13:14:45 +0000
commit2813d65208c6bd5e774450aa8e206845ab149d21 (patch)
tree2b604e6c30ae983d2a647d844cebeb918ab91a07
parent8eeac318b68f0ef2e4d0d9f188f6b3726c574eae (diff)
downloademacs-2813d65208c6bd5e774450aa8e206845ab149d21.tar.gz
emacs-2813d65208c6bd5e774450aa8e206845ab149d21.zip
Don't bind keys in quail-mode-map. The
function added to quail-mode-hook turn ethio-mode on only when input method "ethiopic" is begin used. (ethio-prefer-ascii-space): Moved to lisp/language/ethio-util.el. (ethio-toggle-space): Likewise. (ethio-insert-space): Likewise. (ethio-insert-ethio-space): Likewise. (ethio-prefer-ascii-punctuation): Likewise. (ethio-toggle-punctuation): Likewise. (ethio-gemination): Likewise. ("ethiopic"): Doc-string of this Quail package modified. Bind function keys for TRANSLATION-KEYMAP to quail-execute-non-quail-command.
-rw-r--r--leim/quail/ethiopic.el132
1 files changed, 21 insertions, 111 deletions
diff --git a/leim/quail/ethiopic.el b/leim/quail/ethiopic.el
index 774322f0682..7eb65c8b283 100644
--- a/leim/quail/ethiopic.el
+++ b/leim/quail/ethiopic.el
@@ -28,99 +28,6 @@
28 28
29(require 'quail) 29(require 'quail)
30(require 'ethio-util) 30(require 'ethio-util)
31
32;;
33;; Ethiopic word separator vs. ASCII space
34;;
35
36(defvar ethio-prefer-ascii-space t)
37(make-variable-buffer-local 'ethio-prefer-ascii-space)
38
39(defun ethio-toggle-space nil
40 "Toggle ASCII space and Ethiopic separator for keyboard input."
41 (interactive)
42 (setq ethio-prefer-ascii-space
43 (not ethio-prefer-ascii-space))
44 (force-mode-line-update))
45
46(defun ethio-insert-space (arg)
47 "Insert ASCII spaces or Ethiopic word separators depending on context.
48
49If the current word separator (indicated in mode-line) is the ASCII space,
50insert an ASCII space. With ARG, insert that many ASCII spaces.
51
52If the current word separator is the colon-like Ethiopic word
53separator and the point is preceded by `an Ethiopic punctuation mark
54followed by zero or more ASCII spaces', then insert also an ASCII
55space. With ARG, insert that many ASCII spaces.
56
57Otherwise, insert a colon-like Ethiopic word separator. With ARG, insert that
58many Ethiopic word separators."
59
60 (interactive "*p")
61 (cond
62 (ethio-prefer-ascii-space
63 (insert-char 32 arg))
64 ((save-excursion
65 (skip-chars-backward " ")
66 (memq (preceding-char)
67 '(?$(3$h(B ?$(3$i(B ?$(3$j(B ?$(3$k(B ?$(3$l(B ?$(3$m(B ?$(3$n(B ?$(3$o(B ?$(3%t(B ?$(3%u(B ?$(3%v(B ?$(3%w(B ?$(3%x(B)))
68 (insert-char 32 arg))
69 (t
70 (insert-char ?$(3$h(B arg))))
71
72(defun ethio-insert-ethio-space (arg)
73 "Insert the Ethiopic word delimiter (the colon-like character).
74With ARG, insert that many delimiters."
75 (interactive "*p")
76 (insert-char ?$(3$h(B arg))
77
78;;
79;; Ethiopic punctuation vs. ASCII punctuation
80;;
81
82(defvar ethio-prefer-ascii-punctuation nil)
83(make-variable-buffer-local 'ethio-prefer-ascii-punctuation)
84
85(defun ethio-toggle-punctuation nil
86 "Toggle Ethiopic punctuations and ASCII punctuations for keyboard input."
87 (interactive)
88 (setq ethio-prefer-ascii-punctuation
89 (not ethio-prefer-ascii-punctuation))
90 (let* ((keys '("." ".." "..." "," ",," ";" ";;" ":" "::" ":::" "*" "**"))
91 (puncs
92 (if ethio-prefer-ascii-punctuation
93 '(?. [".."] ["..."] ?, [",,"] ?\; [";;"] ?: ["::"] [":::"] ?* ["**"])
94 '(?$(3$i(B ?$(3%u(B ?. ?$(3$j(B ?, ?$(3$k(B ?\; ?$(3$h(B ?$(3$i(B ?: ?* ?$(3$o(B))))
95 (while keys
96 (quail-defrule (car keys) (car puncs) "ethiopic")
97 (setq keys (cdr keys)
98 puncs (cdr puncs)))
99 (force-mode-line-update)))
100
101;;
102;; Gemination
103;;
104
105(defun ethio-gemination nil
106 "Compose the character before the point with the Ethiopic gemination mark.
107If the characater is already composed, decompose it and remove the gemination
108mark."
109 (interactive "*")
110 (cond
111 ((eq (char-charset (preceding-char)) 'ethiopic)
112 (insert "$(3%s(B")
113 (compose-region
114 (save-excursion (backward-char 2) (point))
115 (point))
116 (forward-char 1))
117 ((eq (char-charset (preceding-char)) 'leading-code-composition)
118 (decompose-region
119 (save-excursion (backward-char 1) (point))
120 (point))
121 (delete-backward-char 1))
122 (t
123 (error ""))))
124 31
125;; 32;;
126;; The package "ethiopic" 33;; The package "ethiopic"
@@ -131,7 +38,11 @@ mark."
131 '("$(3$O#U!.(B " 38 '("$(3$O#U!.(B "
132 (ethio-prefer-ascii-space "_" "$(3$h(B") 39 (ethio-prefer-ascii-space "_" "$(3$h(B")
133 (ethio-prefer-ascii-punctuation "." "$(3$i(B")) 40 (ethio-prefer-ascii-punctuation "." "$(3$i(B"))
134 t " KEYS AND FUNCTIONS 41 t " QUAIL PACKAGE FOR ETHIOPIC (TIGRIGNA AND AMHARIC)
42
43When you activate this package, Ethio minor mode is also turned on.
44
45 KEYS AND FUNCTIONS
135 46
136F2 or `M-x ethio-toggle-space' 47F2 or `M-x ethio-toggle-space'
137 Toggles space characters for keyboard input. The current mode is 48 Toggles space characters for keyboard input. The current mode is
@@ -153,20 +64,15 @@ C-' or `M-x ethio-gemination'
153 If the characater is already composed, decompose it and remove the 64 If the characater is already composed, decompose it and remove the
154 gemination mark." 65 gemination mark."
155 66
156 '(([f2] . ethio-toggle-space) 67 ;; The following keys should work as defined in lisp/language/ethio-util,
157 ([f3] . ethio-toggle-punctuation) 68 ;; even during the translation.
158 (" " . ethio-insert-space) 69 '(([f2] . quail-execute-non-quail-command)
159 ([?\S- ] . ethio-insert-ethio-space) 70 ([f3] . quail-execute-non-quail-command)
160 ([?\C-'] . ethio-gemination)) 71 (" " . quail-execute-non-quail-command)
72 ([?\S- ] . quail-execute-non-quail-command)
73 ([?\C-'] . quail-execute-non-quail-command))
161 t t) 74 t t)
162 75
163;; These keys should work even if translation region is not active.
164(define-key quail-mode-map [f2] 'ethio-toggle-space)
165(define-key quail-mode-map [f3] 'ethio-toggle-punctuation)
166(define-key quail-mode-map " " 'ethio-insert-space)
167(define-key quail-mode-map [?\S- ] 'ethio-insert-ethio-space)
168(define-key quail-mode-map [?\C-'] 'ethio-gemination)
169
170(quail-define-rules 76(quail-define-rules
171 ("he" ?$(3!!(B) 77 ("he" ?$(3!!(B)
172 ("hu" ?$(3!"(B) 78 ("hu" ?$(3!"(B)
@@ -1120,12 +1026,16 @@ C-' or `M-x ethio-gemination'
1120 ("`1000000" ["$(3%$%%(B"]) 1026 ("`1000000" ["$(3%$%%(B"])
1121) 1027)
1122 1028
1123;; The translation of `a' depends on the language (Tigrigna or Amharic).
1124(add-hook 'quail-mode-hook 1029(add-hook 'quail-mode-hook
1125 (lambda nil 1030 (lambda nil
1126 (if (string= (quail-name) "ethiopic") 1031 (if (not (string= (quail-name) "ethiopic"))
1127 (quail-defrule "a" 1032 nil
1128 (if (ethio-prefer-amharic-p) ?$(3"c(B ?$(3"f(B) 1033 ;; Also turn on the Ethio minor mode.
1129 "ethiopic")))) 1034 (ethio-mode 1)
1035 ;; The translation of `a' depends on the language
1036 ;; (either Tigrigna or Amharic).
1037 (quail-defrule "a"
1038 (if (ethio-prefer-amharic-p) ?$(3"c(B ?$(3"f(B)
1039 "ethiopic"))))
1130 1040
1131;;; quail/ethiopic.el ends here 1041;;; quail/ethiopic.el ends here